From 1a598ac4fa3726ab4c71ae9bf52a109bce930ec5 Mon Sep 17 00:00:00 2001 From: Cheryl Aurelia <135518448+cherylaurelia@users.noreply.github.com> Date: Mon, 9 Nov 2026 15:12:30 -0500 Subject: [PATCH] feat: readiness probe on healthcheckPort The chart rendered no readiness probe, so Kubernetes treated a PgDog pod whose pools are all down as ready, even with healthcheckPort set. When healthcheckPort is set, declare it as a container port and, unless the user has set readinessProbe, add an HTTP readiness probe on it. The endpoint only fails when every pool is down, so one unreachable database keeps the pod ready. Pools report healthy until their first connection attempt fails (up to connect_timeout), hence the 10s initial delay. healthcheckPort stays unset by default, so default renders are unchanged, and a user-set readinessProbe is unchanged. No liveness probe: restarting PgDog during a database outage would drop every client. test/values-healthcheck-port.yaml renders the probe through the kubeconform loop. Co-Authored-By: Claude Opus 5.5 --- templates/deployment.yaml | 12 ++++++++++++ test/values-healthcheck-port.yaml | 2 ++ values.yaml | 7 +++++-- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 test/values-healthcheck-port.yaml diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 0ae2b6b..899d743 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -155,6 +155,10 @@ spec: containerPort: {{ .Values.port }} - name: metrics containerPort: {{ .Values.openMetricsPort }} + {{- if .Values.healthcheckPort }} + - name: healthcheck + containerPort: {{ .Values.healthcheckPort }} + {{- end }} {{- if .Values.lifecycle }} {{- if .Values.preStopSleepSeconds }} {{- fail "lifecycle replaces the preStop that preStopSleepSeconds renders; set one of them" }} @@ -178,6 +182,14 @@ spec: {{- if .Values.readinessProbe }} readinessProbe: {{- toYaml .Values.readinessProbe | nindent 12 }} + {{- else if .Values.healthcheckPort }} + readinessProbe: + # Pools report healthy until their first connection attempt fails, + # which takes up to connect_timeout (5s by default). + initialDelaySeconds: 10 + httpGet: + path: / + port: healthcheck {{- end }} {{- if .Values.startupProbe }} startupProbe: diff --git a/test/values-healthcheck-port.yaml b/test/values-healthcheck-port.yaml new file mode 100644 index 0000000..298863f --- /dev/null +++ b/test/values-healthcheck-port.yaml @@ -0,0 +1,2 @@ +# Test healthcheck port with its default HTTP readiness probe +healthcheckPort: 8080 diff --git a/values.yaml b/values.yaml index 7c15f6a..4502fea 100644 --- a/values.yaml +++ b/values.yaml @@ -66,7 +66,9 @@ port: 6432 # net.core.somaxconn, so raise both settings when increasing this value. # Defaults to 1024. This setting cannot be changed at runtime. # listenBacklog: 1024 -# healthcheckPort on which PgDog will expose healthcheck endpoint +# healthcheckPort on which PgDog will expose its HTTP healthcheck endpoint. +# It returns 502 when every connection pool is down. Unless readinessProbe is +# set, the chart uses it as the readiness probe. # (if not specified, no separate healthcheck port is configured) # healthcheckPort: 8080 # Optional [general] setting; omitted unless explicitly set to true or false. @@ -109,7 +111,8 @@ replicas: 2 # Optional: Deployment rollout strategy (Deployment only) # strategy: {} -# Optional: container health probes (disabled by default) +# Optional: container health probes. When readinessProbe is not set and +# healthcheckPort is, the chart adds an HTTP readiness probe on healthcheckPort. # livenessProbe: {} # readinessProbe: {} # startupProbe: {}