Skip to content
Opsfolk
Kubernetes

Kubernetes Troubleshooting: Fix CrashLoopBackOff, OOMKilled and More

Fix CrashLoopBackOff, OOMKilled, ImagePullBackOff and Pending Pods: read the status, the exit code and the events, find the cause and apply the right fix.

admin25 min readUpdated

Kubernetes Troubleshooting: fix CrashLoopBackOff, OOMKilled and more. A Pod on worker-2 is OOMKilled at its memory limit and loops through back-off to its next restart.
On this page

It is 2 a.m., a deploy has just gone out, and kubectl get pods shows this:

NAME                   READY   STATUS             RESTARTS      AGE
web-7c9d8f6b5-x2kqp    0/1     CrashLoopBackOff   5 (82s ago)   6m
api-5f7b9c4d8-m8z4t    0/1     OOMKilled          3 (12s ago)   4m
worker-6d4f8b7c9-q7wv  0/1     ImagePullBackOff   0             3m
cron-1732860000-abcde  0/1     Pending            0             3m

Four Pods, four different problems. The good news: each of those words names the exact step of a Pod's life that failed, and each step has one place where Kubernetes writes down why. Troubleshooting is mostly knowing which place to read.

In the first five parts of Kubernetes Internals: How a Cluster Really Works, we followed a Pod from the API server to the scheduler, onto its node, behind a Service and onto a disk. This part turns that knowledge into a playbook: for each status you will meet, what it means, which command shows the cause, and how to fix it. Where the cause lives deep inside a component, we link back to the part that explains it.

New to the series? Start with Kubernetes API Server Explained: The Life of a Request. This part leans most on Kubelet and Container Runtimes: How Kubernetes Runs Pods.

What the STATUS Column Is Telling You

Definition: The STATUS column of kubectl get pods is not the Pod's phase. kubectl shows the most specific reason it can find: a container's waiting reason (CrashLoopBackOff, ImagePullBackOff), a container's last terminated reason (OOMKilled, Error, Completed), the Pod's own reason (Evicted), or Terminating when the Pod is being deleted. Only when there is nothing more specific does it show the phase: Pending, Running, Succeeded or Failed.

This matters, because the Pod's real phase can be different from what the column says. A Pod in CrashLoopBackOff is in the phase Running: its sandbox is up, one of its containers keeps dying. A Pod in ImagePullBackOff is Pending: no container has started. Each status points to a step:

  • Pending with no node: the scheduler has not placed it.
  • ContainerCreating, ErrImagePull, ImagePullBackOff, CreateContainerConfigError: it has a node, and the kubelet cannot start a container.
  • CrashLoopBackOff, OOMKilled, Error, Completed: a container started and exited.
  • Running with READY 0/1: the container runs, but its readiness probe fails.
  • Evicted, Terminating: the Pod is being removed, by the node or by you.

Each step of a Pod's start fails with its own status, from Pending and ContainerCreating to CrashLoopBackOff, OOMKilled and not Ready, and writes why in one place.

The RESTARTS column completes the picture. A count that keeps rising means a container starts and dies; a count of 0 on a Pod that is not Running means it never started at all.

Kubernetes Troubleshooting at a Glance

How to troubleshoot a broken Pod, step by step:

  1. Find the step. kubectl get pod <pod> -o wide gives the status, the restart count and the node. No node means the scheduler; a node means the kubelet or the app.
  2. Read the events. kubectl describe pod <pod> ends with the Pod's events, or list them alone, oldest first: kubectl events --for pod/<pod>. Warnings name most problems in plain words: FailedScheduling, FailedMount, Failed to pull image, BackOff.
  3. Read the last exit. In the same describe output, each container's Last State shows its last termination: the reason, the exit code, and when it started and finished.
  4. Read the logs from before the crash. kubectl logs <pod> --previous shows the output of the container instance that died, which is the one that knows why.
  5. Fix, then watch. Change the manifest, roll it out, and follow the new Pods with kubectl get pods -w and kubectl events --watch.
bash
kubectl get pod web-7c9d8f6b5-x2kqp -o wide
kubectl describe pod web-7c9d8f6b5-x2kqp
kubectl events --for pod/web-7c9d8f6b5-x2kqp
kubectl logs web-7c9d8f6b5-x2kqp --previous

