Kubernetes: CreateContainerConfigError — secret / configmap not found
Kubernetes can’t build the container’s configuration — usually a referenced Secret, ConfigMap or key doesn’t exist in that namespace.
Seen on:
Kubernetes
Meaning
Environment variables and volumes from Secrets/ConfigMaps are resolved before the container starts. A missing object or key (or a wrong namespace) stops it here — the app never runs, so there are no app logs.
Common causes
- Secret/ConfigMap not created (or created in another namespace)
- Key name typo in
secretKeyRef/configMapKeyRef - Deployment applied before its secrets in CI
- runAsNonRoot set but the image runs as root
⚡ Quick fix
kubectl describe pod→ Events names the missing object/key- Create it in the same namespace
- Use
optional: truefor truly optional keys - Order manifests so secrets apply first
Detailed fix by platform
Kubernetes
- Check and create:bash
kubectl -n prod get secret api-secrets -o jsonpath='{.data}' | head -c 300 kubectl -n prod create secret generic api-secrets --from-literal=DATABASE_URL='postgres://…'
How to diagnose
- Events — Which secret/configmap/key is missing?
- Namespace — Same namespace as the pod?
- Keys — Exact key names?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026