How do you troubleshoot a Pod stuck in CrashLoopBackOff? How do you distinguish between exit code 137, 1, and 127?
“CrashLoopBackOff is not an error itself (read our full CrashLoopBackOff SRE runbook and ImagePullBackOff guide)—it is kubelet's exponential backoff state telling us that a container repeatedly crashed after starting. I immediately inspect kubectl describe pod to examine the container's Last State: Terminated exit code. Exit 137 indicates a SIGKILL from the Linux kernel OOM killer or cgroup limit; Exit 1 indicates an unhandled application exception, missing configuration, or failed database connection; and Exit 127 indicates command not found due to a broken entrypoint binary or missing library path.”
The Mental Model: What the Exit Codes Actually Mean
When a container terminates in Linux, the process returns a status code between 0 and 255. Any code above 128 indicates termination by a fatal signal (128 + Signal Number). Signal 9 (SIGKILL) equals 137 (128 + 9). Signal 15 (SIGTERM) equals 143 (128 + 15). Knowing this arithmetic immediately isolates whether the application failed internally or the operating system killed it from the outside.
S Situation
Following a microservice release, 4 out of 10 pods in our payment processing deployment entered CrashLoopBackOff with Exit Code 137, while the remaining 6 pods stayed healthy.
T Task
Determine why identical containers exhibited divergent memory behaviors and restore 100% pod availability without blind resource over-allocation.
A Action
1. Ran kubectl logs <pod> --previous and saw heap metrics spikes right before termination.
2. Correlated with Prometheus metrics and noticed affected pods were processing large batch reconciliation payloads.
3. Identified Java heap was set to -Xmx1500m inside a 1536Mi container limit, leaving only 36MB for non-heap native memory.
4. Rebalanced container memory limit to 2048Mi and tuned JVM heap to 75% container memory using -XX:MaxRAMPercentage=75.0.
R Result
CrashLoopBackOff was completely eliminated, batch jobs completed in 4.2 seconds, and pod memory headroom maintained a stable 25% safety margin.
The Rookie Answer: “I run kubectl delete pod to make it restart.”
The Senior Answer: Differentiate between an application-level OOM (where the language runtime throws an OutOfMemoryError and exits with code 1) versus an OS-level cgroup kill (where the kernel fires SIGKILL and sets exit code 137). Only exit 137 points to container resource limits.