Containers and orchestration
Config, storage and labels in Kubernetes
Where pods get their settings, secrets, disks and identity, and how labels and namespaces organize everything. Includes the storage rules that decide where a pod can run.
A pod needs settings, sometimes secrets, often a disk, and an identity for calling the API. Kubernetes gives each need its own object: a ConfigMap for settings, a Secret for sensitive values, a volume for storage, and a ServiceAccount for identity. Labels tie it all together by grouping objects so you can query them.
ConfigMaps and Secrets
A ConfigMap holds non-secret settings as key-value pairs or files. You mount it as environment variables or as files.
Changing a ConfigMap has different effects depending on how it is used. A file mount updates after a delay. An environment variable does not change in a running pod. You need a rollout to pick it up.
A Secret has the same shape, but its values are only base64-encoded in etcd by default. Base64 is an encoding, not encryption. Turn on encryption at rest, or use an external secrets manager, for anything valuable. Never bake secrets into images.
Volumes and where pods can run
emptyDiris scratch space that lasts as long as the pod.configMap,secretandprojectedput config into the filesystem.- PersistentVolumeClaim (PVC) requests durable storage. A provisioner creates the disk and binds it to the claim.
Most block volumes are ReadWriteOnce (RWO). They attach to one node at a time. A pod that mounts one is tied to that node.
Here is what happens when that node dies:
- The node stops responding, and the pod on it is gone.
- The replacement pod is scheduled, but the old volume is still attached to the dead node.
- The volume must detach from that node and attach to the new one.
- Only then can the replacement pod start.
Plan for this delay. Shared storage across nodes needs a filesystem that allows multi-attach, such as EFS or Filestore.
ServiceAccounts
A ServiceAccount gives a pod an identity for talking to the Kubernetes API. The token is mounted automatically. If the app never calls the API, turn automount off. Scope RBAC to only the verbs the app needs.
Namespaces and labels
Namespaces split the cluster by team or environment, such as payments-prod and payments-staging. RBAC and quotas usually apply per namespace. Namespaces are not a hard security boundary against a hostile tenant with node access.
Labels are key=value tags on objects. Deployments, Services and NetworkPolicies find their targets through labels. A consistent convention makes it possible to ask "show me everything for checkout":
app.kubernetes.io/name: checkout
app.kubernetes.io/instance: checkout-prod
app.kubernetes.io/component: api
app.kubernetes.io/part-of: payments
app.kubernetes.io/managed-by: helmCommon mistakes
- Believing Secrets are encrypted by default. They are base64 unless you enable encryption.
- Expecting an env var change to apply without a rollout. It will not.
- Choosing RWO storage for shared data. Pods on other nodes cannot mount it.
- Inventing labels per team. Use one convention, or selectors will miss things.
Check yourself
- You change a ConfigMap that pods read as environment variables. What has to happen? The pods must be rolled out. Env vars only change in new pods.
- Why can't replicas on different nodes share one RWO volume? An RWO volume attaches to one node at a time, so the others cannot mount it.
Key takeaways
- ConfigMaps hold settings, Secrets hold sensitive values, and volumes hold data.
- Secrets are not encrypted unless you enable encryption or use an external store.
- RWO volumes pin a pod to a node and add reattach delay after a node failure.
- Labels are part of your API. Keep one convention.
Further learning
Next, when a pod keeps crashing, use the steps in debugging CrashLoopBackOff.
Related
Kubernetes in production
Requests and limits, probes, autoscaling, disruption budgets, packaging and the mistakes that cause outages.
Secrets management and encryption
Keeping credentials out of code and data safe at rest and in transit with KMS, Vault and envelope encryption — plus how to catch leaks before they become incidents.
IAM and least privilege
How cloud identity works, why least privilege is a habit rather than a checkbox, and where the org-level guardrails sit. Start here for the map of IAM pages.