pgdogdev/helm · issue #121

A bad config rolls out to every PgDog pod, because the Helm chart has no readiness probe.

A default readiness probe on PgDog's own healthcheck endpoint stops the rollout at the first broken pod, and the old pods keep serving. This is the approach Lev suggested in #121, recorded on a kind cluster.

PR #163Issue #121pgdogdev/helm

Same typo, two charts

2 replicas, the chart's default values, Postgres 18 in the cluster. The values change has a typo in the database host. rollout restart is how a config change reaches pods, since PgDog reloads most settings in place and the chart doesn't roll pods for a ConfigMap change.

Before: chart main (v0.95)both pods replaced in 2 s
$ helm upgrade pgdog pgdogdev/pgdog -f bad.yaml # host: postgres-primary (typo)
$ kubectl rollout restart deploy/pgdog
Waiting for deployment "pgdog" rollout to finish: 1 out of 2 new replicas have been updated...
(5 more Waiting lines)
deployment "pgdog" successfully rolled out # 05:21:55 → 05:21:57
$ kubectl get pods
pgdog-5d864f4bc5-5885d 0/1 Completed 0 24s
pgdog-5d864f4bc5-srgkk 1/1 Terminating 0 24s
pgdog-8884db45c-54jmp 1/1 Running 0 1s
pgdog-8884db45c-cmkz7 1/1 Running 0 2s
$ psql -h pgdog -p 6432 -U postgres -d app -c 'select 1' # 3 tries
ERROR: connection pool for user "postgres" and database "app" is down
ERROR: connection pool for user "postgres" and database "app" is down
ERROR: connection pool for user "postgres" and database "app" is down
After: default readiness proberollout stops at pod 1
$ helm upgrade pgdog ./helm -f bad.yaml # same typo, chart with the fix
$ kubectl rollout restart deploy/pgdog
error: timed out waiting for the condition # rollout stopped
$ kubectl get pods
pgdog-5f7984bd86-vzpcn 0/1 Running 0 45s # new pod, readiness 502
pgdog-86b8f4f5fd-4zlqn 1/1 Running 0 67s # old pods keep serving
pgdog-86b8f4f5fd-mfgh4 1/1 Running 0 56s
$ psql -h pgdog -p 6432 -U postgres -d app -c 'select 1' # 3 tries
1
1
1
Same result on 3 of 3 runs, and with an unreachable IP instead of a typo.

The change

Three files, +38/−4 including a test. The probe is added only when you haven't set your own.

diff (trimmed to the template lines)fix/default-readiness-probe
# values.yaml
-# healthcheckPort: 8080
+healthcheckPort: 8080
# templates/deployment.yaml (container ports)
+ {{- if .Values.healthcheckPort }}
+ - name: healthcheck
+ containerPort: {{ .Values.healthcheckPort }}
+ {{- end }}
# templates/deployment.yaml (probes)
{{- if .Values.readinessProbe }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
+ {{- else if .Values.healthcheckPort }}
+ readinessProbe:
+ initialDelaySeconds: 10
+ httpGet:
+ path: /
+ port: healthcheck
{{- end }}

What else was checked

Rerun it

The values files, Postgres manifest and logs are in the demo repo. With kind and helm installed: create a cluster, apply pg.yaml, install the chart with good.yaml, then upgrade with bad.yaml and run kubectl rollout restart deploy/pgdog.