Skip to content
Latchkey

Kubernetes "CreateContainerConfigError" on deploy in CI - Fix it

CreateContainerConfigError means the pod was scheduled but the kubelet could not assemble the container configuration - typically because an envFrom/valueFrom/volume points at a ConfigMap or Secret (or a key inside one) that is not present in the namespace.

What this error means

kubectl get pods shows CreateContainerConfigError and kubectl describe pod reports something like configmap "app-config" not found or couldn't find key DB_URL in Secret. The container never starts.

kubectl
Warning  Failed  kubelet  Error: couldn't find key DATABASE_URL in Secret
"default/api-secrets"

Common causes

Referenced ConfigMap/Secret does not exist

The manifest references a ConfigMap or Secret that was never created in this namespace, or was deployed to a different namespace.

A named key is missing

The ConfigMap/Secret exists but the specific key the env var maps to is absent or misspelled.

How to fix it

Find the exact missing object or key

describe names what is missing; confirm against the live cluster.

Terminal
kubectl describe pod <pod>
kubectl get secret api-secrets -o jsonpath='{.data}' | tr ',' '\n'
kubectl get configmap app-config -n <ns>

Create or fix the reference

  1. Apply the missing ConfigMap/Secret to the correct namespace before (or with) the workload.
  2. If a key is misnamed, fix the key: in the pod spec or add the key to the source object.
  3. Order the apply so config exists before the Deployment, or apply the whole kustomize/Helm bundle together.

How to prevent it

  • Deploy config (ConfigMap/Secret) and workload as one bundle so neither lands without the other.
  • Validate referenced keys in CI (kubeconform/conftest) before apply.
  • Pin namespaces explicitly in manifests so objects do not split across namespaces.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →