Kubernetes "CreateContainerConfigError" - Fix Missing ConfigMap/Secret
CreateContainerConfigError means the kubelet could not assemble the container’s configuration before starting it - almost always a ConfigMap, Secret, or a specific key the pod references that does not exist in its namespace.
What this error means
A pod sits at STATUS: CreateContainerConfigError and never starts. kubectl describe pod names the missing object - configmap "x" not found or couldn't find key y in Secret.
Warning Failed 10s (x4 over 30s) kubelet Error: configmap "app-config"
not found
# or
Error: couldn't find key DATABASE_URL in Secret prod/db-credentialsCommon causes
Referenced ConfigMap or Secret missing
An envFrom/valueFrom or volume references a ConfigMap/Secret that was never created in the pod’s namespace, or was applied to a different namespace.
Missing key in an existing object
The object exists but the specific key the container asks for (valueFrom.secretKeyRef.key) is not present - a typo or an out-of-sync secret.
How to fix it
Confirm the object and key exist in the right namespace
kubectl -n <ns> get configmap app-config
kubectl -n <ns> get secret db-credentials -o jsonpath='{.data}'; echoCreate or fix the referenced config
- Apply the missing ConfigMap/Secret into the pod’s namespace before the workload.
- Match the exact key names the container references (case-sensitive).
- Order CI so config objects are applied before the Deployment that consumes them.
How to prevent it
- Apply ConfigMaps/Secrets in the same namespace and before the workloads that use them.
- Keep key names in sync between the manifest and the referenced object.
- Validate references with
kubectl apply --dry-run=serverin CI.