Use it to externalise configuration, or when a pod does not pick up a change.
ConfigMaps
ConfigMaps store non-secret configuration as key/value data, consumed as environment variables or mounted files.
1. kubectl get cm <c> -o yaml.
2. Referenced correctly in the pod?
3. Inside the pod: env/file value.
4. Restart: kubectl rollout restart.
5. Avoid subPath if live updates needed.
ConfigMap → referenced by pod → env/file in container
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 How to verify Verify boundary
Compare the ConfigMap content with what the container sees. After a change, restart Pods that use environment variables. Use a hash annotation in the Pod template to trigger rollouts automatically.
Step 2 Common failures Narrow the fault
Putting passwords in a ConfigMap exposes them to anyone who can read ConfigMaps. A missing key referenced by envFrom without optional: true stops the container from starting. subPath mounts keep the old content forever.
Env vars are fixed at container start — restart to apply. Mounted files update after a delay (not with subPath). Use versioned names or checksum annotations to trigger rollouts.
kubectl get cm <c> -o yaml— first check for this topickubectl get pods -o wide— pods, status, node, IPkubectl describe pod <pod>— events and conditionskubectl logs <pod> [-c <c>] [--previous]— container logs (incl. previous crash)kubectl get events --sort-by=.lastTimestamp— recent cluster events
ReferenceWhat it is1 section · depth on demand
How it works
The kubelet projects ConfigMap data into the Pod as files or reads it when building the container environment. File projections are refreshed periodically through a symlink swap, so applications must re-read files to notice changes.
ReferenceImportant terms & boundaries3 sections · depth on demand
Using ConfigMaps
kubectl create configmap app-config --from-file=app.yaml --from-literal=LOG_LEVEL=info
kubectl get cm app-config -o yaml
Consume as env vars (envFrom) or mounted files. Mounted files update automatically (after a delay); env vars need a Pod restart (kubectl rollout restart). Limit 1 MiB per ConfigMap. Use immutable: true for large static configs to reduce API load.
In depth
How a change reaches the application
| Consumption | Updated in a running Pod? | Pickup |
|---|---|---|
Environment variables (env, envFrom) | No | Restart Pods (kubectl rollout restart) |
| Volume mount (whole ConfigMap) | Yes, after kubelet sync (typically under a minute or two) | App must re-read the file or watch it |
Volume mount with subPath | No | Restart Pods |
immutable: true | Cannot change | Create a new ConfigMap name and roll out |
Files from a volume are swapped atomically through a ..data symlink, so an app watching the file should watch the directory or re-open the path, not keep the old file descriptor.
Rolling out on config change
Put a hash of the configuration in the Pod template so a changed ConfigMap triggers a normal rolling update:
template:
metadata:
annotations:
checksum/config: "{{ sha256 of app.yaml }}" # set by Helm, Kustomize or CI
Kustomize's configMapGenerator does the same by appending a content hash to the ConfigMap name.
Worked check — what does the container really see?
kubectl get cm app-config -o jsonpath='{.data.app\.yaml}' | head
kubectl exec deploy/web -- cat /etc/app/app.yaml | head
kubectl exec deploy/web -- printenv LOG_LEVEL
A ConfigMap is limited to 1 MiB and is not encrypted; credentials belong in a Secret.
Common mistakes
- Expecting pods to reload ConfigMaps automatically.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.