/kubernetes-platform-skills:pod-crashloop-and-oom-troubleshootingfrom kubernetes-platform-skills
Guides diagnosing CrashLoopBackOff and OOMKilled pods using kubectl logs, describe, and top. Helps distinguish undersized memory limits from memory leaks to avoid raising limits blindly.
Ships in kubernetes-platform-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
CrashLoopBackOff is not itself a root cause — it's Kubernetes'
description of a symptom (a container keeps exiting, so the kubelet
keeps restarting it with exponential backoff up to a 5-minute cap). The
actual cause could be an application bug, a missing dependency, a
misconfigured probe killing an otherwise-healthy process, or the
container being killed by the kernel's OOM killer for exceeding its
memory limit — each requiring a different fix, and each easy to
misdiagnose if you only look at the crash-looping status itself rather
than the specific termination reason and exit code underneath it. This
skill covers the diagnostic sequence for both crash-loops in general and
OOMKilled specifically, including the most common mistake: repeatedly
raising a memory limit to make an OOMKilled pod "stop crashing"
without checking whether the real problem is a leak rather than sizing.
CrashLoopBackOff in kubectl get pods and the restart
count keeps climbing.Last State reason is OOMKilled, or its previous container
exited with code 137.kubectl logs <pod> shows nothing useful right after a restart.kubectl access to the pod's namespace with permission to read pod
logs, events, and describe output.metrics-server installed (for kubectl top pod) or a Prometheus/
kube-state-metrics + cAdvisor setup for historical memory usage —
useful for distinguishing a slow leak from a sudden spike, though not
strictly required for a first-pass diagnosis.resources.requests/resources.limits for the container in
question, and its liveness/readiness probe configuration.Confirm the restart pattern and exit code before assuming anything:
kubectl get pods -n <namespace>
kubectl describe pod <pod> -n <namespace>
In the describe output, check Last State → Reason and
Exit Code: OOMKilled + exit code 137 means the kernel's cgroup
OOM killer terminated the container for exceeding its memory limit;
a plain Error + a non-zero exit code (commonly 1) means the
application itself exited; exit code 143 typically indicates a
graceful SIGTERM (e.g. from a failed liveness probe triggering a
restart, or a voluntary shutdown), not a crash.
Always check the previous container's logs, not just current — right after a restart, the current container's logs are often empty or just starting up:
kubectl logs <pod> -n <namespace> --previous
kubectl logs <pod> -n <namespace> --previous -c <container> # multi-container pod
This is the single most-skipped step and the most common reason a crash-loop looks "unexplainable" — the explanation is almost always in the terminated container's own log tail, not the API server's view of it.
Check events for corroborating detail the describe summary may
compress:
kubectl get events -n <namespace> \
--field-selector involvedObject.name=<pod> \
--sort-by='.lastTimestamp'
Look specifically for Liveness probe failed events (points to a
probe, not a crash), BackOff events (confirms the crash-loop
backoff timer, not new information about the cause), or an
OOMKilling kernel-level message surfaced through node events.
If the reason is OOMKilled, determine whether it's an
undersized limit or a real leak. Check the configured limit against
recent usage:
kubectl get pod <pod> -n <namespace> -o jsonpath='{.spec.containers[*].resources}'
kubectl top pod <pod> -n <namespace> --containers
A single spike to the limit under unusually high load suggests
sizing; a memory curve that climbs steadily over hours/days
regardless of load (visible in Prometheus'
container_memory_working_set_bytes over time, if available) points
to a leak that raising the limit will only delay, not fix.
If the reason is a plain application error (not OOM), read the
--previous log's actual error/stack trace, then check for common
root causes: a missing/misnamed ConfigMap/Secret key referenced
in an env var or mounted file, a dependency (database, downstream
service) not yet reachable at startup, a bad image tag/entrypoint, or
a config value that's valid syntax but semantically wrong for this
environment.
Rule out a probe misconfiguration masquerading as a crash. A
liveness probe with too-short initialDelaySeconds,
failureThreshold, or timeoutSeconds can kill a genuinely healthy,
still-starting process, which then looks identical to a real crash
loop from the outside:
kubectl get pod <pod> -n <namespace> -o jsonpath='{.spec.containers[*].livenessProbe}'
If events show repeated Liveness probe failed immediately followed
by container restart, and the application logs (via --previous)
show no actual error at the time of the kill, the probe — not the
application — is the root cause. See
kubernetes-service-connectivity-troubleshooting
for the related readiness-probe failure mode (excluded from Service
endpoints without a restart, the milder sibling of this issue).
Check node-level memory pressure to rule out the node's own OOM killer evicting the pod for a reason unrelated to this container's own limit (overcommitted node, another pod's usage crowding it out):
kubectl describe node <node> | grep -A5 Conditions
kubectl top node <node>
A MemoryPressure condition on the node points to node-level
overcommit, not necessarily this container exceeding its own limit —
see
kubernetes-node-maintenance-and-troubleshooting
for diagnosing node-level resource pressure directly.
Debug interactively without modifying the running workload, when logs alone aren't enough:
kubectl debug <pod> -n <namespace> -it --image=busybox:1.36 --target=<container>
Ephemeral containers/kubectl debug share the target pod's process
namespace without requiring a redeploy or altering the crash-looping
container itself.
Apply the fix that matches the actual cause — raise
resources.limits.memory (with a deliberate, tested margin, not an
arbitrary large bump) only if usage data supports a genuine sizing
gap; fix and redeploy the application if it's a real leak (profile
with the language's native tooling — heap dumps, pprof, etc. —
rather than guessing); fix the referenced config/secret/dependency if
it's a startup error; adjust probe timing/thresholds (or the health
endpoint itself) if it's a probe misconfiguration.
Confirm the fix by watching the restart count stabilize, not just disappear once:
kubectl get pod <pod> -n <namespace> -w
A restart count that stays flat for a full deploy cycle (and ideally a full traffic-pattern cycle, e.g. a day's peak-load window) is a real confirmation; one that hasn't incremented in the last five minutes is not.
kubectl logs --previous before concluding "no useful
logs" — the current container's logs are frequently empty
immediately after a restart while the previous container's final
output holds the actual error.resources.requests/resources.limits deliberately from real
observed usage under load, not a copy-pasted default — see
capacity-planning-and-load-testing
for load-testing methodology to establish real sizing rather than
guessing.OOMKilled after a limit increase as a strong leak
signal, not something to "fix" with a second, larger increase — track
memory usage over time and profile the application rather than
scaling the limit indefinitely.Symptom: kubectl logs <pod> shows nothing useful, or just a
fresh startup banner with no error.
Fix: Use --previous to read the terminated container's own final
output, not the newly restarted container's just-starting logs — this
is the most common reason a crash loop looks unexplainable at first
glance.
Symptom: Exit code 137 is assumed to be an application bug and
"fixed" by repeatedly restarting the deployment, but the crash
recurs.
Fix: 137 = terminated by SIGKILL, commonly (not always) the
cgroup OOM killer. Confirm via describe pod's Last State.Reason —
if it says OOMKilled, the fix is about memory (limit sizing or a
leak), not the restart itself.
Symptom: Raising the memory limit makes the crash loop stop
temporarily, but the same pod gets OOMKilled again hours or days
later after climbing back up to the new, higher limit.
Fix: This pattern is a strong signal of a genuine memory leak, not
an undersized limit. Repeatedly raising the limit only delays the
next OOM and burns more node capacity per pod in the meantime — profile
the application (heap dump, language-native memory profiler) and fix
the leak instead of treating the limit as the dial to turn.
Symptom: A pod restarts on a suspiciously regular interval, and
application logs (via --previous) show no actual error at the
moment of each restart.
Fix: Check events for Liveness probe failed — a probe configured
with too-short initialDelaySeconds/timeoutSeconds relative to the
app's real startup or response time will kill an otherwise-healthy
process on a schedule that mimics a crash loop. Fix the probe
configuration (or the health endpoint's actual behavior) rather than
debugging the application for a bug that isn't there.
Symptom: kubectl delete pod <pod> is used repeatedly to "fix" a
crash-looping pod whenever someone notices it.
Fix: The controller (Deployment/StatefulSet/ReplicaSet) just
recreates the pod, and it crash-loops again for the same underlying
reason — this masks the root cause instead of fixing it, and burns
time on every recurrence. If it's done with
kubectl delete pod --force --grace-period=0 to speed things up,
Warning: this skips graceful termination entirely and can leave a stateful workload's on-disk or external state inconsistent; use it only when a pod is genuinely stuck (e.g. its node is gone), and diagnose the actual crash cause (steps 1–6 above) instead of deleting reflexively.
Scenario: payments-worker-6f9d4b5-2xk9p shows CrashLoopBackOff
with a restart count climbing every few minutes.
kubectl describe pod payments-worker-6f9d4b5-2xk9p -n payments
# Last State: Terminated
# Reason: OOMKilled
# Exit Code: 137
# Started: ...
# Finished: ...
kubectl get pod payments-worker-6f9d4b5-2xk9p -n payments \
-o jsonpath='{.spec.containers[0].resources}'
# {"limits":{"memory":"256Mi"},"requests":{"memory":"128Mi"}}
kubectl top pod payments-worker-6f9d4b5-2xk9p -n payments --containers
# (prior to the last OOM, memory climbed from ~90Mi at startup to 256Mi
# over roughly 40 minutes of otherwise-steady request volume)
The steady climb regardless of load — not a sudden spike under a
traffic burst — points to a leak rather than an undersized limit.
Checking --previous logs confirms no application-level error at the
moment of the kill (consistent with OOM, not a code-path crash).
Investigation of the worker's in-memory cache finds it has no eviction
policy, growing unbounded with every processed job. The fix: add a
bounded, TTL'd eviction policy to the cache (the real fix), plus a more
conservative, evidence-based limit increase to 384Mi as headroom — not
a blind large jump — and a Prometheus alert on
container_memory_working_set_bytes trending toward the limit so the
next leak is caught before it OOMs in production again.
kubectl get pod payments-worker-6f9d4b5-2xk9p -n payments -w
# restart count stays flat through a full day's peak-traffic window
MemoryPressure when an OOM looks correlated with overall node capacity rather than one container's limit.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
kubernetes, troubleshooting, crashloopbackoff, oomkilled, pod-diagnostics, kubectl
npx claudepluginhub selvarajmurugesan90/ops-engineering-skills --plugin kubernetes-platform-skills35 skills in this plugin
/cert-manager-tls-automationGuides installing and configuring cert-manager for automated TLS certificate issuance and renewal — Issuers vs. ClusterIssuers, ACME/ Let's Encrypt HTTP-01 and DNS-01 challenges, private-CA issuance, and integration with Ingress-nginx and Istio gateways. Use when a user asks to "automate TLS certificates on Kubernetes," "set up cert-manager with Let's Encrypt," "fix a stuck Certificate that won't become Ready," "use DNS-01 for a wildcard cert," "rotate mTLS certs automatically," or "issue certs from an internal CA."
/cni-networking-calico-flannelGuides choosing and installing a Kubernetes CNI plugin — Calico vs. Flannel — including NetworkPolicy enforcement capability differences, BGP vs. VXLAN/overlay data paths, and IP address management (IPAM) tradeoffs. Use when a user asks to "choose a CNI plugin for Kubernetes," "enable NetworkPolicy enforcement," "set up Calico with BGP peering," "install Flannel," "debug pod-to-pod connectivity across nodes," or "migrate from Flannel to Calico."
/complete-kubernetes-deployment-on-aks-from-scratchSequences a complete, end-to-end AKS deployment from a bare Azure subscription to a production-ready cluster serving a first workload — Azure landing zone prerequisites, AKS cluster and node pool provisioning, Azure CNI (with the Calico/Cilium alternative noted), ingress (Application Gateway Ingress Controller vs. ingress-nginx), cert-manager with Azure DNS, conformance validation, a Helm-deployed workload, and a node/cluster health baseline. This is an integration/orchestration skill that sequences several existing tool-specific skills in the correct order and flags the handoff points between them — it does not restate their internals. Use when a user asks to "deploy a Kubernetes cluster on AKS from scratch," "set up a new AKS environment end to end," "build a production AKS cluster from a fresh Azure subscription," or "give me the full sequence to go from nothing to a working AKS cluster."
Other plugins' skills for the same job