https://dev.to/yash_sonawane25
Learn how to debug your first Kubernetes crash like a pro (even if you’re just starting out).
You deployed your app to Kubernetes. Everything looked fine. And then—boom—it crashed. No logs, no traffic, just a mysterious failure.
Don’t worry. We’ve all been there. In this beginner-friendly guide, I’ll walk you through exactly how to debug a Kubernetes app crash step-by-step.
🧠 Step 1: Understand the Crash Types
Before jumping in, it helps to know what kind of crash you're dealing with:
- CrashLoopBackOff: Your container is starting, failing, and retrying in a loop.
- ImagePullBackOff: Kubernetes can’t find or pull your container image.
- OOMKilled: Your app used too much memory and was killed.
- Completed: Your container exited normally (common in jobs).
Each type tells a story. Let’s decode it.
🔍 Step 2: Check Pod Status
kubectl get pods
Look at the STATUS column. If you see something like CrashLoopBackOff
, grab the pod name and inspect it:
kubectl describe pod
This gives you events, restarts, reasons, and more. Look for lines like:
Last State: Terminated
Reason: OOMKilled
Exit Code: 137
📄 Step 3: Check Pod Logs
Logs are your best friends.
kubectl logs
If the pod has multiple containers:
kubectl logs -c
Look for stack traces, uncaught exceptions, or config errors.
💡 Use
--previous
flag if the container has already restarted.
kubectl logs --previous
🔧 Step 4: Exec Into the Pod (If It’s Still Running)
Sometimes it's easier to debug from inside the pod:
kubectl exec -it -- /bin/bash
Check environment variables, file paths, dependencies:
env
ls /app
cat config.yaml
📦 Step 5: Validate Your Deployment
Check for errors in your manifest:
- Wrong image name/tag?
- Missing environment variables?
- Wrong command/entrypoint?
- CPU/memory limits too low?
kubectl get deployment -o yaml
🧯 Step 6: Check Events & Nodes
Maybe the issue isn't your app. Maybe it's the cluster.
kubectl get events --sort-by=.metadata.creationTimestamp
Also check node status:
kubectl get nodes
A node could be out of resources or in NotReady
state.
🛠️ Step 7: Use Liveness & Readiness Probes
If you’re not already using them, add these to your deployment:
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 10
periodSeconds: 5
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 3
This helps Kubernetes know when to restart your app or stop sending traffic.
✅ Final Thoughts
Debugging in Kubernetes takes practice. Use the built-in tools: kubectl logs
, describe
, exec
, events
.
Start with what Kubernetes is telling you, then dig deeper. And always keep your YAML clean, validated, and version-controlled.
If you found this helpful, share it with a fellow beginner and follow me on Dev.to for more DevOps guides. Happy debugging! 🛠️🐳☸️