Introduction

Kubernetes ConfigMaps and Secrets look simple until a configuration change refuses to land. At 09:12, an engineer updated a ConfigMap that pointed a checkout service at a new payment gateway endpoint. Argo CD reported the application as Synced and Healthy. The ConfigMap in the cluster showed the new URL. Traffic still went to the old gateway. The Deployment had not rolled because its pod template had not changed. Half the pods read the endpoint from an environment variable, which Kubernetes froze when each container started. The other half mounted the same ConfigMap with subPath, which pins a file snapshot at container start and never receives updates. Every dashboard that inspected the API object said the change was live. Every running process disagreed. The fix was not another edit to the ConfigMap. The fix was a rollout, followed by removing the subPath mount and adding a checksum annotation so the next configuration change would change the pod template. That incident exposes the real subject of this guide: Kubernetes ConfigMaps and Secrets are API objects, but running containers consume them through three different paths with three different update semantics. Teams that treat a successful kubectl apply as proof that pods changed will keep shipping configuration that exists only in etcd. The sections below separate object storage from container consumption, then give the production patterns that make changes land predictably: explicit env injection, file mounts that applications actually reload, versioned names, encryption at rest, external secret stores, and rotation runbooks that verify consumers before old credentials are revoked.


1. Kubernetes ConfigMaps and Secrets: ConfigMap vs Secret

Kubernetes ConfigMaps and Secrets separate configuration from credentials: ConfigMaps hold non-sensitive settings such as URLs and feature flags, while Secrets hold passwords, tokens, and TLS keys. Both are namespace-scoped API objects consumed by pods through environment variables or mounted files, but only Secrets receive special handling in tooling and access patterns.

A ConfigMap is a namespace-scoped API object for non-confidential configuration data. Typical values are service URLs, feature flags, log levels, timeout values, and whole configuration files for applications that expect a file on disk. A Secret is a namespace-scoped API object for confidential data such as passwords, API tokens, TLS certificates and keys, and registry credentials. The distinction is not cosmetic. ConfigMaps are routinely shown in dashboards, Git repositories, and support bundles. Secrets must be treated as credentials wherever they appear, including in API responses, backups, and CI logs.

Both objects store key-value pairs, and both can be consumed in the same two ways: injected as environment variables or mounted as files in a volume. That symmetry hides an operational difference. Kubernetes tooling masks Secret values in some outputs, restricts Secret volumes to tmpfs on Linux nodes, and gives Secrets typed forms such as kubernetes.io/tls and kubernetes.io/dockerconfigjson. None of that makes a Secret encrypted. It only means the platform knows the data is sensitive and applies handling conventions around it.

The practical rule is classification at authoring time. If a value would embarrass the team in a screenshot, it belongs in a Secret or an external secret store, never in a ConfigMap. Database hostnames and ports are configuration. Database usernames are borderline and usually travel with the password. Passwords, private keys, bearer tokens, and signing keys are Secrets. Splitting one logical credential across a ConfigMap and a Secret, such as host in one and password in the other, is common and acceptable, provided the Secret side receives the stricter handling.

AspectConfigMapSecret
Intended dataNon-sensitive configurationPasswords, tokens, TLS keys, registry credentials
EncodingPlain text values, binaryData for binaryBase64 in data, plain input via stringData
Size limit1 MiB per object1 MiB per object
ConsumptionEnv vars, envFrom, volume filesEnv vars, envFrom, volume files, imagePullSecrets
Storageetcd, plainetcd, Base64-encoded and unencrypted unless encryption at rest is configured
Git safetySafe to commitUnsafe in plain form; use SOPS, Sealed Secrets, or an external store

Misclassification causes the worst failures. A token placed in a ConfigMap tends to be copied into Helm values, Argo CD application diffs, and incident screenshots because everyone treats ConfigMaps as harmless. The reverse error, putting ordinary configuration in Secrets, creates needless RBAC friction and makes debugging harder because values are masked. Classify once, at the source, and keep the classification stable across environments.


2. Creating Kubernetes ConfigMaps and Secrets with kubectl and YAML

Creating Kubernetes ConfigMaps and Secrets should be declarative in Git, with kubectl used for inspection, one-off generation, and dry-run rendering. Use stringData for readable Secret manifests during authoring, --from-literal for small values, and --from-file for certificates or configuration files that must keep exact bytes.

