ConfigMap & Secret generators
Generate config with hashes.
Kustomize can generate ConfigMaps and Secrets from files, literals, or env files, rather than you hand-writing them. The generators read the source data and emit a ConfigMap/Secret resource — and, by default, append a content hash to its name. That hash is the clever part: when the data changes, the name changes, which forces every workload referencing it to roll, so a config change triggers a rolling update automatically instead of silently leaving old pods with stale config.
configMapGenerator:- name: app-configliterals:- LOG_LEVEL=infofiles:- app.propertiessecretGenerator:- name: db-credsenvs:- db.env # KEY=VALUE lines (keep this file out of Git if real!)
$ kustomize build .kind: ConfigMapmetadata:name: app-config-7h9k2t4b8m # <- content hash appended# references to "app-config" are rewritten to the hashed name automatically
The hash suffix and rollouts
Kustomize rewrites references to the generated object (a Deployment mounting app-config) to point at the hashed name, so everything stays consistent. Because a data change yields a new hashed name, the Deployment’s pod spec changes, and Kubernetes performs a rolling update — solving the classic “I changed the ConfigMap but the pods still have the old value” problem without any manual restart. You can disable the suffix with a generator option if you truly need a stable name.