Kubernetes · Orchestration under pressure
How do ConfigMaps work and how do updates propagate?
Short answer
A ConfigMap stores non-secret configuration as key-value data. It can be consumed as environment variables or mounted files, and update propagation differs between those two modes.
ConfigMaps decouple configuration from images. You can create them from literals, files or directories, then reference keys individually or mount the whole object as a volume. This lets the same image run in different environments with different settings.
- Environment variables are read at container start and do not update in place
- Mounted ConfigMap volumes are updated by kubelet, usually within a minute or so
- Applications must watch the files to pick up changes
- subPath mounts do not receive updates
- immutable: true prevents changes and reduces API server load
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
LOG_LEVEL: info
feature-flags.json: |
{"newCheckout": true}
---
apiVersion: v1
kind: Pod
metadata:
name: app
spec:
containers:
- name: app
image: registry.example.com/app:3.0.1
envFrom:
- configMapRef:
name: app-config
volumeMounts:
- name: config
mountPath: /etc/app
volumes:
- name: config
configMap:
name: app-configFor most stateless services, changing configuration means rolling the Deployment so pods restart with the new values. If you need live reload, mount files and implement a watcher. Never assume an environment variable changed because the ConfigMap changed.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1Why do environment variables not update when a ConfigMap changes?
- 2What is the risk of mounting with subPath?
- 3When should a ConfigMap be immutable?
- 4How do you roll out a configuration change safely?
Say it in the interview
A ConfigMap holds non-secret configuration that I can inject as environment variables or mount as files. Environment variables are fixed at container start, while mounted volumes eventually update, though subPath mounts do not. In practice I treat config changes like code changes and roll the Deployment. I also keep ConfigMaps immutable when they rarely change to reduce API load.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Kubernetes mock interview and get scored feedback on depth, clarity and confidence.