CreateContainerConfigError ☸️ Kubernetes

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

  1. kubectl describe pod → Events names the missing object/key
  2. Create it in the same namespace
  3. Use optional: true for truly optional keys
  4. Order manifests so secrets apply first

Detailed fix by platform

Kubernetes

  1. 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

  1. Events — Which secret/configmap/key is missing?
  2. Namespace — Same namespace as the pod?
  3. 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.