diff --git a/README.md b/README.md index 8d29337..51d01e3 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,19 @@ podAntiAffinity: type: soft # "soft" (preferred) or "hard" (required) ``` +### Config Change Restarts + +By default, ConfigMap changes are not automatically picked up by +running pods. Enable `restartOnConfigChange` to trigger a rolling +restart whenever the rendered config changes: + +```yaml +restartOnConfigChange: true +``` + +This injects a `checksum/config` pod annotation that changes when the +config template output changes, causing Kubernetes to roll the pods. + ### ExternalSecrets Integration Securely manage credentials using ExternalSecrets operator: diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 18902bf..b63e967 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -30,9 +30,14 @@ spec: metadata: labels: {{- include "pgdog.selectorLabels" . | nindent 8 }} - {{- if .Values.podAnnotations }} + {{- if or .Values.restartOnConfigChange .Values.podAnnotations }} annotations: + {{- if .Values.restartOnConfigChange }} + checksum/config: {{ include (print $.Template.BasePath "/config.yaml") . | sha256sum }} + {{- end }} + {{- if .Values.podAnnotations }} {{- toYaml .Values.podAnnotations | nindent 8 }} + {{- end }} {{- end }} spec: {{- if .Values.serviceAccount.create }} diff --git a/values.yaml b/values.yaml index 0ada9a4..752888d 100644 --- a/values.yaml +++ b/values.yaml @@ -19,6 +19,11 @@ annotations: {} # allows adding custom annotations to the pods podAnnotations: {} +# restartOnConfigChange triggers a rolling restart when pgdog config changes. +# Disabled by default; enable if you don't have a hot-reload mechanism (e.g. SIGHUP sidecar). +# See: https://github.com/pgdogdev/helm/issues/15 +# restartOnConfigChange: false + # clusterName identifies the Kubernetes cluster (optional) # When set, this will be added as a label to all Prometheus metrics # clusterName: ""