From c2f672881e687d9b17ab1ad8cf5effa4dce6b4d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Matija=C5=A1evi=C4=87?= Date: Fri, 8 Jan 2021 06:28:11 +0100 Subject: [PATCH] Updating pods on configmap change (#73) Fixes #71 ### Motivation Pods are not restarting when config maps are changed after changing values.yaml file, so they need to be restarted manually in order to pick up new values from config map. ### Modifications As I mentioned `restartPodsOnConfigMapChange` flag for each component is added in values.yaml file whether to restart pods on configmap change or not, default is `false`. In statefulset templates for each component is added part which is adding annotation that contains hash of corresponding configmap if `restartPodsOnConfigMapChange` is `true`, which will cause pods to restart if corresponding configmap has been changed (https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments). ### Verifying this change - [ ] Make sure that the change passes the CI checks. --- .../templates/autorecovery-statefulset.yaml | 3 +++ .../templates/bookkeeper-statefulset.yaml | 3 +++ .../pulsar/templates/broker-statefulset.yaml | 3 +++ .../pulsar/templates/grafana-deployment.yaml | 3 +++ .../templates/prometheus-deployment.yaml | 3 +++ charts/pulsar/templates/proxy-statefulset.yaml | 3 +++ .../templates/pulsar-manager-deployment.yaml | 3 +++ .../pulsar/templates/toolset-statefulset.yaml | 3 +++ .../templates/zookeeper-statefulset.yaml | 3 +++ charts/pulsar/values.yaml | 18 ++++++++++++++++++ 10 files changed, 45 insertions(+) diff --git a/charts/pulsar/templates/autorecovery-statefulset.yaml b/charts/pulsar/templates/autorecovery-statefulset.yaml index b040b4d..0d942b0 100644 --- a/charts/pulsar/templates/autorecovery-statefulset.yaml +++ b/charts/pulsar/templates/autorecovery-statefulset.yaml @@ -45,6 +45,9 @@ spec: annotations: prometheus.io/scrape: "true" prometheus.io/port: "{{ .Values.autorecovery.ports.http }}" + {{- if .Values.autorecovery.restartPodsOnConfigMapChange }} + checksum/config: {{ include (print $.Template.BasePath "/autorecovery-configmap.yaml") . | sha256sum }} + {{- end }} {{- with .Values.autorecovery.annotations }} {{ toYaml . | indent 8 }} {{- end }} diff --git a/charts/pulsar/templates/bookkeeper-statefulset.yaml b/charts/pulsar/templates/bookkeeper-statefulset.yaml index 35829dd..de91af6 100644 --- a/charts/pulsar/templates/bookkeeper-statefulset.yaml +++ b/charts/pulsar/templates/bookkeeper-statefulset.yaml @@ -44,6 +44,9 @@ spec: annotations: prometheus.io/scrape: "true" prometheus.io/port: "{{ .Values.bookkeeper.ports.http }}" + {{- if .Values.bookkeeper.restartPodsOnConfigMapChange }} + checksum/config: {{ include (print $.Template.BasePath "/bookkeeper-configmap.yaml") . | sha256sum }} + {{- end }} {{- with .Values.bookkeeper.annotations }} {{ toYaml . | indent 8 }} {{- end }} diff --git a/charts/pulsar/templates/broker-statefulset.yaml b/charts/pulsar/templates/broker-statefulset.yaml index 96096de..08a93bd 100644 --- a/charts/pulsar/templates/broker-statefulset.yaml +++ b/charts/pulsar/templates/broker-statefulset.yaml @@ -44,6 +44,9 @@ spec: annotations: prometheus.io/scrape: "true" prometheus.io/port: "{{ .Values.broker.ports.http }}" + {{- if .Values.broker.restartPodsOnConfigMapChange }} + checksum/config: {{ include (print $.Template.BasePath "/broker-configmap.yaml") . | sha256sum }} + {{- end }} {{- with .Values.broker.annotations }} {{ toYaml . | indent 8 }} {{- end }} diff --git a/charts/pulsar/templates/grafana-deployment.yaml b/charts/pulsar/templates/grafana-deployment.yaml index 3f4ce94..85db243 100644 --- a/charts/pulsar/templates/grafana-deployment.yaml +++ b/charts/pulsar/templates/grafana-deployment.yaml @@ -38,6 +38,9 @@ spec: {{- include "pulsar.template.labels" . | nindent 8 }} component: {{ .Values.grafana.component }} annotations: + {{- if .Values.grafana.restartPodsOnConfigMapChange }} + checksum/config: {{ include (print $.Template.BasePath "/grafana-configmap.yaml") . | sha256sum }} + {{- end }} {{- with .Values.grafana.annotations }} {{ toYaml . | indent 8 }} {{- end }} diff --git a/charts/pulsar/templates/prometheus-deployment.yaml b/charts/pulsar/templates/prometheus-deployment.yaml index dfb10d6..cc5f2ee 100644 --- a/charts/pulsar/templates/prometheus-deployment.yaml +++ b/charts/pulsar/templates/prometheus-deployment.yaml @@ -38,6 +38,9 @@ spec: {{- include "pulsar.template.labels" . | nindent 8 }} component: {{ .Values.prometheus.component }} annotations: + {{- if .Values.prometheus.restartPodsOnConfigMapChange }} + checksum/config: {{ include (print $.Template.BasePath "/prometheus-configmap.yaml") . | sha256sum }} + {{- end }} {{ toYaml .Values.prometheus.annotations | indent 8 }} spec: {{- if .Values.prometheus.nodeSelector }} diff --git a/charts/pulsar/templates/proxy-statefulset.yaml b/charts/pulsar/templates/proxy-statefulset.yaml index e05e243..00e001d 100644 --- a/charts/pulsar/templates/proxy-statefulset.yaml +++ b/charts/pulsar/templates/proxy-statefulset.yaml @@ -44,6 +44,9 @@ spec: annotations: prometheus.io/scrape: "true" prometheus.io/port: "{{ .Values.proxy.ports.http }}" + {{- if .Values.proxy.restartPodsOnConfigMapChange }} + checksum/config: {{ include (print $.Template.BasePath "/proxy-configmap.yaml") . | sha256sum }} + {{- end }} {{- with .Values.proxy.annotations }} {{ toYaml . | indent 8 }} {{- end }} diff --git a/charts/pulsar/templates/pulsar-manager-deployment.yaml b/charts/pulsar/templates/pulsar-manager-deployment.yaml index 0aa2841..c795fd3 100644 --- a/charts/pulsar/templates/pulsar-manager-deployment.yaml +++ b/charts/pulsar/templates/pulsar-manager-deployment.yaml @@ -38,6 +38,9 @@ spec: {{- include "pulsar.template.labels" . | nindent 8 }} component: {{ .Values.pulsar_manager.component }} annotations: + {{- if .Values.pulsar_manager.restartPodsOnConfigMapChange }} + checksum/config: {{ include (print $.Template.BasePath "/pulsar-manager-configmap.yaml") . | sha256sum }} + {{- end }} {{ toYaml .Values.pulsar_manager.annotations | indent 8 }} spec: {{- if .Values.pulsar_manager.nodeSelector }} diff --git a/charts/pulsar/templates/toolset-statefulset.yaml b/charts/pulsar/templates/toolset-statefulset.yaml index a250239..dd2b401 100644 --- a/charts/pulsar/templates/toolset-statefulset.yaml +++ b/charts/pulsar/templates/toolset-statefulset.yaml @@ -42,6 +42,9 @@ spec: {{- include "pulsar.template.labels" . | nindent 8 }} component: {{ .Values.toolset.component }} annotations: + {{- if .Values.toolset.restartPodsOnConfigMapChange }} + checksum/config: {{ include (print $.Template.BasePath "/toolset-configmap.yaml") . | sha256sum }} + {{- end }} {{ toYaml .Values.toolset.annotations | indent 8 }} spec: {{- if .Values.toolset.nodeSelector }} diff --git a/charts/pulsar/templates/zookeeper-statefulset.yaml b/charts/pulsar/templates/zookeeper-statefulset.yaml index cb89469..40d05f4 100644 --- a/charts/pulsar/templates/zookeeper-statefulset.yaml +++ b/charts/pulsar/templates/zookeeper-statefulset.yaml @@ -43,6 +43,9 @@ spec: {{- include "pulsar.template.labels" . | nindent 8 }} component: {{ .Values.zookeeper.component }} annotations: + {{- if .Values.zookeeper.restartPodsOnConfigMapChange }} + checksum/config: {{ include (print $.Template.BasePath "/zookeeper-configmap.yaml") . | sha256sum }} + {{- end }} {{ toYaml .Values.zookeeper.annotations | indent 8 }} spec: {{- if .Values.zookeeper.nodeSelector }} diff --git a/charts/pulsar/values.yaml b/charts/pulsar/values.yaml index 8f58588..113ed9a 100644 --- a/charts/pulsar/values.yaml +++ b/charts/pulsar/values.yaml @@ -284,6 +284,8 @@ zookeeper: enabled: false interval: 10s scrapeTimeout: 10s + # True includes annotation for statefulset that contains hash of corresponding configmap, which will cause pods to restart on configmap change + restartPodsOnConfigMapChange: false ports: http: 8000 client: 2181 @@ -396,6 +398,8 @@ bookkeeper: enabled: false interval: 10s scrapeTimeout: 10s + # True includes annotation for statefulset that contains hash of corresponding configmap, which will cause pods to restart on configmap change + restartPodsOnConfigMapChange: false ports: http: 8000 bookie: 3181 @@ -518,6 +522,8 @@ autorecovery: # so the metrics are correctly rendered in grafana dashboard component: recovery replicaCount: 1 + # True includes annotation for statefulset that contains hash of corresponding configmap, which will cause pods to restart on configmap change + restartPodsOnConfigMapChange: false ports: http: 8000 # nodeSelector: @@ -579,6 +585,8 @@ broker: enabled: false interval: 10s scrapeTimeout: 10s + # True includes annotation for statefulset that contains hash of corresponding configmap, which will cause pods to restart on configmap change + restartPodsOnConfigMapChange: false ports: http: 8080 https: 8443 @@ -675,6 +683,8 @@ proxy: enabled: false interval: 10s scrapeTimeout: 10s + # True includes annotation for statefulset that contains hash of corresponding configmap, which will cause pods to restart on configmap change + restartPodsOnConfigMapChange: false # nodeSelector: # cloud.google.com/gke-nodepool: default-pool probe: @@ -809,6 +819,8 @@ toolset: component: toolset useProxy: true replicaCount: 1 + # True includes annotation for statefulset that contains hash of corresponding configmap, which will cause pods to restart on configmap change + restartPodsOnConfigMapChange: false # nodeSelector: # cloud.google.com/gke-nodepool: default-pool annotations: {} @@ -842,6 +854,8 @@ prometheus: rbac: enabled: true replicaCount: 1 + # True includes annotation for statefulset that contains hash of corresponding configmap, which will cause pods to restart on configmap change + restartPodsOnConfigMapChange: false # nodeSelector: # cloud.google.com/gke-nodepool: default-pool annotations: {} @@ -882,6 +896,8 @@ prometheus: grafana: component: grafana replicaCount: 1 + # True includes annotation for statefulset that contains hash of corresponding configmap, which will cause pods to restart on configmap change + restartPodsOnConfigMapChange: false # nodeSelector: # cloud.google.com/gke-nodepool: default-pool annotations: {} @@ -933,6 +949,8 @@ grafana: pulsar_manager: component: pulsar-manager replicaCount: 1 + # True includes annotation for statefulset that contains hash of corresponding configmap, which will cause pods to restart on configmap change + restartPodsOnConfigMapChange: false # nodeSelector: # cloud.google.com/gke-nodepool: default-pool annotations: {}