Skip to content
tezvyn:
Menu

Debugging a Pod in CrashLoopBackOff

Source: interviewEasyHow cards are made

Summary

Practical Pod debugging instinct.

Key points

kubectl describe pod for events, restarts, and last state; kubectl logs (with --previous) for the crashed container's output.

What's really being asked

CrashLoopBackOff means a container starts, exits, and Kubernetes keeps restarting it with increasing back-off delays. The interviewer checks whether you gather evidence before acting.

The full answer

First, kubectl describe pod POD_NAME. This surfaces the Events section, the container's restart count, its Last State (often Terminated with an exit code and Reason), and any image-pull or scheduling problems. Second, kubectl logs POD_NAME, and importantly kubectl logs POD_NAME --previous. Because the current container instance may have already died, --previous retrieves stdout and stderr from the prior crashed instance, which usually contains the actual stack trace or error message.

The mistakes people make

Deleting the Pod to force a fresh start, which throws away the failing container's history. Restarting the whole Deployment blindly. Only checking kubectl get pods, which shows the status but not the cause.

What usually comes next

What exit code suggests an out-of-memory kill? 137, meaning the container was SIGKILLed, often by the OOM killer when it exceeded its memory limit. How would you debug if logs are empty? Exec into a sidecar or use an ephemeral debug container. How does back-off timing work? Delays grow exponentially up to a cap.

A concrete example

A service crashes on boot. kubectl describe pod shows Reason: Error and exit code 1, plus an event noting the restart count climbing. kubectl logs --previous reveals a fatal error reading a missing environment variable. The fix is adding the variable via a ConfigMap, not restarting the Pod.

Interview question

Why is kubectl logs POD_NAME --previous often more useful than plain kubectl logs for a CrashLoopBackOff Pod?

  • a.It includes cluster-level scheduler logs
  • b.It retrieves output from the prior crashed container instance, which holds the actual errorCorrect
  • c.It shows logs from every Pod in the Deployment
  • d.It streams future logs in real time
Why?

The current container may have just died, so --previous reads the crashed instance's logs where the error actually appears. It does not stream future logs or aggregate across Pods.

Just read this? Test yourself on what you have been reading.

Read the original → kubernetes.io

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on kubernetes — each one lists the topics its interview covers.

See open roles