Skip to the page

Kubernetes: shipping a service · core

Debugging CrashLoopBackOff, ImagePullBackOff and stuck rollouts

Always start with the pod status, then describe, then the logs of the previous run, then events. The exit code and the event message usually name the cause.

The notes

What you must know

  • Commands: kubectl get pods (status, restarts), kubectl describe pod (events, last state, reason, exit code), kubectl logs <pod> --previous (the crashed container), kubectl get events --sort-by=.lastTimestamp.
  • Exit codes: 1 is an app error, 137 is SIGKILL (often OOMKilled), 139 a segmentation fault, 127 command not found.
  • exec format error: the binary is for the wrong CPU architecture, for example an image built on an Apple Silicon (arm64) laptop and run on amd64 nodes. Build with docker buildx build --platform linux/amd64 or publish a multi-architecture image.
  • Missing environment variable or config: the app exits at startup. Compare the pod's env with what runs locally.
  • ImagePullBackOff causes: a tag that does not exist (typo, v prefix), no permission to the registry (another account or region, missing pull secret or node role), public registry rate limits, no image for the node architecture.
  • Pending with Insufficient memory: the pod asks for more than any node can give. Often a typo in requests, sometimes a full cluster the autoscaler cannot grow. Fix the request first.
  • A rolling update keeps old pods serving while new pods fail, so users are usually fine. Confirm with the error rate, then use kubectl rollout status and kubectl rollout undo if needed.
  • Readiness probe failing: the pod runs but gets no traffic. Describe shows probe failures.

The red pen

Common traps: mistake → fix

  • Mistake: CrashLoopBackOff is a Kubernetes error

    Fix: It is the app crashing again and again with growing waits. Read the previous logs.

  • Mistake: kubectl logs shows the cause of the crash

    Fix: It shows the new container. Use --previous for the crashed one.

  • Mistake: A stuck rollout means an outage

    Fix: Old pods keep serving during a rolling update.

Easy to hard

Questions interviewers ask, easy to hard

  1. A pod is in CrashLoopBackOff. What do you run, in order?
  2. What does exit code 137 mean and how do you confirm the cause?
  3. What does exec format error mean?
  4. A rollout is stuck at 2 of 6 pods. How do you find out why?
  5. The app runs locally but crashes on the cluster. List the usual differences.

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview