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.
This commit is contained in:
Miloš Matijašević 2021-01-08 06:28:11 +01:00 committed by GitHub
parent 667e634af0
commit c2f672881e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 45 additions and 0 deletions

View File

@ -45,6 +45,9 @@ spec:
annotations: annotations:
prometheus.io/scrape: "true" prometheus.io/scrape: "true"
prometheus.io/port: "{{ .Values.autorecovery.ports.http }}" 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 }} {{- with .Values.autorecovery.annotations }}
{{ toYaml . | indent 8 }} {{ toYaml . | indent 8 }}
{{- end }} {{- end }}

View File

@ -44,6 +44,9 @@ spec:
annotations: annotations:
prometheus.io/scrape: "true" prometheus.io/scrape: "true"
prometheus.io/port: "{{ .Values.bookkeeper.ports.http }}" 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 }} {{- with .Values.bookkeeper.annotations }}
{{ toYaml . | indent 8 }} {{ toYaml . | indent 8 }}
{{- end }} {{- end }}

View File

@ -44,6 +44,9 @@ spec:
annotations: annotations:
prometheus.io/scrape: "true" prometheus.io/scrape: "true"
prometheus.io/port: "{{ .Values.broker.ports.http }}" 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 }} {{- with .Values.broker.annotations }}
{{ toYaml . | indent 8 }} {{ toYaml . | indent 8 }}
{{- end }} {{- end }}

View File

@ -38,6 +38,9 @@ spec:
{{- include "pulsar.template.labels" . | nindent 8 }} {{- include "pulsar.template.labels" . | nindent 8 }}
component: {{ .Values.grafana.component }} component: {{ .Values.grafana.component }}
annotations: annotations:
{{- if .Values.grafana.restartPodsOnConfigMapChange }}
checksum/config: {{ include (print $.Template.BasePath "/grafana-configmap.yaml") . | sha256sum }}
{{- end }}
{{- with .Values.grafana.annotations }} {{- with .Values.grafana.annotations }}
{{ toYaml . | indent 8 }} {{ toYaml . | indent 8 }}
{{- end }} {{- end }}

View File

@ -38,6 +38,9 @@ spec:
{{- include "pulsar.template.labels" . | nindent 8 }} {{- include "pulsar.template.labels" . | nindent 8 }}
component: {{ .Values.prometheus.component }} component: {{ .Values.prometheus.component }}
annotations: annotations:
{{- if .Values.prometheus.restartPodsOnConfigMapChange }}
checksum/config: {{ include (print $.Template.BasePath "/prometheus-configmap.yaml") . | sha256sum }}
{{- end }}
{{ toYaml .Values.prometheus.annotations | indent 8 }} {{ toYaml .Values.prometheus.annotations | indent 8 }}
spec: spec:
{{- if .Values.prometheus.nodeSelector }} {{- if .Values.prometheus.nodeSelector }}

View File

@ -44,6 +44,9 @@ spec:
annotations: annotations:
prometheus.io/scrape: "true" prometheus.io/scrape: "true"
prometheus.io/port: "{{ .Values.proxy.ports.http }}" 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 }} {{- with .Values.proxy.annotations }}
{{ toYaml . | indent 8 }} {{ toYaml . | indent 8 }}
{{- end }} {{- end }}

View File

@ -38,6 +38,9 @@ spec:
{{- include "pulsar.template.labels" . | nindent 8 }} {{- include "pulsar.template.labels" . | nindent 8 }}
component: {{ .Values.pulsar_manager.component }} component: {{ .Values.pulsar_manager.component }}
annotations: 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 }} {{ toYaml .Values.pulsar_manager.annotations | indent 8 }}
spec: spec:
{{- if .Values.pulsar_manager.nodeSelector }} {{- if .Values.pulsar_manager.nodeSelector }}

View File