Declarative YAML is the production default because configuration changes need review, history, and rollback. Imperative kubectl create commands are useful for generating a manifest, testing in a disposable namespace, or building a TLS Secret from files on disk. The safe workflow is to generate with kubectl create --dry-run=client -o yaml, review the output, and commit the manifest through the same GitOps path as the workload. The kubectl master guide covers the dry-run and JSONPath patterns used throughout this article.

kubectl create configmap app-config   --from-literal=DBHOST=mysql-service   --from-literal=DBPORT=3306   --from-file=app.conf=./app.conf   --dry-run=client -o yaml

kubectl create secret generic db-secret --from-literal=DBUSERNAME=admin --from-literal=DBPASSWORD='replace-me' --dry-run=client -o yaml

kubectl create secret tls web-tls --cert=./tls.crt --key=./tls.key --dry-run=client -o yaml

The equivalent manifests are explicit about names, keys, and types. stringData accepts plain text at write time and is converted to Base64 data by the API server; it is never returned on read. That makes stringData convenient for authoring and dangerous in Git, because the committed file still contains the plain credential.

apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
  namespace: production
data:
  DBHOST: mysql-service
  DBPORT: "3306"
  app.conf: |
    loglevel = info
    featurecheckoutv2 = true
---
apiVersion: v1
kind: Secret
metadata:
  name: db-secret
  namespace: production
type: Opaque
stringData:
  DBUSERNAME: admin
  DB_PASSWORD: replace-me

Three creation details matter in production. First, --from-file preserves exact bytes, which matters for certificates, keys, and configuration files with trailing newlines. Second, --from-env-file reads KEY=value lines and is convenient for local parity, but it silently imports whatever the file contains, so review the generated manifest. Third, Secret types carry validation: a kubernetes.io/tls Secret must contain tls.crt and tls.key, and a kubernetes.io/dockerconfigjson Secret must contain a valid .dockerconfigjson entry. Using the correct type lets ingress controllers, kubelet image pulls, and admission tooling recognize the credential without guessing.


3. Kubernetes ConfigMaps and Secrets as Environment Variables

Kubernetes ConfigMaps and Secrets can be injected as environment variables with valueFrom for single keys or envFrom for whole objects. Environment variables suit simple settings and URLs, but they freeze at container start, leak through process inspection more easily, and force a rollout for every value change.

Environment variable injection has two forms. valueFrom maps one key to one variable through configMapKeyRef or secretKeyRef, which keeps the pod spec explicit about exactly which values the container receives. envFrom imports every key from a ConfigMap or Secret through configMapRef or secretRef, optionally with a prefix. Explicit valueFrom is the safer default for credentials because the blast radius is visible in the pod spec. envFrom is convenient for application configuration bundles, but it imports keys the container may not need and makes accidental exposure easier.

apiVersion: v1
kind: Pod
metadata:
  name: web-app
  namespace: production
spec:
  containers:
    - name: web-app
      image: nginx:1.27
      env:
        - name: DBHOST
          valueFrom:
            configMapKeyRef:
              name: app-config
              key: DBHOST
        - name: DBPASSWORD
          valueFrom:
            secretKeyRef:
              name: db-secret
              key: DBPASSWORD
      envFrom:
        - configMapRef:
            name: app-config
          prefix: APP_

The defining property of environment variables is that they are set once, when the container starts. Kubelet resolves valueFrom and envFrom while building the container environment, and the running process keeps that snapshot for its lifetime. Updating the ConfigMap or Secret afterward changes the API object and nothing else. The process environment does not change, child processes inherit the old values, and the only reliable propagation mechanism is starting new containers through a rollout or a pod restart.

Environment variables also have a wider exposure surface than files. They are visible through /proc/<pid>/environ to processes with sufficient privilege on the node, they are inherited by every child process, and they tend to appear in crash dumps, debug endpoints, and careless startup logs. That exposure is acceptable for hostnames, ports, and feature flags. For passwords and tokens, mounted files with restrictive permissions are the better default, as the next section explains. When environment injection is unavoidable for a credential, prefer a single secretKeyRef over envFrom so the pod spec names the exact secret key being exposed.


4. Kubernetes ConfigMaps and Secrets as Mounted Files

Kubernetes ConfigMaps and Secrets mounted as files update more gracefully than environment variables and suit certificates, configuration files, and credentials that applications can reload. Use volume items to control file names, projected volumes to combine sources, and restrictive defaultMode values so mounted Secrets are readable only by the workload.

