Skip to content

Force containers to update when config map changes in helm

Why

When we create a config map in Kubernetes, it syncs with the container the first time it creates, and then never again.

Sometimes in our applications we will update an env on the fly, or use a range block to create infinite ones.

How

Adding the below in to the deployment.yaml file will cause helm to basically cat configmap.yaml | sha256sum on the rendered template.

This is for when the helm chart has all the template files in the same direcrory

  template:
    metadata:
      annotations:
        checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}

This is for when you have a folder splitting out say, backend and frontend

  template:
    metadata:
      annotations:
        checksum/config: {{ include (print $.Template.BasePath "/backend/configmap.yaml") . | sha256sum }}

Want to make this site better? Open a PR or help fund hosting costs