@ -42,6 +42,9 @@ spec:
{{- include "pulsar.template.labels" . | nindent 8 }} {{- include "pulsar.template.labels" . | nindent 8 }}
component: {{ .Values.toolset.component }} component: {{ .Values.toolset.component }}
annotations: annotations:
{{- if .Values.toolset.restartPodsOnConfigMapChange }}
checksum/config: {{ include (print $.Template.BasePath "/toolset-configmap.yaml") . | sha256sum }}
{{- end }}
{{ toYaml .Values.toolset.annotations | indent 8 }} {{ toYaml .Values.toolset.annotations | indent 8 }}
spec: spec:
{{- if .Values.toolset.nodeSelector }} {{- if .Values.toolset.nodeSelector }}

View File

@ -43,6 +43,9 @@ spec:
{{- include "pulsar.template.labels" . | nindent 8 }} {{- include "pulsar.template.labels" . | nindent 8 }}
component: {{ .Values.zookeeper.component }} component: {{ .Values.zookeeper.component }}
annotations: annotations:
{{- if .Values.zookeeper.restartPodsOnConfigMapChange }}
checksum/config: {{ include (print $.Template.BasePath "/zookeeper-configmap.yaml") . | sha256sum }}
{{- end }}
{{ toYaml .Values.zookeeper.annotations | indent 8 }} {{ toYaml .Values.zookeeper.annotations | indent 8 }}
spec: spec:
{{- if .Values.zookeeper.nodeSelector }} {{- if .Values.zookeeper.nodeSelector }}

View File

@ -284,6 +284,8 @@ zookeeper:
enabled: false enabled: false
interval: 10s interval: 10s
scrapeTimeout: 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: ports:
http: 8000 http: 8000
client: 2181 client: 2181
@ -396,6 +398,8 @@ bookkeeper:
enabled: false enabled: false
interval: 10s interval: 10s
scrapeTimeout: 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: ports:
http: 8000 http: 8000
bookie: 3181 bookie: 3181
@ -518,6 +522,8 @@ autorecovery:
# so the metrics are correctly rendered in grafana dashboard # so the metrics are correctly rendered in grafana dashboard
component: recovery component: recovery
replicaCount: 1 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: ports:
http: 8000 http: 8000
# nodeSelector: # nodeSelector:
@ -579,6 +585,8 @@ broker:
enabled: false enabled: false
interval: 10s interval: 10s
scrapeTimeout: 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: ports:
http: 8080 http: 8080
https: 8443 https: 8443
@ -675,6 +683,8 @@ proxy:
enabled: false enabled: false
interval: 10s interval: 10s
scrapeTimeout: 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: # nodeSelector:
# cloud.google.com/gke-nodepool: default-pool # cloud.google.com/gke-nodepool: default-pool
probe: probe:
@ -809,6 +819,8 @@ toolset:
component: toolset component: toolset
useProxy: true useProxy: true
replicaCount: 1 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: # nodeSelector:
# cloud.google.com/gke-nodepool: default-pool # cloud.google.com/gke-nodepool: default-pool
annotations: {} annotations: {}
@ -842,6 +854,8 @@ prometheus:
rbac: rbac:
enabled: true enabled: true
replicaCount: 1 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: # nodeSelector:
# cloud.google.com/gke-nodepool: default-pool # cloud.google.com/gke-nodepool: default-pool
annotations: {} annotations: {}
@ -882,6 +896,8 @@ prometheus:
grafana: grafana:
component: grafana component: grafana
replicaCount: 1 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: # nodeSelector:
# cloud.google.com/gke-nodepool: default-pool # cloud.google.com/gke-nodepool: default-pool
annotations: {} annotations: {}
@ -933,6 +949,8 @@ grafana:
pulsar_manager: pulsar_manager:
component: pulsar-manager component: pulsar-manager
replicaCount: 1 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: # nodeSelector:
# cloud.google.com/gke-nodepool: default-pool # cloud.google.com/gke-nodepool: default-pool
annotations: {} annotations: {}