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: {}