Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Concourse postgres conditional dependency #1390

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stable/concourse/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: concourse
version: 0.1.3
version: 0.2.0
description: Concourse is a simple and scalable CI system.
icon: https://avatars1.githubusercontent.com/u/7809479
keywords:
Expand Down
49 changes: 49 additions & 0 deletions stable/concourse/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,30 @@ Scaling should typically be managed via the `helm upgrade` command, but `Statefu
$ kubectl scale statefulset my-release-worker --replicas=3
```

### Restarting workers

If worker pods go down, their persistent volumes are changed, or if you're having other issues with them, you'll need to restart the workers. Concourse workers were designed to be deployed onto infrastructure VMs which are less "ephemeral" than pods, so it isn't good at detecting when a worker goes down and comes back under the same hostname.

Scale the workers down to 0:

```
kubectl scale statefulset concourse-worker --replicas=0

```

And then `fly workers` until the workers are detected to be `stalled`. Then for each worker
```
fly prune-worker -w concourse-worker-0
fly prune-worker -w concourse-worker-1
...

```
And finally

```
kubectl scale statefulset concourse-worker --replicas=3
```

## Configuration

The following tables lists the configurable parameters of the Concourse chart and their default values.
Expand Down Expand Up @@ -110,6 +134,8 @@ The following tables lists the configurable parameters of the Concourse chart an
| `persistence.worker.class` | Concourse Worker Persistent Volume Storage Class | `generic` |
| `persistence.worker.accessMode` | Concourse Worker Persistent Volume Access Mode | `ReadWriteOnce` |
| `persistence.worker.size` | Concourse Worker Persistent Volume Storage Size | `10Gi` |
| `postgresql.enabled` | Enable PostgreSQL as a chart dependency | `true` |
| `postgresql.uri` | PostgreSQL connection URI | `nil` |
| `postgresql.postgresUser` | PostgreSQL User to create | `concourse` |
| `postgresql.postgresPassword` | PostgreSQL Password for the new user | `concourse` |
| `postgresql.postgresDatabase` | PostgreSQL Database to create | `concourse` |
Expand Down Expand Up @@ -244,3 +270,26 @@ web:
hosts:
- concourse.domain.com
```


### PostgreSQL

By default, this chart will use a PostgreSQL database deployed as a chart dependency. You can also bring your own PostgreSQL. To do so, set the following in your custom `values.yaml` file:

```yaml
## Configuration values for the postgresql dependency.
## ref: https://github.com/kubernetes/charts/blob/master/stable/postgresql/README.md
##
postgresql:

## Use the PostgreSQL chart dependency.
## Set to false if bringing your own PostgreSQL.
##
enabled: false

## If bringing your own PostgreSQL, the full uri to use
## e.g. postgres://concourse:changeme@my-postgres.com:5432/concourse?sslmode=require
##
uri: postgres://concourse:changeme@my-postgres.com:5432/concourse?sslmode=require
Copy link
Contributor

@gmile gmile Jul 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to specify a uri with credentials that are not known upfront? E.g. when existing postgres installation pulls password from a secret object in cluster


```
1 change: 1 addition & 0 deletions stable/concourse/requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ dependencies:
- name: postgresql
version: 0.3.0
repository: https://kubernetes-charts.storage.googleapis.com/
condition: postgresql.enabled
4 changes: 4 additions & 0 deletions stable/concourse/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ metadata:
heritage: "{{ .Release.Service }}"
type: Opaque
data:
{{ if .Values.postgresql.enabled }}
postgresql-user: {{ .Values.postgresql.postgresUser | b64enc | quote }}
{{ else }}
postgresql-uri: {{ .Values.postgresql.uri | b64enc | quote }}
{{ end }}
basic-auth-username: {{ .Values.concourse.username | b64enc | quote }}
basic-auth-password: {{ .Values.concourse.password | b64enc | quote }}
host-key: {{ .Values.concourse.hostKey | b64enc | quote }}
Expand Down
8 changes: 8 additions & 0 deletions stable/concourse/templates/web-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ spec:
args:
- "web"
env:
{{ if .Values.postgresql.enabled }}
- name: POSTGRES_HOST
valueFrom:
configMapKeyRef:
Expand All @@ -43,6 +44,13 @@ spec:
key: postgresql-database
- name: CONCOURSE_POSTGRES_DATA_SOURCE
value: postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@$(POSTGRES_HOST)/$(POSTGRES_DATABASE)?sslmode=disable
{{ else }}
- name: CONCOURSE_POSTGRES_DATA_SOURCE
valueFrom:
secretKeyRef:
name: {{ template "concourse.fullname" . }}
key: postgresql-uri
{{ end }}
- name: POD_IP
valueFrom:
fieldRef:
Expand Down
11 changes: 11 additions & 0 deletions stable/concourse/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,17 @@ persistence:
## ref: https://github.com/kubernetes/charts/blob/master/stable/postgresql/README.md
##
postgresql:

## Use the PostgreSQL chart dependency.
## Set to false if bringing your own PostgreSQL.
##
enabled: true

## If bringing your own PostgreSQL, the full uri to use
## e.g. postgres://concourse:changeme@my-postgres.com:5432/concourse?sslmode=disable
##
# uri:

### PostgreSQL User to create.
##
postgresUser: concourse
Expand Down