From a9ecfeef4566d21c844b8a05928d08cc1bba49e6 Mon Sep 17 00:00:00 2001 From: Evans Mungai Date: Tue, 15 Sep 2026 22:11:58 +0100 Subject: [PATCH] helm: roll master pods when master config changes (#11331) * helm: roll master pods when master config changes The master loads master.toml once at startup (startAdminScripts reads master.maintenance.scripts and sleep_minutes via viper with no config watching), and the master ConfigMap is mounted with subPath, which kubelet never refreshes in a running pod. So a change to .Values.master.config today updates the ConfigMap but running masters keep executing the old configuration until something else restarts them. Add a checksum/config annotation on the master pod template, following the existing checksum/s3config pattern on the filer and s3 pods, so a master config change triggers a rolling restart of the masters. Signed-off-by: Evans Mungai * Guard against duplicate keys Signed-off-by: Evans Mungai * Add checksum to deployment as well Signed-off-by: Evans Mungai * Always ensure the annotation is set Signed-off-by: Evans Mungai * Update comments Signed-off-by: Evans Mungai * Soften stance Signed-off-by: Evans Mungai * helm: merge pod annotations before checksums --------- Signed-off-by: Evans Mungai Co-authored-by: Chris Lu --- .../all-in-one/all-in-one-deployment.yaml | 23 ++++++++----------- .../templates/filer/filer-statefulset.yaml | 16 +++++-------- .../templates/master/master-statefulset.yaml | 9 +++----- .../seaweedfs/templates/s3/s3-deployment.yaml | 16 +++++-------- k8s/charts/seaweedfs/values.yaml | 11 +++++++++ 5 files changed, 36 insertions(+), 39 deletions(-) diff --git a/k8s/charts/seaweedfs/templates/all-in-one/all-in-one-deployment.yaml b/k8s/charts/seaweedfs/templates/all-in-one/all-in-one-deployment.yaml index ba1fcfdfc..9f4a92e75 100644 --- a/k8s/charts/seaweedfs/templates/all-in-one/all-in-one-deployment.yaml +++ b/k8s/charts/seaweedfs/templates/all-in-one/all-in-one-deployment.yaml @@ -37,20 +37,17 @@ spec: {{- with .Values.allInOne.podLabels }} {{- toYaml . | nindent 8 }} {{- end }} + {{- $podAnnotations := mergeOverwrite (deepCopy (.Values.podAnnotations | default dict)) (.Values.allInOne.podAnnotations | default dict) }} + {{- $existingS3ConfigSecret := or .Values.allInOne.s3.existingConfigSecret .Values.s3.existingConfigSecret .Values.filer.s3.existingConfigSecret }} + {{- if $existingS3ConfigSecret }} + {{- $configSecret := (lookup "v1" "Secret" .Release.Namespace $existingS3ConfigSecret) | default dict }} + {{- $_ := set $podAnnotations "checksum/s3config" ($configSecret | toYaml | sha256sum) }} + {{- else }} + {{- $_ := set $podAnnotations "checksum/s3config" (include (print .Template.BasePath "/s3/s3-secret.yaml") . | sha256sum) }} + {{- end }} + {{- $_ := set $podAnnotations "checksum/master-config" (include (print .Template.BasePath "/master/master-configmap.yaml") . | sha256sum) }} annotations: - {{- with .Values.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.allInOne.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- $existingS3ConfigSecret := or .Values.allInOne.s3.existingConfigSecret .Values.s3.existingConfigSecret .Values.filer.s3.existingConfigSecret }} - {{- if $existingS3ConfigSecret }} - {{- $configSecret := (lookup "v1" "Secret" .Release.Namespace $existingS3ConfigSecret) | default dict }} - checksum/s3config: {{ $configSecret | toYaml | sha256sum }} - {{- else }} - checksum/s3config: {{ include (print .Template.BasePath "/s3/s3-secret.yaml") . | sha256sum }} - {{- end }} + {{- toYaml $podAnnotations | nindent 8 }} spec: restartPolicy: {{ default .Values.global.seaweedfs.restartPolicy .Values.allInOne.restartPolicy }} {{- if .Values.allInOne.affinity }} diff --git a/k8s/charts/seaweedfs/templates/filer/filer-statefulset.yaml b/k8s/charts/seaweedfs/templates/filer/filer-statefulset.yaml index e505faf1c..5ded97469 100644 --- a/k8s/charts/seaweedfs/templates/filer/filer-statefulset.yaml +++ b/k8s/charts/seaweedfs/templates/filer/filer-statefulset.yaml @@ -43,19 +43,15 @@ spec: {{- with .Values.filer.podLabels }} {{- toYaml . | nindent 8 }} {{- end }} - annotations: - {{- with .Values.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.filer.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} + {{- $podAnnotations := mergeOverwrite (deepCopy (.Values.podAnnotations | default dict)) (.Values.filer.podAnnotations | default dict) }} {{- if .Values.filer.s3.existingConfigSecret }} - {{- $configSecret := (lookup "v1" "Secret" .Release.Namespace .Values.filer.s3.existingConfigSecret) | default dict }} - checksum/s3config: {{ $configSecret | toYaml | sha256sum }} + {{- $configSecret := (lookup "v1" "Secret" .Release.Namespace .Values.filer.s3.existingConfigSecret) | default dict }} + {{- $_ := set $podAnnotations "checksum/s3config" ($configSecret | toYaml | sha256sum) }} {{- else }} - checksum/s3config: {{ include (print .Template.BasePath "/s3/s3-secret.yaml") . | sha256sum }} + {{- $_ := set $podAnnotations "checksum/s3config" (include (print .Template.BasePath "/s3/s3-secret.yaml") . | sha256sum) }} {{- end }} + annotations: + {{- toYaml $podAnnotations | nindent 8 }} spec: restartPolicy: {{ default .Values.global.seaweedfs.restartPolicy .Values.filer.restartPolicy }} {{- if .Values.filer.affinity }} diff --git a/k8s/charts/seaweedfs/templates/master/master-statefulset.yaml b/k8s/charts/seaweedfs/templates/master/master-statefulset.yaml index 914f0dfd1..89e99d470 100644 --- a/k8s/charts/seaweedfs/templates/master/master-statefulset.yaml +++ b/k8s/charts/seaweedfs/templates/master/master-statefulset.yaml @@ -43,13 +43,10 @@ spec: {{- with .Values.master.podLabels }} {{- toYaml . | nindent 8 }} {{- end }} + {{- $podAnnotations := mergeOverwrite (deepCopy (.Values.podAnnotations | default dict)) (.Values.master.podAnnotations | default dict) }} + {{- $_ := set $podAnnotations "checksum/master-config" (include (print .Template.BasePath "/master/master-configmap.yaml") . | sha256sum) }} annotations: - {{ with .Values.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.master.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} + {{- toYaml $podAnnotations | nindent 8 }} spec: restartPolicy: {{ default .Values.global.seaweedfs.restartPolicy .Values.master.restartPolicy }} {{- if .Values.master.affinity }} diff --git a/k8s/charts/seaweedfs/templates/s3/s3-deployment.yaml b/k8s/charts/seaweedfs/templates/s3/s3-deployment.yaml index 756607cea..a8126830c 100644 --- a/k8s/charts/seaweedfs/templates/s3/s3-deployment.yaml +++ b/k8s/charts/seaweedfs/templates/s3/s3-deployment.yaml @@ -35,19 +35,15 @@ spec: {{- with .Values.s3.podLabels }} {{- toYaml . | nindent 8 }} {{- end }} - annotations: - {{ with .Values.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.s3.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} + {{- $podAnnotations := mergeOverwrite (deepCopy (.Values.podAnnotations | default dict)) (.Values.s3.podAnnotations | default dict) }} {{- if .Values.s3.existingConfigSecret }} - {{- $configSecret := (lookup "v1" "Secret" .Release.Namespace .Values.s3.existingConfigSecret) | default dict }} - checksum/s3config: {{ $configSecret | toYaml | sha256sum }} + {{- $configSecret := (lookup "v1" "Secret" .Release.Namespace .Values.s3.existingConfigSecret) | default dict }} + {{- $_ := set $podAnnotations "checksum/s3config" ($configSecret | toYaml | sha256sum) }} {{- else }} - checksum/s3config: {{ include (print .Template.BasePath "/s3/s3-secret.yaml") . | sha256sum }} + {{- $_ := set $podAnnotations "checksum/s3config" (include (print .Template.BasePath "/s3/s3-secret.yaml") . | sha256sum) }} {{- end }} + annotations: + {{- toYaml $podAnnotations | nindent 8 }} spec: restartPolicy: {{ default .Values.global.seaweedfs.restartPolicy .Values.s3.restartPolicy }} {{- if .Values.s3.affinity }} diff --git a/k8s/charts/seaweedfs/values.yaml b/k8s/charts/seaweedfs/values.yaml index 47db70440..40d77e897 100644 --- a/k8s/charts/seaweedfs/values.yaml +++ b/k8s/charts/seaweedfs/values.yaml @@ -190,6 +190,8 @@ master: podLabels: {} # Annotations to be added to the master pods + # The chart sets checksum/master-config on master pods; other checksum/* keys + # can be used for custom rollouts. podAnnotations: {} # Annotations to be added to the master resources @@ -773,6 +775,8 @@ filer: podLabels: {} # Annotations to be added to the filer pods + # The chart sets checksum/s3config on filer pods; other checksum/* keys can be + # used for custom rollouts. podAnnotations: {} # Annotations to be added to the filer resource @@ -1078,6 +1082,8 @@ s3: podLabels: {} # Annotations to be added to the s3 pods + # The chart sets checksum/s3config on s3 pods; other checksum/* keys can be + # used for custom rollouts. podAnnotations: {} # Annotations to be added to the s3 resources @@ -1788,6 +1794,8 @@ allInOne: initContainers: "" # Init containers sidecars: "" # Sidecar containers annotations: {} # Annotations for the deployment + # The chart sets checksum/master-config and checksum/s3config on all-in-one + # pods; other checksum/* keys can be used for custom rollouts. podAnnotations: {} # Annotations for the pods podLabels: {} # Labels for the pods @@ -1922,6 +1930,9 @@ certificates: # Labels to be added to all the created pods podLabels: {} # Annotations to be added to all the created pods +# The chart sets checksum/master-config and checksum/s3config on pods whose +# rendered ConfigMaps or Secrets should trigger rollouts. Other checksum/* keys +# can be used for custom rollout annotations. podAnnotations: {} networkPolicy: