🎉 DevOps Interview Prep Bundle is live — 1000+ Q&A across 20 topicsGet it →
All Fixes
Today I Fixed

CrashLoopBackOff on new deployment — ConfigMap created in wrong namespace

kubernetesJun 29, 202610 minutes to fixkubernetestroubleshooting

A new deployment went into CrashLoopBackOff immediately after kubectl apply. Running kubectl logs showed the app dying on startup with: Error: config file not found at /etc/app/config.yaml.

Root cause: The ConfigMap (app-config) had been created in the default namespace, but the deployment was running in the production namespace. Kubernetes ConfigMaps are namespace-scoped — the pod couldn't find the ConfigMap, so the mounted file simply didn't exist at startup.

Fix:

First, find where the ConfigMap actually lives:

bash
kubectl get configmap -A | grep app-config
# Output: default    app-config    1    5m

Recreate it in the correct namespace:

bash
# Export from default namespace
kubectl get configmap app-config -n default -o yaml \
  | sed 's/namespace: default/namespace: production/' \
  | kubectl apply -f -
 
# Verify it's in the right place
kubectl get configmap app-config -n production

Then restart the deployment:

bash
kubectl rollout restart deployment my-app -n production
kubectl rollout status deployment my-app -n production

Check that the pod starts cleanly:

bash
kubectl logs -n production -l app=my-app --tail=20

Lesson: When a pod can't find a mounted ConfigMap or Secret, always run kubectl get configmap -A | grep <name> first — it's almost always a namespace mismatch, not a missing resource.