What is CrashLoopBackOff and how do you debug it?
Quick Answer
CrashLoopBackOff means a container keeps starting, crashing, and being restarted, with Kubernetes backing off (waiting longer) between attempts. Debug with logs (including previous), describe, and the exit code.
Detailed Answer
Common causes: the app exits on a bug or bad config, a missing dependency or env var/secret, an OOM kill (exit 137), or a failing liveness probe restarting a healthy-but-slow app. Investigate with kubectl logs pod --previous, kubectl describe pod (events, last state, exit code), and check probes and resource limits. Fix the root cause rather than just restarting.
Code Example
kubectl describe pod <pod> kubectl logs <pod> --previous # logs from the crashed instance
Interview Tip
List the usual causes and that --previous shows the crashed container logs; call out liveness-probe misconfig as a sneaky one.