1. What Kubernetes CreateContainerConfigError means

Kubernetes CreateContainerConfigError means kubelet cannot assemble the container configuration before asking the runtime to create the container. The Pod is scheduled, the image may already be present, and the process has not started, so restart count stays at zero. Treat it as a configuration resolution failure, not an application crash.

Illustrative composite: a checkout API rollout adds a new DATABASEURL value from a Secret named checkout-secrets. The Deployment creates Pods, the image pulls cleanly, and every new Pod sits at 0/1 CreateContainerConfigError. The on-call engineer checks registry logs first because the status contains the word Create. kubectl describe pod would have ended the detour: the Failed event says the Secret exists, but the key is database-url, not DATABASEURL. One case mismatch blocked the rollout while old replicas kept serving traffic.

The important boundary is timing. Kubelet must resolve environment variables, envFrom sources, selected keys, command arguments that use dependent environment expansion, and some security settings before it can hand a complete container config to containerd or CRI-O. If a required reference cannot be resolved, kubelet records a waiting reason and retries on later sync loops. The Kubernetes Pod lifecycle guide is useful here because this status belongs to the waiting phase, before running, terminated, or restart backoff behaviour exists.

Do not start with kubectl logs. There is no container process and usually no log stream to read. Start with the Pod event, then compare the exact reference in the spec with the objects and keys that exist in the Pod namespace. That order prevents the two common wastes of time: rebuilding an image that already pulled, and changing application code that never executed.


2. Read the Kubernetes CreateContainerConfigError event before changing anything

The fastest CreateContainerConfigError fix starts with kubectl describe pod, because the Failed event normally names the missing ConfigMap, Secret, or key. Read the event text literally before editing YAML. Object-missing errors and key-missing errors look similar in kubectl get pods, but they require different fixes and different owners.

Run the narrow checks first:

bash
kubectl get pods -n payments
kubectl describe pod payments-api-7d9f4c8b6-xk2mn -n payments
kubectl get pod payments-api-7d9f4c8b6-xk2mn -n payments -o jsonpath='{.status.containerStatuses[0].state.waiting.reason}{"\n"}'

Look for event shapes such as secret "payments-secrets" not found, configmap "payments-config" not found, or couldn't find key DATABASE_URL in Secret payments/payments-secrets. The first two mean the named object is absent from the Pod namespace. The third means the object exists, but the selected key does not. That split decides whether you create an object, repair a key, fix a namespace, or roll back a template change.

Capture the Pod spec references at the same time. A Deployment can be correct in Git and still render the wrong name through Helm values, Kustomize overlays, or an ExternalSecret target name. The kubectl master guide patterns for jsonpath, describe, and events are enough for this stage. Keep the evidence small: Pod name, namespace, waiting reason, Failed event, referenced object name, referenced key, and the object inventory in that namespace.

When several Pods fail together, group them by owner and event text before changing shared configuration. A Deployment rollout usually produces many Pods with the same missing reference. A namespace bootstrap problem produces failures across different workloads. A single Pod with a unique event may point to a sidecar, init container, or one-off job template. Grouping prevents a broad Secret edit when only one template drifted, and it prevents ten Pod deletions when the shared object is absent. Kubernetes CreateContainerConfigError is a per-container waiting reason, but the cause is often a shared release dependency.


3. Missing ConfigMap or Secret object in the Pod namespace

A missing ConfigMap or Secret object causes CreateContainerConfigError when a required reference names something that does not exist in the Pod namespace. Kubernetes resolves these references locally to the Pod namespace. An object with the right name in default, staging, or a platform namespace is still not found for a Pod running elsewhere.

Confirm the object inventory in the Pod namespace, not in the namespace your shell context happens to prefer:

bash
kubectl get configmap -n payments
kubectl get secret -n payments
kubectl get configmap payments-config -n payments
kubectl get secret payments-secrets -n payments

If the object is absent, decide whether the workload or the configuration is wrong. Create the object when the reference is intentional and the values are ready. Fix the reference when the name is a typo, an old environment suffix survived a promotion, or the chart rendered a release-specific name that the secret sync job did not create. Do not copy a production Secret into a namespace just to clear the status unless ownership, rotation, and access rules are already defined.

The Kubernetes ConfigMaps and Secrets guide covers the consumption patterns behind this failure. For incident work, the operational rule is simpler: required configuration must exist before Pods that depend on it are created, unless the reference is explicitly optional. If a rollout created Pods before the configuration object, the fix is ordering and source-of-truth repair, not Pod deletion. Kubelet retries, so the Pod can recover when the object appears, but a healthy delivery path should not depend on that retry.

Watch for partial rollouts. Old Pods may keep running with the previous template while new Pods wait for a missing object. That can make the service look healthy while capacity is quietly reduced. If the Deployment has a maxUnavailable budget, the rollout may pause and protect traffic. If the workload is a Job or a single-replica service, the same missing object becomes immediate downtime. The severity comes from replica topology, not from the status string alone. Record whether old replicas are still serving, whether endpoints dropped, and whether the missing object blocks only new Pods or every restart.


4. Missing key in configMapKeyRef or secretKeyRef

A missing key causes CreateContainerConfigError when the ConfigMap or Secret exists but configMapKeyRef or secretKeyRef asks for a key that is not present. Keys are matched exactly, including case, hyphens, underscores, and spelling. The event usually says couldn't find key, which is your signal to stop checking object existence and start comparing key names.

List keys without printing secret values:

bash
kubectl get configmap payments-config -n payments -o json | jq '.data | keys'
kubectl get secret payments-secrets -n payments -o json | jq '.data | keys'
kubectl get pod payments-api-7d9f4c8b6-xk2mn -n payments -o json | jq '.spec.containers[].env[] | select(.valueFrom)'

A broken reference often looks reasonable during review:

yaml
env:
  - name: DATABASE_URL
    valueFrom:
      secretKeyRef:
        name: payments-secrets
        key: DATABASE_URL

If the Secret stores database-url, kubelet cannot substitute the value. Fix the key name in the workload template or add the expected key through the approved secret path. Prefer fixing Git, Helm values, or the ExternalSecret mapping over a live kubectl edit, because the next sync will overwrite a manual repair. After the fix, watch the same Pod or the replacement Pod until the waiting reason clears and the container reaches Running.


5. envFrom failures and optional references

envFrom causes CreateContainerConfigError when a required ConfigMap or Secret source is missing, because kubelet must import the whole object into the container environment. The event names the object rather than one key. Marking a reference optional changes the failure mode, so use optional only when the application can start safely without those values.

A required source looks like this:

yaml
envFrom:
  - configMapRef:
      name: payments-config
  - secretRef:
      name: payments-secrets

If either object is absent and the reference is not optional, container configuration fails. An optional reference is explicit:

yaml
envFrom:
  - configMapRef:
      name: payments-feature-flags
      optional: true

Optional is not a repair for required database credentials, TLS material, or feature flags that change safety behaviour. It is a contract decision: the process must have a safe default, the missing values must be visible in metrics or logs after start, and the team must accept that configuration absence becomes a runtime behaviour change. For required configuration, keep the reference required and fix creation order. That keeps failures loud at deploy time instead of turning them into silent application misconfiguration after the Pod starts.

Also check envFrom prefix and key validity when the object exists. envFrom imports keys as environment variable names. Keys that are not valid environment variable names can be skipped or transformed by prefix rules, which creates a different class of confusion: the Pod starts, but the application does not see the value under the expected name. That is not the same event as a missing object, yet it often appears in the same review. Keep env keys uppercase, simple, and stable across environments. If a ConfigMap is shared between file mounts and env imports, separate the naming contract so file names do not silently become poor environment names.


6. Namespace mismatch and name drift

Namespace mismatch is a common CreateContainerConfigError cause because ConfigMaps and Secrets are namespaced, while manifests often travel across environments with names that look portable. A Pod in payments cannot consume a Secret that exists only in default. The event still says not found, even though a human can see the object in another namespace.

Check both sides of the reference:

bash
kubectl get pod payments-api-7d9f4c8b6-xk2mn -n payments -o jsonpath='{.metadata.namespace}{"\n"}'
kubectl get configmap,secret -A | grep payments
kubectl get deploy payments-api -n payments -o yaml | grep -n "configMapRef\|secretRef\|configMapKeyRef\|secretKeyRef" -A3 -B2

Name drift usually enters through environment promotion. A chart value changes from payments-config to payments-prod-config, but the secret sync still writes payments-config. A Kustomize overlay adds a suffix to the Deployment and ConfigMap, but a hard-coded Secret name in a sidecar remains unchanged. A namespace is copied, but the ExternalSecret is not included in the new namespace bundle.

Fix the rendered manifest, not only the live object. Render the chart or overlay for the target namespace and compare every name field under envFrom, valueFrom, and volumes with the objects that the namespace bootstrap creates. If the object must exist in multiple namespaces, automate that replication through the platform path. Manual copies drift, and drift returns as the same waiting reason during the next rollout.


7. Volume config errors that look like CreateContainerConfigError