File mounts turn each key into a file inside the container filesystem. A ConfigMap volume writes one file per key, a Secret volume does the same on a tmpfs mount, and the items field selects specific keys and renames them to the paths the application expects. This is the natural consumption path for TLS certificates, configuration files, and credentials that an application reads from disk. It is also the only path that can receive updates without a container restart, subject to the update rules in the next section.

apiVersion: v1
kind: Pod
metadata:
  name: backend-app
  namespace: production
spec:
  containers:
    - name: backend-app
      image: nginx:1.27
      volumeMounts:
        - name: config-volume
          mountPath: /etc/config
          readOnly: true
        - name: tls-volume
          mountPath: /etc/tls
          readOnly: true
  volumes:
    - name: config-volume
      configMap:
        name: app-config
        items:
          - key: app.conf
            path: app.conf
    - name: tls-volume
      secret:
        secretName: web-tls
        defaultMode: 0o400

Projected volumes combine several sources into one directory: ConfigMaps, Secrets, downward API fields, and service account tokens. They are the standard way to place a configuration file, a TLS pair, and a token in one mount without juggling multiple volumes. Each source keeps its own update behavior, so a projected Secret still rotates through the symlink swap described below.

apiVersion: v1
kind: Pod
metadata:
  name: projected-app
  namespace: production
spec:
  containers:
    - name: projected-app
      image: nginx:1.27
      volumeMounts:
        - name: combined
          mountPath: /etc/combined
          readOnly: true
  volumes:
    - name: combined
      projected:
        defaultMode: 0o400
        sources:
          - configMap:
              name: app-config
              items:
                - key: app.conf
                  path: app.conf
          - secret:
              name: web-tls
              items:
                - key: tls.crt
                  path: tls.crt
                - key: tls.key
                  path: tls.key
          - downwardAPI:
              items:
                - path: namespace
                  fieldRef:
                    fieldPath: metadata.namespace

Permissions deserve deliberate settings. defaultMode controls file permissions for mounted keys, and Secret files should be readable only by the workload identity, commonly 0o400 with a matching runAsUser or fsGroup. A mounted Secret that every process in the container can read is only marginally better than an environment variable. Set readOnly: true on the mount, keep the mount path out of world-writable directories, and confirm the application user can actually read the files before blaming the Secret contents during an incident.


5. How Kubernetes ConfigMaps and Secrets Update in Running Pods

Kubernetes ConfigMaps and Secrets do not update running containers the way many teams expect: environment variables never change, mounted files swap atomically after kubelet sync, and subPath mounts never receive updates. A Deployment also stays unchanged unless its pod template changes, so checksum annotations, Reloader, or versioned names must force rollouts.

Update behavior depends entirely on the consumption path. Environment variables from valueFrom and envFrom never update in a running container. Kubelet builds the environment at container start, and no later API change reaches the process. The only propagation mechanism is a new container, which means a rollout, a pod deletion, or a node drain. Teams that edit a Secret and wait are waiting for an event Kubernetes never sends.

Mounted files behave differently. For ConfigMap and Secret volumes without subPath, kubelet writes updated files into a timestamped directory and atomically swaps the ..data symlink to point at the new directory. Applications reading through the symlink see the new content once kubelet syncs, which typically lands within roughly 60 to 90 seconds depending on the kubelet sync period and cache behavior. The swap is atomic, so readers never see a half-written file. Atomicity does not imply the application noticed. A process that read its configuration once at startup keeps the old values in memory until it re-reads the file, receives a reload signal, or restarts. File delivery and application reload are separate responsibilities, and both must work for a change to land.

The subPath mount is the trap that causes the opening incident. A subPath mount binds a single file or directory from the volume into the container at start time, and kubelet does not propagate later updates to that path. The file looks mounted, kubectl get configmap shows the new value, and the container keeps the old bytes indefinitely. Use subPath only when the application truly requires a file inside an existing directory and accepts restart-only updates. Otherwise mount the whole volume directory and let the symlink swap work. The workload-shape consequences of rollouts are covered in Deployment vs StatefulSet vs DaemonSet.

