Kubernetes "CreateContainerConfigError" - Fix Missing ConfigMap/Secret in CI
The pod scheduled fine, but the kubelet cannot assemble the container's configuration: an envFrom/valueFrom/volume references a ConfigMap, Secret, or specific key that is not present in the namespace.
What this error means
The pod sits in CreateContainerConfigError and kubectl describe pod shows Error: configmap "X" not found or couldn't find key Y in Secret. It is deterministic -- the referenced object simply is not there -- so the rollout never becomes Ready.
Warning Failed kubelet Error: configmap "app-config" not found
# or
Warning Failed kubelet Error: couldn't find key DATABASE_URL in Secret "default/app-secrets"Common causes
Referenced ConfigMap or Secret missing
The manifest references a ConfigMap/Secret by name that was never created in the pod's namespace, or was created in a different namespace.
Referenced key absent
The ConfigMap/Secret exists but does not contain the specific key the container's env or volume mount asks for.
How to fix it
Create the missing object/key in the right namespace
- Read the describe message for the exact object and key name.
- Confirm it exists in the pod's namespace:
kubectl get configmap,secret -n <ns>. - Apply the missing ConfigMap/Secret (or add the missing key) before the deployment.
kubectl get configmap app-config -n prod -o yaml
kubectl get secret app-secrets -n prod -o jsonpath='{.data}'Order config objects before the workload
- Apply ConfigMaps/Secrets in the same kustomize/Helm release as the Deployment.
- Match the names and keys in the Deployment exactly to the created objects.
- Re-roll the deployment so the kubelet re-reads the now-present config.
How to prevent it
- Keep ConfigMaps/Secrets and the workloads that use them in one release.
- Validate referenced names and keys before apply (e.g. with kubeconform/conftest).
- Avoid cross-namespace references; create config in the workload's namespace.