Volume configuration can confuse CreateContainerConfigError triage because missing ConfigMap or Secret volumes often produce FailedMount and ContainerCreating, not this waiting reason. Keep the boundary clear. Environment references fail during container configuration generation. Volume setup failures usually block mount preparation and should be read through mount events.

Check the event reason before assuming the fix is an env change:

bash
kubectl describe pod payments-api-7d9f4c8b6-xk2mn -n payments | grep -A4 -B2 "Failed\|FailedMount\|CreateContainerConfigError"
kubectl get pod payments-api-7d9f4c8b6-xk2mn -n payments -o json | jq '.spec.volumes'

There are edge cases. A subPath mount that depends on a file created from configuration, projected volume items with missing keys, or init container configuration can blur the first symptom. The event still tells you which subsystem failed. If the message says MountVolume.SetUp failed, repair the volume source, item key, or mount path. If the message says a Secret or ConfigMap key could not be found during container config generation, repair the env reference.

For projected volumes, inspect items, path, and optional fields. A missing projected key can fail volume setup unless the source or item is optional. For subPath, confirm the referenced path exists after the volume is populated and that the workload is not depending on live updates that subPath mounts do not receive. The goal is not to force every config problem into one status name. The goal is to follow the event to the subsystem that actually refused to proceed.

Init containers deserve the same discipline. A main container may be healthy in the template, while an init container references a missing ConfigMap for a migration script or waits for a Secret that the main container does not use. kubectl get pods still shows the Pod waiting, and the container status list tells you which container is blocked. Check init container statuses separately before editing the application container. Many production templates hide configuration dependencies in init containers for schema checks, certificate rendering, or dependency waits. Kubernetes CreateContainerConfigError can therefore block a Pod even when the long-running container spec looks clean.


8. ServiceAccount, imagePullSecrets and RBAC confusion

ServiceAccount and RBAC problems can sit near CreateContainerConfigError, but they are not the same failure as a missing env reference. A missing ServiceAccount usually blocks Pod creation or scheduling flow earlier. Image pull secret failures surface as image pull errors. RBAC denial for a human using kubectl does not stop kubelet from resolving a Pod reference that already exists.

Separate the identities involved. The user or GitOps controller creates objects through the API server. Kubelet reads the Pod spec and referenced configuration from the API server cache path for that node. The application ServiceAccount matters after the container starts, when the process calls Kubernetes or cloud APIs. If the event names a missing Secret key, changing application RBAC will not create that key.

Check the specific objects instead of widening permissions:

bash
kubectl get pod payments-api-7d9f4c8b6-xk2mn -n payments -o jsonpath='{.spec.serviceAccountName}{"\n"}'
kubectl get serviceaccount payments-api -n payments
kubectl get pod payments-api-7d9f4c8b6-xk2mn -n payments -o json | jq '.spec.imagePullSecrets'
kubectl auth can-i get secret/payments-secrets -n payments

Use kubectl auth can-i to test your own access when you cannot inspect the object. Do not grant broad Secret read access to solve a missing key. If the Pod references an image pull Secret that does not exist, expect image pull symptoms and fix the pull secret path. If the Pod references a config Secret that does not exist, fix the config object. Keeping those paths separate avoids a security change that leaves the rollout blocked.

Projected ServiceAccount tokens add another lookalike. A Pod may start with a token volume, then fail later when the application calls the Kubernetes API or a cloud metadata endpoint. That later failure is not CreateContainerConfigError unless kubelet cannot build the initial container configuration. If the container is Running and the application receives 401 or 403 responses, debug identity, audience, namespace, and cloud role binding. If the container never starts and the event names a Secret key, debug configuration resolution. The phase boundary keeps identity work from masking a simple missing reference.


9. runAsNonRoot and securityContext config failures

CreateContainerConfigError can also occur when kubelet rejects the effective container user during configuration generation. The classic case is runAsNonRoot: true with an image whose user is root, empty, or a non-numeric name that kubelet cannot prove is non-root. The event mentions the user or root, not a missing ConfigMap or Secret.

Read the event wording before hunting for configuration objects:

bash
kubectl describe pod payments-api-7d9f4c8b6-xk2mn -n payments | grep -A3 -B2 "runAsNonRoot\|root\|user"
kubectl get pod payments-api-7d9f4c8b6-xk2mn -n payments -o json | jq '.spec.securityContext, .spec.containers[].securityContext'

The durable fix is to set a numeric non-root runAsUser that the image and filesystem permissions support, or rebuild the image with a numeric non-root user. Do not remove runAsNonRoot just to clear the status unless the workload has an approved exception. The Kubernetes SecurityContext guide covers the wider policy context, including Pod Security Standards and filesystem ownership.

This branch matters because the status name misleads teams toward Secrets. If the Failed event says the container has runAsNonRoot and the image will run as root, the missing piece is identity proof, not configuration data. Fix the image user or the Pod security context, then verify the process can still read mounted files and write only to intended paths.


10. External Secrets and GitOps ordering failures

External Secrets and GitOps ordering failures cause CreateContainerConfigError when the workload syncs before the Kubernetes Secret or ConfigMap exists in the target namespace. The Pod reference may be correct. The delivery graph is wrong: the application arrived before the configuration object it requires at container start.

Check the sync chain in order: source secret exists, ExternalSecret or SealedSecret reconciled, target Secret created in the Pod namespace, target keys match the Pod spec, then workload rollout begins. The External Secrets Operator guide is the deeper reference for Vault and AWS Secrets Manager patterns. During an incident, keep the checks concrete:

bash
kubectl get externalsecret -n payments
kubectl describe externalsecret payments-secrets -n payments
kubectl get secret payments-secrets -n payments -o json | jq '.data | keys'
kubectl get deploy payments-api -n payments -o jsonpath='{.spec.template.spec.containers[0].env}'

Fix ordering with sync waves, dependencies, namespace bootstrap bundles, or a pre-rollout validation job that fails before Pods are created. Avoid marking required references optional to hide ordering defects. Optional references let Pods start with missing credentials and move the failure into application errors, retries, and partial traffic. A blocked Pod is painful, but it is honest. The platform fix is to make configuration readiness part of release readiness.

A practical preflight job can render the workload, extract required references, and query the target namespace for object and key existence without printing Secret values. It should fail the release when a required reference is absent, when an ExternalSecret is not ready, or when the rendered name differs from the sync target. That job belongs in the delivery path, not in an incident runbook alone. Kubernetes CreateContainerConfigError then becomes a backstop signal for a missed dependency, rather than the first place the dependency graph is tested.


11. CreateContainerConfigError vs CrashLoopBackOff and CreateContainerError

CreateContainerConfigError differs from CrashLoopBackOff because the container process never started, while CrashLoopBackOff means a container started, exited, and is waiting before another restart attempt. It also differs from CreateContainerError, where configuration succeeded and the runtime create call failed. The status boundary tells you which evidence exists and which debugging path is valid.

Use restart count and events together. CreateContainerConfigError normally shows zero restarts and a Failed event from kubelet about configuration resolution. CrashLoopBackOff shows restarts, terminated state, exit codes, and logs from the previous container instance. CreateContainerError points closer to runtime creation problems such as invalid container settings, duplicate names in some contexts, or runtime refusal after kubelet prepared the config.

The CrashLoopBackOff troubleshooting guide starts after a process has run. Do not borrow its log-first workflow for a Pod that has no process history. For CreateContainerConfigError, the evidence order is event, Pod spec references, namespace inventory, key inventory, then delivery ordering. For CreateContainerError, move toward runtime and node evidence after confirming configuration references resolve.

This distinction also prevents bad fixes. Restarting a Deployment does not create a missing Secret. Increasing memory does not repair a missing key. Changing a probe does not matter before the process exists. Name the phase correctly, and the fix becomes smaller.

CreateContainerError needs a different evidence set. Once configuration resolves, kubelet asks the runtime to create the container with mounts, namespaces, cgroups, devices, and security settings. Failures there can involve runtime state, invalid mount combinations, device access, or node-level constraints. If the event no longer names a missing object or key, stop editing ConfigMaps. Move to container runtime logs, node conditions, and the exact create error returned by the runtime. Keeping Kubernetes CreateContainerConfigError separate from CreateContainerError protects both runbooks from becoming vague Pod-start advice.


12. Troubleshooting matrix for Kubernetes CreateContainerConfigError events

A CreateContainerConfigError matrix should map the Failed event text to the smallest safe fix. Read the event as a contract: object not found means create or rename the object, key not found means repair the selected key, mount failure means leave env triage, and root user wording means fix the effective container identity.

Event signal Likely cause Confirm with Fix
secret "name" not found Secret missing in Pod namespace or wrong name kubectl get secret name -n ns Create the Secret through the approved path or fix the reference
configmap "name" not found ConfigMap missing, wrong namespace, or overlay name drift kubectl get configmap name -n ns Create the ConfigMap or correct rendered name
couldn't find key KEY in Secret ns/name Secret exists, selected key absent or misspelled `kubectl get secret name -n ns -o json jq '.data keys'` Add the key or fix secretKeyRef.key
couldn't find key KEY in ConfigMap ns/name ConfigMap exists, selected key absent or case drift `kubectl get configmap name -n ns -o json jq '.data keys'` Add the key or fix configMapKeyRef.key
FailedMount with volume name Volume source, item, or mount setup failure kubectl describe pod mount events Repair volume source, item key, path, or optional setting
runAsNonRoot and image will run as root Effective user cannot be proven non-root Pod securityContext and image user Set numeric runAsUser or rebuild image user
ExternalSecret not ready Sync ordering or source permission failure ExternalSecret status and target Secret keys Fix sync dependency before rollout

