Does anyone know how to get a Kubernetes deployment to automatically update when a configMap is changed?
3 Answers
Unfortunately there is nothing built in for this. You used the helm
tag, so with Helm you do this by setting a checksum of the rendered configmap (or secret, same issue there) as an annotation in the pod template. This means that changing the configmap results in a (meaningless) change to the pod template, which triggers a rolling update.

- 52,400
- 4
- 52
- 75
-
This appears to be the only solution. I just need to figure out how to pass the checksum in. – Hammed Apr 28 '20 at 09:56
-
Docs got you covered, https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments :) – coderanger Apr 28 '20 at 11:23
-
I've tried this unfortunately. I get a "rendering template has a nested reference name: xyz.chart: unable to execute template" error. – Hammed Apr 28 '20 at 13:11
Consider reloader, a kubernetes controller, that watches changes to configmaps and secrets and will trigger a deployment when there is any change --> https://github.com/stakater/Reloader

- 15,499
- 7
- 34
- 59
As mentioned by @coderanger, by default Kubernetes doesn't provide anything like this by default.
Consider using kapp. kapp has the concept of (versioned) resources. You can mark the ConfigMap as a versioned resource. After that, anytime this configmap will be updated, all the K8s resources referring this ConfigMap will be updated as well.

- 31
- 1