Skip to content

Commit 0488105

Browse files
authored
Add opt-in config checksum annotation for auto pod restarts (#76)
ConfigMap changes don't trigger pod restarts, so config updates silently fail to take effect after helm upgrade. This adds an opt-in `restartOnConfigChange` value (default false) that injects a `checksum/config` pod annotation, triggering rolling restarts when the rendered config changes. This is related to #15 and the closed #22.
1 parent d964ddd commit 0488105

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,19 @@ podAntiAffinity:
135135
type: soft # "soft" (preferred) or "hard" (required)
136136
```
137137

138+
### Config Change Restarts
139+
140+
By default, ConfigMap changes are not automatically picked up by
141+
running pods. Enable `restartOnConfigChange` to trigger a rolling
142+
restart whenever the rendered config changes:
143+
144+
```yaml
145+
restartOnConfigChange: true
146+
```
147+
148+
This injects a `checksum/config` pod annotation that changes when the
149+
config template output changes, causing Kubernetes to roll the pods.
150+
138151
### ExternalSecrets Integration
139152

140153
Securely manage credentials using ExternalSecrets operator:

templates/deployment.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@ spec:
3030
metadata:
3131
labels:
3232
{{- include "pgdog.selectorLabels" . | nindent 8 }}
33-
{{- if .Values.podAnnotations }}
33+
{{- if or .Values.restartOnConfigChange .Values.podAnnotations }}
3434
annotations:
35+
{{- if .Values.restartOnConfigChange }}
36+
checksum/config: {{ include (print $.Template.BasePath "/config.yaml") . | sha256sum }}
37+
{{- end }}
38+
{{- if .Values.podAnnotations }}
3539
{{- toYaml .Values.podAnnotations | nindent 8 }}
40+
{{- end }}
3641
{{- end }}
3742
spec:
3843
{{- if .Values.serviceAccount.create }}

values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ annotations: {}
1919
# allows adding custom annotations to the pods
2020
podAnnotations: {}
2121

22+
# restartOnConfigChange triggers a rolling restart when pgdog config changes.
23+
# Disabled by default; enable if you don't have a hot-reload mechanism (e.g. SIGHUP sidecar).
24+
# See: https://github.com/pgdogdev/helm/issues/15
25+
# restartOnConfigChange: false
26+
2227
# clusterName identifies the Kubernetes cluster (optional)
2328
# When set, this will be added as a label to all Prometheus metrics
2429
# clusterName: ""

0 commit comments

Comments
 (0)