After applying the fix, verify the exact Pod transition. The waiting reason should clear, the container should reach Running, readiness should pass on its own merits, and the Deployment should stop creating replacement Pods for the same reason. If the status changes to CrashLoopBackOff, you have crossed into a new phase: configuration resolved, the process started, and application logs now matter.


13. Prevention checklist for Kubernetes CreateContainerConfigError in production

Prevent CreateContainerConfigError by treating configuration references as release dependencies, not as loose strings in a Pod template. Every required ConfigMap, Secret, key, namespace, and sync owner should be visible before rollout. The cheapest production control is a preflight check that renders manifests and verifies required references against the target namespace contract.

Use this checklist before a rollout:

  • Render the exact manifests for the target namespace and list every envFrom, configMapKeyRef, secretKeyRef, projected volume, and config volume reference.
  • Verify each required object exists in the Pod namespace or will be created by an earlier sync wave with a named owner.
  • Verify selected keys by name, including case and hyphen or underscore choices.
  • Keep required references required. Use optional: true only when the application has a safe default and the absence is observable.
  • Add ExternalSecret readiness to release gates when the workload depends on synced Secrets.
  • Test runAsNonRoot with numeric users in image builds and Pod security reviews.
  • Alert on Pods waiting with CreateContainerConfigError for more than a few minutes, grouped by namespace, owner, and referenced object.
  • Keep rollback simple: if a template adds a new required reference, the previous template must remain deployable until the new configuration path is proven.

The operational habit is to debug from the event outward. CreateContainerConfigError is rarely mysterious once the Failed event is read closely. It becomes expensive when teams chase images, probes, RBAC, or application logs before checking the reference that kubelet already named.

Measure the failure after the fix. Track how often Pods enter Kubernetes CreateContainerConfigError, which namespaces repeat the pattern, and which referenced objects appear most often in events. A repeated missing Secret in one namespace usually means bootstrap ordering is weak. Repeated key drift across services usually means naming contracts are not reviewed with the same care as API changes. Treat configuration names and keys as interfaces. Version them, test them, and make breaking changes explicit in release notes. That is how a small waiting reason becomes a platform quality signal instead of a recurring incident.

Frequently Asked Questions

What does CreateContainerConfigError mean in Kubernetes?

CreateContainerConfigError means kubelet cannot build the container configuration before the runtime creates the container. The usual cause is a required ConfigMap, Secret, or selected key that cannot be resolved in the Pod namespace. The container has not started, so check Pod events before logs.

Why does CreateContainerConfigError show secret not found?

The Pod references a Secret name that does not exist in the Pod namespace, or the rendered name differs from the Secret created by your sync path. Check kubectl get secret <name> -n <namespace>, then compare the name in secretKeyRef, envFrom, or the volume source.

How do I fix CreateContainerConfigError when a key is missing?

List the keys on the existing ConfigMap or Secret and compare them with configMapKeyRef.key or secretKeyRef.key. Fix the key name in Git or add the expected key through the approved configuration path. Key matching is exact, including case and hyphens.

Can CreateContainerConfigError happen with envFrom?

Yes. If envFrom references a required ConfigMap or Secret that is missing, kubelet cannot import the environment source and container configuration fails. Use optional: true only when the application can start safely without that source and the absence is observable.

Is CreateContainerConfigError the same as CrashLoopBackOff?

No. CreateContainerConfigError happens before the container process starts, so restart count is normally zero and logs are usually absent. CrashLoopBackOff means the container started, exited, and Kubernetes is waiting before restarting it. The fix path is different.

Why is there no log for CreateContainerConfigError?

There is usually no application log because no container process ran. Kubelet failed while resolving configuration references, so the useful evidence is in kubectl describe pod events, the Pod spec references, and the ConfigMap or Secret inventory in the namespace.

How do I prevent Kubernetes CreateContainerConfigError in GitOps?

Make configuration readiness part of release readiness. Render manifests for the target namespace, verify required objects and keys, order ExternalSecret sync before workload rollout, and fail preflight when a required reference cannot be resolved. Keep required references required unless the app has a safe default.

⚡ 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 →