CreateContainerConfigError happens before your container even starts: the kubelet tried to assemble the container's environment variables or volume mounts, but a referenced ConfigMap or Secret is missing or malformed.
30-Second kubectl Diagnosis
# 1. Read the exact missing ConfigMap/Secret name under Events kubectl describe pod -n | grep -A 15 "Events:" # 2. List ConfigMaps and Secrets in the SAME namespace kubectl get configmaps,secrets -n Top 4 Causes & Exact Fixes
Missing ConfigMap or Secret: The Pod references
secretKeyReforconfigMapRefthat was never created (or created in the wrong namespace). ConfigMaps and Secrets are strictly namespace-scoped.Wrong Key Name Inside an Existing Secret/ConfigMap: The object exists, but the key specified in
key: DB_PASSdoes not match the actual key (e.g.,DB_PASSWORD). Inspect keys withkubectl get secret <name> -o jsonpath='{.data}'.Optional Flag Not Set: If a ConfigMap is genuinely optional, add
optional: trueunderconfigMapKeyRef/secretKeyRefso the Pod starts cleanly without it.Invalid Non-String Data or Missing
subPath: Mounting a single key viasubPathfails if that key is missing from the ConfigMap.
Safe Optional Reference Pattern
env: - name: FEATURE_FLAGS valueFrom: configMapKeyRef: name: app-config key: feature_flags optional: true Related guides: Also seeing startup crashes? Check CrashLoopBackOff, ImagePullBackOff, and validate your Pod resources with our Kubernetes QoS Class Checker.
Originally published at OpsHubs. Found it useful? Buy us a coffee ☕.

