How do you add a checksum annotation so pods restart when a ConfigMap changes?
IntermediateConceptTemplating: Go Templates & Sprig
Answer
Changing a ConfigMap does not restart pods that consume it via envFrom or files mounted as env. Hash the rendered ConfigMap into the pod template so any change alters the template and triggers a rollout:
spec:
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/frontend-configmap.yaml") . | sha256sum }}
Use the same trick for Secrets the chart renders. Do not hash an externally managed Secret this way; it is not in the chart.
More on Templating: Go Templates & Sprig
What template language does Helm use?BeginnerWhat does the dot (`.`) mean in a Helm template?BeginnerWhat is `$` and when do you need it?IntermediateHow does whitespace control (`{{-` and `-}}`) work?BeginnerHow do `if`, `else if` and `else` evaluate truthiness?BeginnerWhat do `and`, `or`, `not`, `eq`, `ne`, `lt`, `gt` look like in Helm?Beginner