A Deployment adds one more layer: changing a ConfigMap does not change the Deployment pod template, so no rollout begins. The standard fixes make the change visible to the template. A checksum annotation stores a hash of the rendered configuration in the pod template annotations, so any value change produces a new ReplicaSet. Reloader watches ConfigMaps and Secrets and triggers rollouts when they change. Versioned names such as app-config-v42 make the reference itself change. All three patterns convert a silent object edit into an explicit, observable rollout.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-app
  namespace: production
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web-app
  template:
    metadata:
      labels:
        app: web-app
      annotations:
        checksum/config: "9f2c1ab4e7d04c6a8b1f3e5d7a9c0b2e4f6a8c1d3e5b7a9c0d2e4f6a8b1c3d5e7"
    spec:
      containers:
        - name: web-app
          image: nginx:1.27
          envFrom:
            - configMapRef:
                name: app-config

Verify propagation at the container, not at the API object. Read the file inside the pod, inspect the ..data symlink target, and check the process environment before declaring a change live. GitOps sync status proves the object matches Git. It proves nothing about running processes, which is why Argo CD vs Flux tooling still needs a rollout strategy beside it.


6. Kubernetes ConfigMaps and Secrets Limits, Immutable Objects, and Versioned Names

Kubernetes ConfigMaps and Secrets are limited to 1 MiB per object, so large files belong in object storage, images, or a configuration service instead. Immutable objects prevent accidental edits and reduce kubelet watch load, but rotation then requires a new versioned name and a controlled pod template update.

Both ConfigMaps and Secrets are capped at 1 MiB per object. The limit exists because the objects are stored in etcd and delivered to kubelets through the API watch path; oversized configuration objects slow propagation and bloat backups. A configuration file approaching that size is usually a sign that the data belongs elsewhere: baked into the image when it changes with the code, stored in object storage when it is large and versioned, or served by a configuration service when it changes independently at scale. Splitting one logical configuration across many ConfigMaps to dodge the limit creates ordering and consistency problems that are worse than the limit itself.

The immutable field freezes a ConfigMap or Secret against updates. An immutable object cannot be modified after creation; changing it requires deleting it, and pods referencing it keep using it until they are recreated. Immutability buys two production properties. It prevents accidental in-place edits from silently diverging running pods from reviewed Git state, and it lets kubelet stop watching the object for changes, which reduces API server and kubelet load in large clusters. The cost is that every change becomes a new object with a new name.

Versioned names pair naturally with immutability. A configuration release creates app-config-v42, updates the Deployment to reference it, and rolls pods onto the new object. Rollback is a reference change back to app-config-v41, which still exists and is still immutable. GitOps tools and Helm can generate hashed names automatically, and the hash doubles as the rollout trigger. This pattern is the most auditable way to propagate configuration: every running pod references an object whose contents cannot drift, and the pod template diff shows exactly which configuration version each rollout adopted.

Choose the propagation pattern by change frequency. Rare, reviewed changes suit versioned immutable objects. Frequent tuning values suit a mutable ConfigMap plus a checksum annotation. Credentials suit versioned Secrets or an external store with explicit rotation. The failure mode to avoid is the mutable object edited in place with no rollout trigger, because that combination produces the silent divergence from the opening incident.


7. Are Kubernetes Secrets Encrypted? Base64, etcd, and RBAC

Kubernetes Secrets are Base64-encoded, not encrypted, and etcd stores them unencrypted unless encryption at rest is configured. Treat get, list, and watch permissions on Secrets as credential access, keep namespaces isolated, prefer mounted files over environment variables, and enable KMS-backed encryption for production clusters.

Base64 is an encoding, not encryption. Anyone who can read a Secret object can decode its values with one command, and kubectl get secret -o yaml prints the encoded form that decodes trivially. The API server stores Secrets in etcd in that same encoded form unless encryption at rest is configured. An etcd snapshot, a backup file, or a compromised control-plane host therefore exposes every Secret in the cluster when encryption at rest is absent. This is the single most misunderstood property of Kubernetes Secrets, and it drives the rest of the security model.

Encryption at rest is configured on the API server with an EncryptionConfiguration that encrypts selected resources before they are written to etcd. Production clusters should use a KMS provider so the encryption keys live outside etcd, ideally KMS v2 with an external key management service. Local providers such as aescbc and secretbox are better than plaintext but keep key material on control-plane hosts. Enabling encryption only protects newly written objects; existing Secrets must be rewritten, typically by reading and updating them, before the protection covers them.

