About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
A pod that sits in CreateContainerConfigError, with the event Error: secret "db-credentials" not found or Error: configmap "app-settings" not found, is waiting for a Secret or ConfigMap that does not exist in the pod's own namespace. The kubelet looks the object up while it builds the container's environment variables and stops there. Create the object in the right namespace, or correct the name in the workload. The Secrets page says the kubelet periodically retries a pod whose Secret could not be fetched.
What the error means
Before the kubelet asks the container runtime to create a container, it builds the container's configuration. That includes the environment variables from env entries that use secretKeyRef or configMapKeyRef, and from envFrom. In the kubelet source at tag v1.37.3, each lookup uses the pod's own namespace (pod.Namespace) and returns the error unless the reference is marked optional. The ConfigMap page says the same about placement: "The Pod and the ConfigMap must be in the same namespace."
The same source (with the reason string defined in pkg/kubelet/events/event.go) then records a warning event with the reason Failed and the message Error: followed by the error text, and reports the container status CreateContainerConfigError.
The Secrets page says the kubelet's default strategy for its Secret cache is Watch. With that strategy the kubelet source builds the not-found error from the singular resource name, so the event reads:
Error: secret "db-credentials" not found
Error: configmap "app-settings" not found
With another cache strategy the text may differ, because the lookup then goes through other code. An object that exists but lacks the named key produces a different message, with ConfigMap in place of Secret for a ConfigMap:
Error: couldn't find key api-key in Secret shop/db-credentials
Two rules from the documentation matter here. By default a Secret is required: "None of a Pod's containers will start until all non-optional Secrets are available." And a reference marked optional: true is ignored when the object is missing ("If an optional Secret doesn't exist, Kubernetes ignores it").
A Secret or ConfigMap used as a volume goes a different way. A reading of the kubelet source is that a failure there is reported in an event beginning MountVolume.SetUp failed, from the volume code and not from the container-configuration code above. That fault does not show CreateContainerConfigError.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| The Secret or ConfigMap was never created, or is created after the workload | secret "x" not found, often right after a deployment |
kubectl get secret x -n shop answers that it was not found |
| It exists in a different namespace | The same message, while the object is visible elsewhere | kubectl get secrets --all-namespaces lists the name under another namespace |
| The name is misspelt in the pod spec | The same message, and a similar name exists | Compare the name in the workload with the list of names |
| The object exists but the key does not | couldn't find key ... in Secret ns/name |
kubectl describe secret x -n shop lists the key names |
Prove the cause before changing anything
These checks only read. They do not print a Secret's contents; a Deployment's YAML may hold literal values, so read it before pasting it anywhere.
- Read the events of the stuck pod. The Debug Pods page makes this the first step:
kubectl describe pod web-6d5f9c7b8-x2k4q -n shop
The warning at the bottom gives the object type and name, or the key. A pod in the Waiting state is scheduled and cannot start, which is what the page describes.
- Look for the object in the pod's namespace:
kubectl get secret db-credentials -n shop
kubectl get configmap app-settings -n shop
A good result lists the object. A bad result is a not-found answer.
- If it is not there, look in every namespace for the same name:
kubectl get secrets --all-namespaces
- If it is there but the key is the problem, list the key names. The Managing Secrets page says
kubectl getandkubectl describe"avoid showing the contents of a Secret by default", so this is safe to run and paste:
kubectl describe secret db-credentials -n shop
Avoid kubectl get secret ... -o yaml for this check, because its output carries the values.
- Read what the workload refers to. A Deployment's YAML normally holds names, but it can carry literal
value:entries, so keep the output private:
kubectl get deployment web -n shop -o yaml
Find secretKeyRef, configMapKeyRef and envFrom, and compare each name and key with steps 2 to 4.
Fix
Which fix applies depends on step 2 to step 5. If the object is missing, create it (fix A). If the reference is wrong, correct the workload (fix B). Marking the reference optional: true hides the message and leaves the variable unset (the ConfigMap task page says the configuration "will be empty"), so use it only where the application runs without the value.
Fix A: create the missing Secret or ConfigMap
First save the current state:
kubectl get secrets -n shop > secrets-before.txt
kubectl get configmaps -n shop > configmaps-before.txt
Risk: the next step creates the missing Secret or ConfigMap in the namespace shop, and every pod there that refers to it starts using its values when the kubelet retries.
Create it from the real values, which come from whoever owns the application. This example reads a Secret's values from a file named db.env:
kubectl create secret generic db-credentials -n shop --from-env-file=db.env
For a ConfigMap, apply its manifest instead, for example kubectl apply -f app-settings.yaml. The file db.env holds the values in plain text. Removing it is for the owner of the values, once they are stored in the owner's password store.
To undo it: delete only the object you just created, then compare with the saved list.
kubectl delete secret db-credentials -n shop
kubectl get secrets -n shop
For a ConfigMap, run kubectl delete configmap app-settings -n shop and then kubectl get configmaps -n shop. The listing should match the saved file (secrets-before.txt or configmaps-before.txt). Pods that start after the delete fail again with the same message.
Fix B: correct the reference in the workload
First save the current state:
kubectl get deployment web -n shop -o yaml > web-deployment-before.yaml
kubectl rollout history deployment/web -n shop
Note the current revision number from the history output (called N below). The saved file may hold literal values, so keep it private.
Disruptive step: the next command edits the pod template of the Deployment web, so the Deployment replaces its pods with new ones.
Open the Deployment in the default editor and correct the name or key:
kubectl edit deployment/web -n shop
Then wait for the rollout:
kubectl rollout status deployment/web -n shop
To back out: return to the revision noted before the edit (replace N with that number), wait for it, and check that the pod template and the env references match the saved file. Fields such as resourceVersion and generation will differ.
kubectl rollout undo deployment/web -n shop --to-revision=N
kubectl rollout status deployment/web -n shop
kubectl get deployment web -n shop -o yaml
Example (illustrative): the Deployment web in namespace shop refers to the Secret db-credentials. The new pod web-6d5f9c7b8-x2k4q, scheduled on k8s-node1, shows CreateContainerConfigError, and kubectl describe pod ends with:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning Failed 8s (x4 over 41s) kubelet Error: secret "db-credentials" not found
kubectl get secret db-credentials -n shop answers that it was not found, and kubectl get secrets --all-namespaces lists db-credentials in the namespace staging. The Secret was created in the wrong namespace. The engineer saves the list of Secrets in shop, creates db-credentials in shop with fix A, and within a retry cycle the pod starts. The copy in staging is left alone.
Confirm the fix
kubectl get pods -n shopshows the podRunning.kubectl describe podshows no newFailedevent withError:after the change.- For fix B,
kubectl rollout statusreports that the rollout is complete.
If the container now starts and then exits, the fault has moved on to a different state. See Kubernetes CrashLoopBackOff: find out why the container keeps exiting. If the pod cannot pull its image, see Kubernetes ImagePullBackOff and ErrImagePull: read the pod events, then fix the image or the credentials.
What to watch afterwards
- Apply Secrets and ConfigMaps before the workloads that use them. The Secrets page says a Secret "needs to be created before any Pods that depend on it".
- When manifests are copied between environments, check the
namespaceof every Secret and ConfigMap in the set, since a pod only reads its own namespace. - In a pipeline, follow each deployment with
kubectl rollout status, which watches the rollout until it is done. Its--timeoutoption sets how long to wait before the watch ends. - Do not add
optional: trueto silence a failing start. The application then runs without the value.
Read next
Related articles you may want next.
- TroubleshootingKubernetes ImagePullBackOff and ErrImagePull: read the pod events, then fix the image or the credentialsPod in ImagePullBackOff or ErrImagePull? Read kubectl describe events, check image name, tag and imagePullSecrets, and fix the cause with a rollback path.Read article
- TroubleshootingKubernetes CrashLoopBackOff: find out why the container keeps exitingPod in CrashLoopBackOff? Read kubectl logs --previous and describe pod, tell a crash from an OOM kill or a failing probe, then fix and confirm.Read article
- TroubleshootingKubernetes pod stuck in Terminating: grace period, finalizers and unreachable nodesPod stuck in Terminating? Check grace period, finalizers, webhooks and the node first. The pages give no undo for force delete or finalizer removal.Read article
Risks and limits
- These commands have not been run or lab-tested.
- The message texts were read from the kubelet source at tag v1.37.3. The documentation pages give no version range for them, so other releases may word them differently.
- The kubelet code at v1.37.3 covers environment variables. A missing object used as a volume produces a different event and is not covered.
- Deleting the object you created in fix A does not undo anything the application did while it ran with the values.
- Never paste Secret values into a ticket or a chat. Use
kubectl describe secret, which lists names and sizes only.
Sources
- Debug Pods — Kubernetes documentation, last modified 24 August 2026, accessed 2 December 2026
- Secrets — Kubernetes documentation, last modified 23 July 2026, accessed 2 December 2026
- ConfigMaps — Kubernetes documentation, last modified 21 November 2025, accessed 2 December 2026
- Configure a Pod to Use a ConfigMap — Kubernetes documentation, last modified 16 August 2026, accessed 2 December 2026
- Managing Secrets using kubectl — Kubernetes documentation, last modified 24 October 2023, accessed 2 December 2026
- kubectl create secret generic — Kubernetes documentation, last modified 26 August 2026, accessed 2 December 2026
- kubectl edit — Kubernetes documentation, last modified 26 August 2026, accessed 2 December 2026
- kubectl rollout undo — Kubernetes documentation, last modified 26 August 2026, accessed 2 December 2026
- kubectl rollout history — Kubernetes documentation, last modified 26 August 2026, accessed 2 December 2026
- kubectl rollout status — Kubernetes documentation, last modified 26 August 2026, accessed 2 December 2026
- kubectl get — Kubernetes documentation, last modified 26 August 2026, accessed 2 December 2026
- kubectl delete — Kubernetes documentation, last modified 26 August 2026, accessed 2 December 2026
- kubectl apply — Kubernetes documentation, last modified 26 August 2026, accessed 2 December 2026
- pkg/kubelet/kubelet_pods.go, tag v1.37.3 — Kubernetes source, no date shown, accessed 2 December 2026
- pkg/kubelet/kuberuntime/kuberuntime_container.go, tag v1.37.3 — Kubernetes source, no date shown, accessed 2 December 2026
- pkg/kubelet/events/event.go, tag v1.37.3 — Kubernetes source, no date shown, accessed 2 December 2026
- pkg/kubelet/util/manager/watch_based_manager.go, tag v1.37.3 — Kubernetes source, no date shown, accessed 2 December 2026
- pkg/kubelet/secret/secret_manager.go, tag v1.37.3 — Kubernetes source, no date shown, accessed 2 December 2026
- pkg/kubelet/configmap/configmap_manager.go, tag v1.37.3 — Kubernetes source, no date shown, accessed 2 December 2026
- staging/src/k8s.io/apimachinery/pkg/api/errors/errors.go, tag v1.37.3 — Kubernetes source, no date shown, accessed 2 December 2026
- staging/src/k8s.io/apimachinery/pkg/runtime/schema/group_version.go, tag v1.37.3 — Kubernetes source, no date shown, accessed 2 December 2026
- pkg/volume/util/operationexecutor/operation_generator.go, tag v1.37.3 — Kubernetes source, no date shown, accessed 2 December 2026
This article was originally published on .