How do you inject configuration into pods and what are the options?
BeginnerScenarioConfiguration, Secrets and storage
Answer
Situation read → A team asks how to pass settings to an app without baking them into the image.
What I'd do →
- Create a ConfigMap with
kubectl create configmap app-config --from-file=app.properties - Consume it as env vars with
envFromorvalueFrom.configMapKeyRef - Or mount it as files under
volumesandvolumeMounts - Remember env vars need a pod restart, while mounted files update eventually
- Keep secrets in Secret objects, not ConfigMaps
Why → ConfigMaps decouple config from images, so one image runs in every environment.
Interview tip → Mention that subPath mounts do not receive updates.
More on Configuration, Secrets and storage
A ConfigMap was updated but the pod still shows old values. Why?IntermediateHow do you store a database password safely in Kubernetes?BeginnerHow do you manage secrets in GitOps without committing them in plain text?IntermediateA pod fails with `CreateContainerConfigError` and a missing key. What happened?BeginnerWhat is the difference between emptyDir, hostPath, PV/PVC and when do you use each?BeginnerA StatefulSet's PVC stays Pending. How do you debug?Intermediate