apiVersion: apiserver.config.k8s.io/v1
kind: EncryptionConfiguration
resources:
  - resources:
      - secrets
    providers:
      - kms:
          name: kms-provider
          endpoint: unix:///var/run/kms.sock
          timeout: 3s
          apiVersion: v2
      - identity: {}

RBAC is the second control. Permission to get a Secret reveals one credential. Permission to list or watch Secrets in a namespace reveals every credential in that namespace, continuously, including future rotations. Grant Secret access by namespace and by verb with the same care as direct credential access, and audit which service accounts hold it. Namespace isolation is the third control: a pod can reference only Secrets in its own namespace, so namespace boundaries are credential boundaries. Shared credentials copied into many namespaces multiply the exposure and the rotation work; prefer per-namespace credentials issued by an external store.

Consumption choice completes the model. Mounted Secret files on tmpfs with 0o400 permissions expose values only to the workload identity and only through the filesystem. Environment variables expose values to child processes, process inspection, and accidental logging. Neither choice protects against a compromised container running as the workload identity, which is why short-lived, scoped credentials from an external store beat long-lived static Secrets wherever the platform supports them.


8. External Stores for Kubernetes ConfigMaps and Secrets

External stores for Kubernetes ConfigMaps and Secrets move the source of truth outside Git or etcd: External Secrets Operator syncs native Secrets, Secrets Store CSI mounts provider values as files, SOPS encrypts files for Git, and Sealed Secrets encrypts values to one cluster controller.

Native Secrets are a delivery mechanism, not a vault. They have no built-in rotation, no dynamic credential generation, no per-read audit trail, and no encryption unless the cluster adds it. External stores fill those gaps, and each fills them differently. The choice depends on where the source of truth should live and whether values may rest in etcd at all.

External Secrets Operator watches ExternalSecret objects and syncs values from providers such as Vault, AWS Secrets Manager, or Google Secret Manager into native Kubernetes Secrets on a refresh interval. Workloads keep consuming ordinary Secrets, rotation happens in the provider, and the synced Secret updates in place. The trade-off is that synced values still rest in etcd, so encryption at rest remains necessary, and env-var consumers still need rollouts when values change.

Secrets Store CSI Driver mounts provider values directly as files through a CSI volume, without creating a Kubernetes Secret unless syncing is explicitly enabled. This keeps credentials out of etcd and suits file-based consumers such as TLS material and application config files. The trade-off is operational: the CSI driver and provider plugin run on every node, and applications must read files rather than environment variables.

SOPS and Sealed Secrets solve the Git problem instead of the storage problem. SOPS encrypts values in files committed to Git using age, PGP, or cloud KMS keys, and a decryptor in the delivery path renders plain manifests at apply time. Sealed Secrets encrypts a Secret to a controller public key so the sealed form is safe in Git, and only the in-cluster controller can decrypt it into a native Secret. Both keep the GitOps workflow intact while removing plain credentials from the repository. Neither removes the etcd copy after decryption.

Choose by threat model. If the concern is credentials in Git, SOPS or Sealed Secrets is sufficient. If the concern is credential sprawl and rotation, a provider-backed store with External Secrets Operator is stronger. If the concern is values resting in etcd, CSI mounting avoids the copy. Vault-backed dynamic secrets go furthest by issuing short-lived credentials per workload, at the cost of running and integrating Vault itself.


9. Rotating Kubernetes ConfigMaps and Secrets Safely

Rotating Kubernetes ConfigMaps and Secrets safely means overlapping old and new credentials, rolling or reloading every consumer, verifying traffic on the new value, and only then revoking the old credential. In-place edits without a rollout leave environment-variable consumers and subPath mounts running stale configuration indefinitely.

Rotation fails when it is treated as an edit instead of a migration. A safe rotation has four phases: issue the new credential while the old one still works, move every consumer onto the new credential, verify production traffic succeeds on the new credential, and revoke the old credential. Skipping the overlap phase converts rotation into an outage window. Skipping verification converts it into a silent partial migration where some pods use the new value and others keep the old one until they happen to restart.

The consumer move depends on the consumption path. Environment-variable consumers move only through a rollout. File consumers move when kubelet swaps the mounted files and the application re-reads them, which must be proven per application. subPath consumers move only through pod recreation. A rotation plan that does not name the path for each consumer is incomplete. Versioned Secret names make the move explicit: create db-secret-v2, update the pod template reference, roll the Deployment, and watch the rollout complete before touching the old credential.

kubectl create secret generic db-secret-v2   --from-literal=DBUSERNAME=admin   --from-literal=DBPASSWORD='new-password'   -n production

kubectl patch deployment web-app -n production --type=json -p='[{"op":"replace","path":"/spec/template/spec/containers/0/env/1/valueFrom/secretKeyRef/name","value":"db-secret-v2"}]'

kubectl rollout status deployment/web-app -n production kubectl exec deploy/web-app -n production -- printenv DB_PASSWORD | wc -c

Database credentials deserve the dual-user pattern: create a new database user or password, deploy consumers onto it, confirm connection pools are healthy, then drop the old user. TLS rotation follows the same shape through cert-manager or an external issuer: the new certificate lands in the Secret, ingress controllers and applications reload or roll, and only then does the old certificate expire. In both cases the revocation step is the point of no return, so it happens last, after dashboards and logs prove the new credential carries real traffic.

Finish rotation by deleting or expiring the old object and recording the change. Orphaned old Secrets are standing credentials that nobody monitors. A short rotation log entry naming the old and new object versions, the rollout evidence, and the revocation time turns the next incident review from archaeology into a lookup.


10. Troubleshooting Kubernetes ConfigMaps and Secrets

Troubleshooting Kubernetes ConfigMaps and Secrets starts by identifying the consumption path: environment variable, mounted file, or subPath mount. Then check object existence, pod events, the ..data symlink target, file permissions, and whether the application re-reads configuration after kubelet swaps the mounted files.

Most configuration incidents reduce to a mismatch between where the operator looked and where the container reads. The API object shows the new value, the pod shows the old behavior, and the gap is explained by the consumption path. Start every diagnosis by naming that path from the pod spec: valueFrom, envFrom, volume mount, or subPath mount. Each path has a different update rule, and applying the wrong rule wastes the first hour of the incident.

Then prove the container view. For environment variables, print the variable inside the container. For files, read the file and inspect the ..data symlink target and its timestamp. For missing objects, read pod events, because CreateContainerConfigError and failed mount events name the missing ConfigMap or Secret directly. The CrashLoopBackOff troubleshooting guide covers the restart-loop symptoms that appear when a container starts with configuration it cannot parse.

SymptomRoot CauseDiagnosis CommandResolution
ConfigMap edited, app keeps old valueEnv var frozen at container startkubectl exec <pod> -- printenv <KEY>Roll the Deployment or restart pods
Mounted file never updatessubPath mount pins a start-time snapshotkubectl get pod <pod> -o yaml and inspect subPathRemove subPath, mount the directory, roll pods
File updated, app behavior unchangedApp read config once and never reloadskubectl exec <pod> -- ls -l /etc/config/..dataAdd reload signal handling or roll pods
Pod stuck in CreateContainerConfigErrorReferenced ConfigMap or Secret missingkubectl describe pod <pod>Create the object in the pod namespace or fix the name
Secret file permission denieddefaultMode or fsGroup mismatchkubectl exec <pod> -- ls -l /etc/tlsSet defaultMode: 0o400 with matching runAsUser/fsGroup
Apply rejected as too largeObject exceeds 1 MiBkubectl get configmap <name> -o json and measure sizeMove large data to object storage or the image
TLS fails after rotationStale mount or mismatched cert/key pairkubectl exec <pod> -- openssl x509 -in /etc/tls/tls.crt -noout -datesReissue matched pair, roll consumers, verify dates
envFrom keys missing in containerInvalid env var names skippedkubectl get events -n <ns>Rename keys to valid env names or use explicit valueFrom

Two checks close most cases. First, confirm the object exists in the pod namespace with the exact name and key the pod spec references; cross-namespace references do not resolve. Second, confirm the running container, not the API object, holds the expected value. Diagnosis that stops at kubectl get configmap proves storage, not consumption, and storage was never the failing layer in the incidents that matter.


11. Production Checklist for Kubernetes ConfigMaps and Secrets

A production checklist for Kubernetes ConfigMaps and Secrets keeps configuration versioned, Secrets encrypted at rest, RBAC least-privilege, and rollouts explicit. Prefer files for credentials, checksum annotations or versioned names for change propagation, external stores for real secrets, and runbooks that prove consumers moved before old credentials are revoked.