Two habits save a lot of time. First, events do not last: the API server keeps them for one hour by default (--event-ttl), so on an old problem describe may show nothing, and the container's Last State and logs are what remain. Second, look at the whole namespace before one Pod: when every Pod of a Deployment fails the same way, the cause is in what they share, the image, a ConfigMap, a Secret, a node.

bash
# Every warning in the namespace, newest last
kubectl events --types=Warning

# Every Pod that is not Running or Succeeded, across the cluster
kubectl get pods -A --field-selector=status.phase!=Running,status.phase!=Succeeded

Read the Exit Code First

When a container has exited, its exit code is the shortest summary of why. kubectl describe pod shows it under Last State, and you can read it alone:

bash
kubectl get pod web-7c9d8f6b5-x2kqp \
  -o jsonpath='{.status.containerStatuses[0].lastState.terminated}'
json
{"containerID":"containerd://4f1c…","exitCode":1,"finishedAt":"2026-11-29T02:04:11Z","reason":"Error","startedAt":"2026-11-29T02:04:09Z"}
Exit code Meaning Usual cause in Kubernetes
0 The process ended normally A container whose main process finishes, under restartPolicy: Always: reason Completed
1 A generic error from the application An exception, a bad configuration, a dependency that refused: read the logs
2 Misuse of a shell builtin, or bad arguments A wrong flag or argument in command or args
126 The command was found but cannot be run A script without the execute bit, or a binary for the wrong architecture, run through a shell
127 Command not found A typo in command, or a binary the image does not have, run through a shell
128 + n Killed by signal n See the three below
137 SIGKILL (128 + 9) The kernel's OOM killer (reason OOMKilled), or the kubelet killing a container that did not stop in its grace period
139 SIGSEGV (128 + 11) A segmentation fault: native code, a library built for another libc
143 SIGTERM (128 + 15) The container was asked to stop and did: a deletion, a rollout, or a failed liveness probe

Exit code 137 does not always mean out of memory. Read the reason next to it: OOMKilled is the kernel; Error with 137 means something sent SIGKILL, most often the kubelet, after a liveness probe failed or a Pod's deletion, when the process ignored SIGTERM for the whole grace period.

CrashLoopBackOff: Find the Exit Before the Loop

CrashLoopBackOff is not an error of its own. It is the kubelet saying that a container keeps exiting and that it is waiting before the next restart: 10 seconds, then 20, 40, 80, 160, and at most five minutes. The kubelet part explains that back-off. Here, what matters is that the real error happened before the loop, in the last exit, and that the logs you want belong to the instance that died:

bash
kubectl describe pod web-7c9d8f6b5-x2kqp | grep -A6 'Last State'
kubectl logs web-7c9d8f6b5-x2kqp --previous
kubectl logs web-7c9d8f6b5-x2kqp -c migrate --previous   # one container of several

Without --previous, kubectl logs reads the current instance, which in back-off has not started yet, or has just started and printed nothing.

Then sort the cause by what you found:

The App Exits With an Error (exit code 1)

The logs say why: a missing environment variable, a configuration file it cannot parse, a database it cannot reach at startup. Fix the configuration, not the Pod: a restart replays the same start with the same input.

A common version of this is a dependency that is not ready: the app exits because the database is not up yet, and the loop goes on until it is. Make the app retry its connections instead of exiting, or wait for the dependency in an init container. A loop that ends by itself after a few minutes is often this.

The Command Does Not Exist (exit code 127, or StartError)

The command or args of the container names something the image does not have. Through a shell (sh -c "…") you get exit code 127 and not found in the logs. Without a shell, the runtime cannot start the process at all: on containerd the reason is StartError and the message says executable file not found in $PATH. Check what the image really contains:

bash
kubectl debug web-7c9d8f6b5-x2kqp -it --copy-to=web-debug --container=web -- sh
# then, inside the copy: ls -l /app, echo $PATH

exec format error in the logs is a close cousin: the binary was built for another CPU architecture, such as an arm64 image on an amd64 node. Build a multi-architecture image, or pin the Pods to nodes of the right architecture with kubernetes.io/arch.

The Container Exits With 0 (reason Completed)

A container that finishes its work and exits 0 is a success for a Job, and a crash for a Deployment, whose Pods have restartPolicy: Always. The usual cause is an entrypoint that starts the server in the background and returns, or a shell script without exec in front of its last command. The main process must stay in the foreground. A task that is meant to finish belongs in a Job or a CronJob.

The Liveness Probe Kills It (exit code 137 or 143)

If the events show Liveness probe failed and Container web failed liveness probe, will be restarted, the app may be fine, and the probe wrong:

  • It runs before the app is up. Give a slow starter a startup probe, which holds the liveness probe back until it succeeds, rather than a large initialDelaySeconds.
  • Its timeoutSeconds, 1 second by default, is shorter than the endpoint's answer under load.
  • It checks a dependency, such as the database, so one slow database restarts every Pod at once. A liveness probe should check the process itself; dependencies belong in the readiness probe, if anywhere.

The kubelet part's canvas plays this loop with each probe setting.

Keep a Crashing Container Up to Look Inside

A container that exits after a second gives you no time for kubectl exec. Copy the Pod with another command, and the copy stays up while you look around:

bash
kubectl debug web-7c9d8f6b5-x2kqp -it --copy-to=web-debug --container=web -- sh

The copy has the same image, environment and volumes, but runs sh instead of the app, and recent kubectl versions drop its probes unless you ask for them with --keep-liveness and --keep-readiness, so nothing kills it. Run the app's command by hand inside it and watch it fail. Delete the copy afterwards: it is a plain Pod that no controller owns.

Restarting the Loop After a Fix

You do not need to wait out the back-off. A fix to the Deployment's template rolls out new Pods, which start with no back-off. If the fix was outside the Pod, a Secret, a ConfigMap, a database, start fresh Pods by hand:

bash
kubectl rollout restart deployment/web
# or, for one Pod that a controller will replace
kubectl delete pod web-7c9d8f6b5-x2kqp

OOMKilled: When a Container Hits Its Memory Limit

OOMKilled means the Linux kernel killed the container because it went over its memory limit. The kubelet wrote the limit into the container's cgroup as memory.max; when the processes in that cgroup try to use more, the kernel's OOM killer ends them with SIGKILL. The container's last state says so:

    Last State:     Terminated
      Reason:       OOMKilled
      Exit Code:    137

With restartPolicy: Always, the kubelet restarts it, and if it is killed again you see the status alternate between OOMKilled and CrashLoopBackOff while RESTARTS climbs. On cgroup v2 nodes, the kubelet also sets memory.oom.group, so that an OOM kill takes all the processes of the container at once, not one worker process among several.

Three things are worth knowing before you fix it.

  • The request does not protect you. The memory request is what the scheduler reserved on the node; the limit is what the kernel enforces. A container that requests 256 MiB and has a 512 MiB limit is killed at 512, however much memory the node has free.
  • A bigger limit only buys time against a leak. If memory keeps growing, a larger limit moves the kill later; it does not prevent it.
  • Some runtimes size themselves wrong. The JVM, Node.js and Go each manage their own heap. If they do not know the container's limit, the heap grows past it, and the kernel kills the process before the garbage collector runs.

The canvas below runs ten minutes of a container whose memory grows at a steady rate. Change the limit and the growth, and watch when the kernel kills it and how long the kubelet waits each time.

Ten minutes of one container whose memory grows from 120 MiB at a steady rate, against its memory limit. When it reaches the limit the kernel kills it, OOMKilled with exit code 137, and the kubelet waits 10, 20, then 40 s before each restart. At a 512 MiB limit and 150 MiB a minute it is killed at 2:37, 5:24 and 8:20. Doubling the limit to 1024 MiB only moves the first kill to 6:02; with no growth it is never killed. The request, half the limit, does not protect it. The controls set the limit and the growth.

A container's memory and its limit

At a 512 MiB limit and 150 MiB a minute, the container is killed at 2:37, 5:24 and 8:20, and spends 10, 20 and 40 seconds in back-off between runs. Doubling the limit to 1024 MiB moves the first kill to 6:02, and that is all it does. Set the growth to 0, a container that uses what it needs and stops there, and no limit above 120 MiB ever kills it: the shape of the line, not its height, tells you whether to raise the limit or fix the code.

Measure Before You Change the Limit

Find out how much memory the container really uses, and whether it keeps growing:

bash
kubectl top pod api-5f7b9c4d8-m8z4t --containers

kubectl top shows the working set, the memory the kernel counts against the limit, as the metrics server last sampled it. For a trend, graph the cAdvisor metric container_memory_working_set_bytes in Prometheus over a few hours, next to the limit (kube_pod_container_resource_limits from kube-state-metrics). A flat line that sits just under the limit needs a higher limit; a slope needs a fix.

Fixing OOMKilled

What you see Fix
Usage is steady and just above the limit Raise the limit, and the request with it, to the measured peak plus a margin
Usage climbs until the kill, after every restart A leak: profile the app; a higher limit only spaces out the kills
Killed at startup, or on one kind of request A burst: load less at once, stream large files, or give that work its own Pods
A JVM is killed while its heap looks fine Size the heap from the limit: -XX:MaxRAMPercentage=75
A Node.js process is killed Set --max-old-space-size below the limit, leaving room for memory outside the heap
A Go process is killed Set GOMEMLIMIT a little under the limit, so the garbage collector works harder before the kernel steps in

An init container can be OOMKilled too: the status then reads Init:OOMKilled or Init:CrashLoopBackOff. Its limit is its own, not the app's. To size requests and limits from real numbers, with the QoS class and what each node can actually hold, the Kubernetes resource calculator does the arithmetic.

OOMKilled or Evicted?

There is a second way memory ends a Pod, and it is fixed differently. When the node runs short of memory, before any container reaches its limit, the kubelet's eviction manager evicts Pods to protect the node: they get the phase Failed and the reason Evicted, and their controller creates replacements, usually on another node. Pods that use more than they requested go first, which is why BestEffort Pods, which request nothing, are evicted first.

Status:   Failed
Reason:   Evicted
Message:  The node was low on resource: memory. …
OOMKilled Evicted
Who acts The kernel, inside one container's cgroup The kubelet, for the whole node
Trigger The container reached its own memory limit The node's memory.available fell under the eviction threshold
What happens The container restarts in the same Pod The Pod ends; its controller makes a new one
Fix The container's limit or its memory use Requests that reflect real use, so the node is not overcommitted

A container over its own memory limit is OOMKilled by the kernel and restarts in the same Pod; a node short of memory makes the kubelet evict Pods, which end and are replaced.

If the node runs out before the kubelet acts, the kernel's own OOM killer chooses a process on the whole node, guided by each container's QoS class. That container also shows OOMKilled, though it was under its limit: compare its usage with its limit, and look at the node's MemoryPressure condition, to tell the two apart.

ImagePullBackOff and ErrImagePull

ErrImagePull is a pull that just failed; ImagePullBackOff is the kubelet waiting before it tries again, with the same 10 seconds to five minutes back-off. The event holds the registry's answer, and that answer names the fix:

bash
kubectl events --for pod/worker-6d4f8b7c9-q7wv | grep -i pull
The event says Cause Fix
not found, manifest unknown A typo in the name or the tag, or a tag that was never pushed Check the reference against the registry
pull access denied, 401 Unauthorized, 403 Forbidden A private image and no credentials, or the wrong ones Add imagePullSecrets
429 Too Many Requests, toomanyrequests The registry's rate limit, often Docker Hub's for anonymous pulls Authenticate, or mirror the image to your own registry
i/o timeout, no such host The node cannot reach the registry DNS, a proxy, a firewall or a private endpoint on the node's network
no match for platform in manifest The image has no variant for the node's architecture Build for that architecture, or schedule elsewhere

For a private registry, create a Secret of type docker-registry and attach it to the Pod, or to its ServiceAccount, so every Pod that uses that account gets it:

bash
kubectl create secret docker-registry regcred \
  --docker-server=registry.example.com \
  --docker-username=ci-bot \
  --docker-password="$REGISTRY_TOKEN"

kubectl patch serviceaccount default \
  -p '{"imagePullSecrets": [{"name": "regcred"}]}'

The Secret must be in the Pod's namespace. A status of InvalidImageName is caught before any pull: the reference itself is malformed, with an uppercase letter or a stray space.

Pending: The Pod Has No Node

A Pod that is Pending with an empty NODE column has not been scheduled. The scheduler writes why in a FailedScheduling event, one reason per group of nodes:

Warning  FailedScheduling  0/3 nodes are available: 1 node(s) had untolerated taint {node-role.kubernetes.io/control-plane: }, 2 Insufficient memory. preemption: 0/3 nodes are available: 3 No preemption victims found for incoming pod.

Read it as a sum: every node is excluded, each for a reason. Insufficient cpu or memory means the requests are larger than any node has free, so lower the request or add nodes; an untolerated taint, a node selector or an affinity that no node matches each point to the Pod's spec. How the Kubernetes Scheduler Works goes through every filter and its message.

One more reason has its own wording: pod has unbound immediate PersistentVolumeClaims. The Pod waits for its storage, not for a node. Check the claim with kubectl describe pvc, and see Kubernetes Persistent Storage for how a claim gets its volume.

A Pod that is Pending with a node is past the scheduler: it waits on its node, and the next section applies.

ContainerCreating and CreateContainerConfigError

A Pod that stays in ContainerCreating has a node, and the kubelet is stuck before the first container starts: on its volumes or on its sandbox. The events say which:

  • FailedMount, MountVolume.SetUp failed for volume "config" : configmap "web-config" not found: a ConfigMap or Secret that a volume names does not exist in the namespace. Create it, or mark the volume optional: true.
  • FailedAttachVolume, Multi-Attach error for volume … Volume is already exclusively attached to one node: a ReadWriteOnce disk is still attached to the node the old Pod ran on. It is released once that Pod is fully gone; the storage part explains the attach-detach controller and its six-minute wait.
  • FailedCreatePodSandBox, failed to setup network for sandbox: the CNI plugin could not give the Pod an IP address. Look at the CNI's Pods on that node, and at its IP pool.

CreateContainerConfigError is a step later: the kubelet has the image, but cannot build the container's configuration. Almost always, an environment variable names a Secret or ConfigMap, or a key in one, that does not exist:

Warning  Failed  Error: couldn't find key DATABASE_URL in Secret shop/web-env

Create the key, fix the name in secretKeyRef or configMapKeyRef, or set optional: true if the app can live without it. No restart is needed: the kubelet retries on its own, and the container starts once the key exists.

Running but Not Ready

STATUS Running with READY 0/1 means the container is up and its readiness probe fails. Nothing restarts: the Pod is simply kept out of its Services' endpoints, so it receives no traffic.

bash
kubectl events --for pod/web-7c9d8f6b5-x2kqp | grep -i readiness
# Readiness probe failed: HTTP probe failed with statuscode: 503

