Pods go into CrashLoopBackOff after a config change; logs show `KeyError: 'DATABASE_URL'`.

BeginnerTroubleshootingSite down
Answer

Likely causes → The env var was removed or renamed in the ConfigMap/Secret, the Secret key changed, or the pod references a Secret in another namespace.

Diagnose →

kubectl logs deploy/api -n prod --previous
kubectl describe pod -n prod -l app=api | grep -A5 -i -E 'environment|events'
kubectl get secret api-secrets -n prod -o jsonpath='{.data}' | jq 'keys'

Fix → kubectl rollout undo deploy/api -n prod, then restore the key.

Prevent → Validate required config at startup with a clear message, keep config in the same PR as code, and mark env refs with optional: false (the default) so missing keys fail at pod creation, not runtime.

All Real-World Interview questions Roadmap: Interview readiness

More on Site down