Kubernetes ConfigMap Not Found: How to Fix CreateContainerConfigError

A pod in CreateContainerConfigError with the event 'configmap not found' is asking for a ConfigMap name that does not exist in its namespace. Kubernetes accepts the Deployment anyway and only fails when it creates the container. Compare the name in the pod spec with kubectl get configmaps and correct the reference.

Start this project - freeLive cloud workspace in your browser · lands on your portfolio
Kubernetes Engineerkuberneteskubectlconfigmap

What you see

kubectl get pods -l app=web
NAME                   READY   STATUS                       RESTARTS   AGE
web-6d9f7c8b5d-x2k4p   0/1     CreateContainerConfigError   0          45s

CreateContainerConfigError means the image pulled fine, but Kubernetes could not build the container's configuration - usually an env var or volume that points at a ConfigMap or Secret that is not there.

Step 1: read the pod Events

kubectl describe pod -l app=web

At the bottom, under Events:

Warning  Failed  12s (x5 over 45s)  kubelet  Error: configmap "app-config" not found

The event names the exact ConfigMap the pod is looking for.

Step 2: list the ConfigMaps that really exist

kubectl get configmaps
NAME               DATA   AGE
app-cfg            1      2m
kube-root-ca.crt   1      10m

The pod wants app-config, but the namespace has app-cfg. Also check that you are in the right namespace - a pod can only use ConfigMaps from its own namespace (kubectl get configmaps -n <namespace>).

Step 3: correct the reference and apply

A ConfigMap can be referenced in several places. Search the manifest for all of them:

spec:
  containers:
  - name: web
    image: busybox:1.36
    envFrom:
    - configMapRef:
        name: app-cfg          # was: app-config

Other places to check: env[].valueFrom.configMapKeyRef.name and volumes[].configMap.name.

kubectl apply -f deployment.yaml
kubectl rollout status deploy/web --timeout=90s

The rollout creates a new pod with the corrected reference.

Step 4: verify the value reaches the container

kubectl exec deploy/web -- printenv GREETING

If the variable prints, the pod is wired to the right ConfigMap.

Other option: create the missing ConfigMap

If the Deployment is correct and the ConfigMap was simply never created (for example, a new environment), create it instead of changing the Deployment:

kubectl create configmap app-config --from-literal=GREETING='hello'

The kubelet keeps retrying, so the waiting pod starts by itself once the ConfigMap exists. Decide which side is wrong before you change anything - other workloads may depend on the current name.

Why kubectl apply did not catch it

Kubernetes checks references lazily. kubectl apply validates the Deployment's structure, not whether every ConfigMap or Secret it names exists. The error only appears when the kubelet tries to start the container. So always check pod status after an apply - a successful apply does not mean a running pod.

Make a reference optional

If the app can run without the ConfigMap, mark the reference optional:

envFrom:
- configMapRef:
    name: app-config
    optional: true

The pod then starts even when the ConfigMap is missing. Use this only when the values are truly optional - otherwise you hide a real problem.

Do this project yourself. It's ready in a live cloud workspace in your browser - when you finish, it lands on your portfolio.

Start this project - free

What you'll practice

FAQ

What does CreateContainerConfigError mean in Kubernetes?

Kubernetes could not build the container's configuration. The most common cause is a reference to a ConfigMap, Secret, or key that does not exist. kubectl describe pod shows the exact name in the Events.

Why does kubectl apply succeed if the ConfigMap does not exist?

Kubernetes does not check ConfigMap and Secret references when you apply a Deployment. The check happens when the kubelet creates the container, so the error shows on the pod, not on the apply.

Can a pod use a ConfigMap from another namespace?

No. A pod can only reference ConfigMaps in its own namespace. Create a copy of the ConfigMap in the pod's namespace.

Do I need to delete the pod after creating the missing ConfigMap?

Usually not. The kubelet keeps retrying and the pod starts once the ConfigMap exists. If you changed the Deployment instead, kubectl apply rolls out a new pod.

Keep learning

Mount a Missing ConfigMap Into a PodKubernetes projectInject a Secret into a Pod as Environment VariablesKubernetes projectFix a Kubernetes CrashLoopBackOffKubernetes projectKubernetes roadmapStep by step to hiredKubernetes interview questionsSTAR answersAll Kubernetes projectsProjects hub

Do this project yourself. It's ready in a live cloud workspace in your browser - when you finish, it lands on your portfolio.

Start this project - free
Start this project - free