The production model that emerges from the previous sections is a set of defaults, not a collection of tips. Classify values at authoring time: configuration in ConfigMaps, credentials in Secrets or an external store. Consume credentials as mounted files with restrictive permissions where the application supports it, and reserve environment variables for simple settings and explicit single-key references. Propagate changes through the pod template with checksum annotations, Reloader, or versioned immutable names, so every configuration change produces an observable rollout instead of silent divergence.

Protect the storage layer. Enable KMS-backed encryption at rest and rewrite existing Secrets so the protection covers them. Grant Secret get, list, and watch permissions as credential access, scoped per namespace and audited. Keep plain credentials out of Git with SOPS, Sealed Secrets, or a provider-backed store, and prefer short-lived issued credentials over static ones where the platform supports them. These controls align with the broader hardening patterns in Kubernetes best practices.

Operate changes like releases. Configuration edits go through review, rollouts are watched to completion, and verification reads the value inside running containers rather than trusting sync status. Rotations overlap credentials, move consumers explicitly, verify traffic, and revoke last. The control-plane mechanics behind these guarantees are covered in Kubernetes architecture and workload orchestration.

Teams that adopt these defaults stop debugging the gap between etcd and the process. Configuration changes become boring: a reviewed diff, a visible rollout, a verified value in the container, and a rollback path that is another reference change. Boring is the goal. Kubernetes ConfigMaps and Secrets are simple objects; production reliability comes from respecting the three consumption paths and never assuming an applied object is a running change.

Frequently Asked Questions

In Kubernetes ConfigMaps and Secrets, what is the difference between a ConfigMap and a Secret?

A ConfigMap stores non-sensitive configuration such as URLs, ports, and feature flags. A Secret stores confidential data such as passwords, tokens, and TLS keys. Both are namespace-scoped and consumed as environment variables or files, but Secrets receive credential handling: masked tooling output, tmpfs volume mounts, typed forms, and stricter RBAC expectations.

In Kubernetes ConfigMaps and Secrets, are Secrets encrypted?

No. Secret values are Base64-encoded, which is reversible encoding, not encryption. etcd stores Secrets unencrypted unless the API server is configured with encryption at rest, ideally a KMS provider. Anyone with permission to read a Secret object can decode its values, so RBAC and encryption at rest are both required.

Do Kubernetes ConfigMaps and Secrets updates restart pods automatically?

No. Editing a ConfigMap or Secret does not change a Deployment pod template, so no rollout starts. Environment variables stay frozen, mounted files swap after kubelet sync, and subPath mounts never update. Use a checksum annotation, Reloader, versioned object names, or an explicit rollout restart to propagate changes.

In Kubernetes ConfigMaps and Secrets, should secrets be environment variables or mounted files?

Mounted files are the safer default for credentials. Files can be restricted with defaultMode permissions, rotate through the atomic symlink swap, and avoid exposure through child processes and process inspection. Environment variables suit simple settings, but they freeze at container start and appear in process environments, crash dumps, and accidental logs.

How do I rotate a Kubernetes Secret safely with Kubernetes ConfigMaps and Secrets?

Issue the new credential while the old one still works, move consumers through a rollout or verified file reload, confirm production traffic succeeds on the new value, then revoke the old credential. Versioned Secret names make the move explicit. Revocation always happens last, after verification, never immediately after editing the object.

What happens when a ConfigMap exceeds 1 MiB?

The API server rejects the object because ConfigMaps and Secrets are limited to 1 MiB each. Move large data to object storage, bake stable files into the image, or serve changing data from a configuration service. Splitting one configuration across many objects to dodge the limit creates consistency problems.

How do I restart pods when a ConfigMap changes in Kubernetes ConfigMaps and Secrets?

Add a checksum annotation of the rendered configuration to the pod template so changes trigger a rollout, use Reloader to watch objects and roll workloads, reference versioned ConfigMap names, or run kubectl rollout restart manually. Verify the new value inside running containers after the rollout completes.

External Secrets Operator vs native Kubernetes Secrets: which should I use?

Native Secrets are the delivery format workloads consume. External Secrets Operator adds a managed source of truth by syncing values from Vault or cloud secret managers into native Secrets with refresh and rotation support. Use the operator when credentials rotate or live in a provider; keep native Secrets for simple, low-risk values.

⚡ KUBERNETES SCENARIO INTERVIEW PREP

Preparing for Senior Platform & SRE Interviews

Practice real-world cluster triage, RBAC debugging, and pod scheduling scenarios in our Kubernetes scenario interview questions hub.

Explore Interview Scenarios →