Check the probe against the app: the path, the port (the container port, not the Service's), the scheme, and the timeout. A probe that hits a path the app does not serve, or a port it listens on only after a long warm-up, keeps a healthy Pod out of service forever.

The same symptom, seen from the client, is a Service with no endpoints: requests to it are refused or time out. Compare the Service's selector with the Pods' labels, and list what the Service actually sends to:

bash
kubectl get svc web -o jsonpath='{.spec.selector}'
kubectl get pods -l app=web --show-labels
kubectl get endpointslices -l kubernetes.io/service-name=web

An empty EndpointSlice means no ready Pod matches the selector; endpoints listed as not ready mean the readiness probes fail; endpoints that are ready while requests still fail point at the targetPort, which must be the port the container listens on. Kubernetes Services, DNS and Ingress Explained follows a request through each of those steps.

Evicted, Completed and Terminating

  • Evicted: the node ran short of memory, disk or PIDs, and the kubelet removed the Pod. The message names the resource. An evicted Pod object stays behind, with the phase Failed, until it is garbage collected or deleted; its replacement is already running elsewhere. Clean them up with kubectl delete pods --field-selector=status.phase=Failed, after reading why: repeated DiskPressure evictions usually mean logs or emptyDir volumes filling the node's disk.
  • Completed: a container exited 0. Normal for a Job's Pod, a crash for a Deployment's (see above).
  • Terminating for minutes: the Pod was deleted, and something holds it. Either a finalizer that no controller removes, or a node that is gone, so no kubelet reports the Pod stopped.
bash
kubectl get pod web-7c9d8f6b5-x2kqp -o jsonpath='{.metadata.finalizers}'
kubectl get node worker-2

Remove a finalizer only when you know what it was waiting for, since it exists to stop a deletion from leaving something behind. kubectl delete pod --grace-period=0 --force removes the object without waiting for the kubelet; on a node that may still be running the container, that can leave two copies of a StatefulSet's Pod writing to the same disk.

Debugging a Container With No Shell: kubectl debug

Many production images are distroless or scratch: no shell, no ls, no curl, so kubectl exec has nothing to run. Ephemeral containers, stable since Kubernetes 1.25, add a temporary container with the tools you need to a Pod that is already running, without restarting it:

bash
kubectl debug -it web-7c9d8f6b5-x2kqp --image=busybox:1.36 --target=web

--target puts the debug container in the process namespace of the container web, so ps shows the app's processes, and its filesystem is reachable at /proc/<pid>/root. The debug container cannot be removed afterwards: it stays in the Pod's spec, stopped, until the Pod is replaced. Adding one needs the permission to update pods/ephemeralcontainers, which many clusters give to fewer people than pods/exec.

kubectl debug has two other forms:

bash
# A copy of the Pod with another image, here a debug build of the app
kubectl debug web-7c9d8f6b5-x2kqp --copy-to=web-debug --set-image=web=registry.example.com/web:1.8-debug

# A Pod on a node, with the node's filesystem at /host
kubectl debug node/worker-2 -it --image=busybox:1.36

The node form runs in the node's network, PID and IPC namespaces, which makes it a way onto a node with no SSH. With the default profile it is not privileged, so some reads of the host fail; --profile=sysadmin gives it a privileged container, and then chroot /host gives you the node's own shell and tools, such as journalctl -u kubelet and crictl. Delete the debugger Pod when you are done.

For network problems, a throwaway Pod in the same namespace tests DNS and connections the way the app sees them:

bash
kubectl run net-test --rm -it --image=busybox:1.36 --restart=Never -- sh
# nslookup web; wget -qO- -T 2 http://web:80/healthz

When the Node Is the Problem

If every failing Pod is on the same node, look at the node before the Pods:

bash
kubectl get pods -A -o wide --field-selector spec.nodeName=worker-2
kubectl describe node worker-2

In describe node, read the Conditions and the Allocated resources:

  • Ready is False or Unknown: the kubelet is not reporting. Unknown after 50 seconds without a Lease renewal means the node is unreachable or its kubelet is down; False comes with a message, such as PLEG is not healthy, which usually means the container runtime is not answering.
  • MemoryPressure, DiskPressure, PIDPressure is True: the kubelet is evicting Pods and the node is tainted, so no new Pods arrive.
  • Allocated resources near 100% of requests: the node is full by reservation, and new Pods go Pending.

On the node itself, through SSH or kubectl debug node/…, the kubelet's journal and the runtime say what the API server cannot: journalctl -u kubelet --since "15 min ago", crictl ps -a, systemctl status containerd. The kubelet part walks through each of them, and what a node does when its Lease stops.

A Troubleshooting Checklist

Symptom First command Usual cause Fix
Pending, no node kubectl describe pod (FailedScheduling) Requests too large, taint, selector, affinity, unbound PVC Lower requests, add nodes, fix the spec
ContainerCreating for minutes kubectl events --for pod/<pod> Missing ConfigMap or Secret in a volume, volume still attached, CNI Create the object, wait for detach, fix the CNI
ErrImagePull, ImagePullBackOff kubectl events --for pod/<pod> Wrong name or tag, no credentials, rate limit Fix the reference, add imagePullSecrets, mirror
CreateContainerConfigError kubectl describe pod A Secret or ConfigMap key that does not exist Create the key or fix the reference
CrashLoopBackOff kubectl logs --previous App error, missing command, exit 0, liveness probe Read the exit code, then fix the cause
OOMKilled, exit 137 kubectl top pod --containers Limit below real use, a leak, an unsized heap Raise the limit to measured use, fix the leak, size the heap
Running, 0/1 ready kubectl events --for pod/<pod> Readiness probe path, port or timeout Fix the probe or the app's health endpoint
Service answers nothing kubectl get endpointslices -l kubernetes.io/service-name=<svc> Selector mismatch, not ready, wrong targetPort Fix labels, readiness or ports
Evicted kubectl describe node Node memory or disk pressure Honest requests and limits, log rotation, bigger nodes
Terminating for minutes kubectl get pod -o jsonpath='{.metadata.finalizers}' A stuck finalizer or a lost node Fix the finalizer's controller; force only when the node is gone

Key Takeaways

  • The STATUS column shows the most specific reason kubectl can find, and each one names a step: scheduling, the kubelet's setup, the container's run, or readiness.
  • Always read in the same order: the events, the container's Last State and exit code, then kubectl logs --previous. Events last one hour by default.
  • CrashLoopBackOff is the kubelet waiting between restarts; the cause is the last exit. Exit code 1 is the app, 127 a missing command, 0 a process that ends, 137 or 143 often a liveness probe.
  • OOMKilled is the kernel enforcing a container's memory limit, exit code 137. The request does not protect from it, and a higher limit only delays it when memory keeps growing.
  • Evicted is the kubelet protecting the node: the Pod ends and is replaced, and the fix is honest requests, not a higher limit.
  • ImagePullBackOff, CreateContainerConfigError and ContainerCreating all have their cause written in the events, in the registry's or the kubelet's own words.
  • For images with no shell, kubectl debug adds an ephemeral container, copies a Pod with another command or image, or opens a shell on the node.

FAQ

What does CrashLoopBackOff mean in Kubernetes?

It means a container in the Pod keeps exiting, and the kubelet is waiting before it restarts it again. The wait doubles after each exit, from 10 seconds up to five minutes. It is not the error itself: the cause is in the container's last exit, shown under Last State in kubectl describe pod, and in the logs of the instance that died, shown by kubectl logs <pod> --previous.

How do I fix OOMKilled in Kubernetes?

First measure the container's memory with kubectl top pod --containers or the container_memory_working_set_bytes metric over time. If it is steady and slightly above the limit, raise the memory limit and request to the measured peak plus a margin. If it climbs until every kill, it is a leak to fix in the application. For the JVM, Node.js and Go, also size the runtime's heap from the container's limit.

What is exit code 137 in Kubernetes?

Exit code 137 is 128 plus 9: the process was killed with SIGKILL. With the reason OOMKilled, the kernel killed it for going over its memory limit. With the reason Error, something else sent the signal, usually the kubelet, after a liveness probe failed or a deletion, when the process did not stop on SIGTERM within its grace period.

How do I see the logs of a crashed Pod?

Use kubectl logs <pod> --previous, with -c <container> for a Pod with several containers. It shows the output of the last terminated instance of the container, which is the one that crashed. Without --previous, you read the current instance, which during a back-off has not started yet.

What is the difference between ImagePullBackOff and ErrImagePull?

ErrImagePull is shown right after a pull fails. ImagePullBackOff follows, while the kubelet waits before it tries the pull again, with a back-off that grows to five minutes. Both have the same cause, written in the Pod's events: a wrong name or tag, missing credentials for a private registry, a rate limit, or a registry the node cannot reach.

Why is my Pod stuck in Pending?

If its NODE column is empty, the scheduler found no node for it: the FailedScheduling event lists why each node was excluded, such as insufficient CPU or memory, a taint, a node selector or affinity, or an unbound PersistentVolumeClaim. If it has a node, it is waiting on that node, for its volumes, its network or its images: read the Pod's events.

How do I restart a Pod in CrashLoopBackOff?

Fix the cause first, since a restart replays the same start. A change to the Deployment rolls out new Pods with no back-off. If the fix was outside the Pod, such as a Secret or a database, run kubectl rollout restart deployment/<name>, or delete the Pod and let its controller create a new one.

How do I debug a container that has no shell?

Add an ephemeral container with kubectl debug -it <pod> --image=busybox --target=<container>: it shares the target's process namespace, without restarting the Pod. To change the command of a container that crashes too fast to inspect, run a copy with kubectl debug <pod> -it --copy-to=<name> --container=<container> -- sh.

What's Next

You can now read a broken Pod the way Kubernetes wrote it down: the status names the step, the events and the last state name the cause. Every one of those records was written by a component reconciling an object, the scheduler, the kubelet, the EndpointSlice controller. In the next part of Kubernetes Internals: How a Cluster Really Works, etcd in Kubernetes: Raft, Quorum, Backup and Restore, we look at where those objects live: how etcd stores the cluster's state, keeps its copies in agreement with Raft, and how to back it up and restore it when things go wrong.


Comments

No comments yet.