Kubernetes: scaling and running it well · mid
ConfigMaps, secrets and Helm per environment
Environment variables from a ConfigMap never change in a running pod. Treat a configuration change as a deploy. Helm packages manifests with values per environment.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Environment variables from a ConfigMap are set when the container starts and never change.
- Mounted ConfigMap files are updated by the kubelet after a delay, often up to a minute or more, and never when mounted with subPath. The app must notice the change and re-read the file.
- Right way: treat a config change like a deploy. kubectl rollout restart deployment/<name> replaces pods gradually with the usual safety. Deleting pods by hand can take too many down at once.
- Helm: add a checksum of the ConfigMap as a pod template annotation (checksum/config), so any change to the config changes the template and triggers a rollout. Kustomize configMapGenerator adds a hash to the name for the same effect.
- Helm chart: templates plus default values.yaml, Chart.yaml (chart version and app version) and dependencies. A release is one installed copy, with revisions stored in the cluster.
- values.yaml holds defaults. values-staging.yaml and values-prod.yaml override only the differences (replicas, resources, hostnames). The pipeline sets the image tag (--set image.tag=<sha>).
- Secrets are not in values files in plain text. Use External Secrets Operator from a secrets manager, Sealed Secrets, or SOPS-encrypted values. A Kubernetes Secret is base64, not encryption.
- Preview before applying: helm template, helm diff (plugin) or a server-side dry run. helm lint and a values.schema.json catch mistakes early. helm rollback returns to an earlier revision.
The red pen
Common traps: mistake → fix
Mistake: Editing the ConfigMap updates running pods
Fix: Environment variables never change, and files change slowly and not with subPath.
Mistake: Kubernetes Secrets are encrypted
Fix: They are base64-encoded. Protect them with access control, encryption at rest and an external store.
Mistake: Helm rollback restores everything
Fix: It restores manifests. It does not undo database migrations or external changes.
Easy to hard
Questions interviewers ask, easy to hard
- Why did the pods not pick up the ConfigMap change?
- How do you trigger a rollout when only a ConfigMap changed?
- What is the difference between a Helm chart, a release and a revision?
- How do you handle different values for staging and production?
- Where do secrets live in a Helm-based deployment?
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.