Skip to content
TrustHappens
Observability & Cloud

How to Troubleshoot Kubernetes Production Incidents

A triage order and the exact kubectl commands for CrashLoopBackOff, OOMKilled, failing probes, DNS errors and node pressure in production Kubernetes clusters.

TrustHappens Editorial TeamPublished 6 min read
Illustration for Observability & Cloud
On this page

Kubernetes incidents rarely announce their cause. The alert says error rate is up or a pod keeps restarting, and the person on call has to work out whether the problem is the code, the configuration, the cluster or something the service depends on. The fastest responders are not the ones who know the most commands. They are the ones who check things in a consistent order and stop guessing early.

This article gives you that order, then walks through the failure modes that cause most production pages: CrashLoopBackOff, OOMKilled, misbehaving probes, DNS failures and node pressure. Every command here is standard kubectl; replace the namespace and names with your own.

A triage order for Kubernetes incidents

Work from the outside in. Start with impact, then narrow to the workload, then the pod, then the node.

  1. Confirm impact and scope. Which users, which endpoints, since when? Check your RED dashboards (rate, errors, duration) before touching the cluster.
  2. Ask what changed. Most incidents follow a change: a deploy, a config or secret update, a node pool upgrade, a traffic shift. Check rollout history first.
  3. Check workload health. Are replicas available? Are pods restarting, pending or not ready?
  4. Read events and pod state. describe and events usually name the failure directly.
  5. Read logs, including the previous container. The crash reason is often in the logs of the container that already died.
  6. Check dependencies. DNS, databases, downstream services, cloud APIs.
  7. Check the node. Pressure conditions, evictions, resource exhaustion.
  8. Mitigate, then diagnose. Roll back or scale first if it restores service; root cause can wait until users are no longer affected.

First five minutes: the commands

These commands answer the first questions in the triage order.

Initial triage
# What changed recently?
kubectl rollout history deployment/checkout -n shop
kubectl get events -n shop --sort-by=.lastTimestamp | tail -n 30

# Is the workload healthy?
kubectl get deployment checkout -n shop
kubectl get pods -n shop -l app=checkout -o wide

# Why is a specific pod unhappy?
kubectl describe pod checkout-7d9f8c6b5-x2k4q -n shop
kubectl logs checkout-7d9f8c6b5-x2k4q -n shop --previous

# Resource usage (requires metrics-server)
kubectl top pod -n shop -l app=checkout
kubectl top node

The -o wide flag shows which node each pod runs on. If all the failing pods share one node, the problem is probably the node, not the application.

If rollout history shows a deploy at the start of the incident, kubectl rollout undo deployment/checkout -n shop returns to the previous revision while you investigate.

CrashLoopBackOff

CrashLoopBackOff is not an error in itself. It means a container keeps exiting and the kubelet is waiting before it restarts it again. By default, the wait grows exponentially (10 seconds, 20, 40 and so on) up to a cap of five minutes, and the back-off resets once the container runs for ten minutes without trouble. The real question is why the container exits.

Start with the last termination state and the previous logs:

Why did it exit?
kubectl get pod checkout-7d9f8c6b5-x2k4q -n shop \
  -o jsonpath='{.status.containerStatuses[*].lastState.terminated}'

kubectl logs checkout-7d9f8c6b5-x2k4q -n shop -c app --previous

The exit code narrows things down quickly:

Exit codeUsual meaningWhere to look
1 or another small numberThe application exited with an errorPrevious logs: missing config, failed migration, bad credentials
137Killed with SIGKILL (128 + 9)Usually OOMKilled; also a liveness probe kill that outlived the grace period
143Terminated with SIGTERM (128 + 15)Normal shutdown, or a liveness probe restart
127Command not foundWrong entrypoint or image

Common causes of a crash loop after a deploy are a missing environment variable or secret, a config file that fails validation, a dependency that is unreachable at startup, or an image built for the wrong CPU architecture. If the container exits too fast to inspect, kubectl debug can start a copy of the pod with a different command, or attach an ephemeral debug container that shares the pod's process namespace:

kubectl debug -it checkout-7d9f8c6b5-x2k4q -n shop \
  --image=busybox:1.36 --target=app

OOMKilled

When a container exceeds its memory limit, the kernel's OOM killer terminates it and Kubernetes records the reason as OOMKilled with exit code 137. kubectl describe pod shows it under Last State.

Two different situations produce memory kills, and they need different fixes:

  • Container limit reached. The container used more than its own limits.memory. Either the limit is too low for the real workload, or the application has a leak or an unbounded cache.
  • Node out of memory. The node itself ran short, and the kubelet evicted pods or the kernel killed processes. This shows up as evictions and node conditions, covered below.

Look at the trend before raising limits. If memory climbs steadily until the kill, raising the limit only delays the next restart. A PromQL query against cAdvisor and kube-state-metrics data shows both the pattern and the restarts:

Memory and restarts (PromQL)
# Working-set memory as a fraction of the limit, per container
max by (namespace, pod, container) (container_memory_working_set_bytes{namespace="shop", container!=""})
/
max by (namespace, pod, container) (kube_pod_container_resource_limits{namespace="shop", resource="memory"})

# Containers whose last termination was an OOM kill
kube_pod_container_status_last_terminated_reason{reason="OOMKilled"} == 1

# Restarts in the last hour
increase(kube_pod_container_status_restarts_total{namespace="shop"}[1h]) > 3

Probes that cause outages

Probes are meant to protect availability, but a badly designed probe can create an incident on its own. Each probe type does something different:

  • Liveness probe: if it fails, the kubelet restarts the container.
  • Readiness probe: if it fails, the pod is removed from Service endpoints and stops receiving traffic, but is not restarted.
  • Startup probe: while it has not yet succeeded, liveness and readiness checks are held off. Use it for slow-starting applications instead of a long initialDelaySeconds.

The most damaging pattern is a liveness probe that checks dependencies. If the database is slow, every pod's liveness check fails, every pod restarts, and a partial slowdown becomes a full outage with cold caches. Liveness should answer one question: is this process stuck beyond recovery? Readiness is the right place to say "do not send me traffic right now."

Safer probe configuration
startupProbe:
  httpGet:
    path: /healthz
    port: 8080
  periodSeconds: 5
  failureThreshold: 30
livenessProbe:
  httpGet:
    path: /healthz
    port: 8080
  periodSeconds: 10
  timeoutSeconds: 2
  failureThreshold: 3
readinessProbe:
  httpGet:
    path: /ready
    port: 8080
  periodSeconds: 5
  timeoutSeconds: 2
  failureThreshold: 2

When probes are failing, kubectl describe pod shows Unhealthy events with the probe type and the response. Check the timeout too. A one-second default timeout on an endpoint that does real work fails as soon as the service is under load.

DNS failures

DNS problems show up as intermittent timeouts, no such host errors or slow first requests, and they are easy to blame on something else. Test resolution from inside the cluster, using the approach in the Kubernetes DNS debugging guide:

DNS checks
# Run a pod with DNS tools, then test cluster and external names
kubectl apply -f https://k8s.io/examples/admin/dns/dnsutils.yaml
kubectl exec -it dnsutils -- nslookup kubernetes.default
kubectl exec -it dnsutils -- cat /etc/resolv.conf

# Is CoreDNS healthy?
kubectl get pods -n kube-system -l k8s-app=kube-dns
kubectl logs -n kube-system -l k8s-app=kube-dns --tail=100
kubectl get endpointslices -n kube-system -l kubernetes.io/service-name=kube-dns

Things to look for: CoreDNS pods restarting or throttled on CPU, a NetworkPolicy that blocks egress to the DNS service on port 53 (UDP and TCP), and query volume amplified by the default ndots:5 search behaviour, where an external name such as api.example.com is first tried against every cluster search domain. Using fully qualified names with a trailing dot, or lowering ndots in the pod's dnsConfig, cuts that amplification.

Node pressure and evictions

When a node runs short of memory, disk or process IDs, the kubelet sets a pressure condition and begins evicting pods to reclaim resources. Evicted pods show a status of Evicted and a message naming the resource.

Node checks
kubectl describe node ip-10-0-12-34.ec2.internal | sed -n '/Conditions:/,/Addresses:/p'
kubectl get pods -A --field-selector=status.phase=Failed
kubectl get events -A --field-selector=reason=Evicted

In the node conditions, look for MemoryPressure, DiskPressure or PIDPressure set to True. The kubelet also taints the node so new pods avoid it.

When choosing what to evict, the kubelet considers whether a pod's usage exceeds its requests, the pod's priority, and its usage relative to its requests. Pods with no requests at all (the BestEffort QoS class) are therefore usually the first to go. The lasting fixes are accurate resource requests, sensible limits, log rotation and image garbage collection to prevent disk pressure, and enough headroom in node sizing.

Pending pods and image pulls

Two more states come up often during incidents. A pod stuck in Pending usually has a FailedScheduling event that explains why: insufficient CPU or memory, no node matching a selector or affinity, an untolerated taint, or an unbound PersistentVolumeClaim. ImagePullBackOff and ErrImagePull mean the image could not be fetched: a wrong tag, a missing pull secret, or a registry problem. In both cases, kubectl describe pod states the reason.

Correlate before you conclude

kubectl tells you what Kubernetes sees. It does not tell you what your users experienced or which downstream call made a request slow. Pair cluster state with application telemetry: traces show whether latency is in your code, a database or a third-party API, and logs correlated to traces show the error for a specific failed request. Recording deploys as events alongside metrics makes the "what changed?" question quick to answer.

After the incident

Once service is restored, capture what helped and what slowed you down. Good follow-ups after a Kubernetes incident are usually small and specific: a missing alert on restart count, a probe that checked a dependency, a memory limit set without data, a runbook step that was wrong. Blameless postmortems that produce a short list of owned actions do more for the next incident than a long document nobody reads.

Frequently asked questions

What does CrashLoopBackOff actually mean?

A container keeps exiting and the kubelet is waiting before restarting it again, with an exponentially increasing delay capped at five minutes by default. Check the exit code and run kubectl logs with --previous to find out why it exits.

Why does an OOMKilled container show exit code 137?

Exit code 137 means the process received SIGKILL (128 plus signal 9). The kernel OOM killer sends SIGKILL when a container exceeds its memory limit, and Kubernetes records the reason as OOMKilled.

Should a liveness probe check the database?

Usually not. If a shared dependency slows down, every pod fails liveness and restarts at once, turning a partial problem into an outage. Use readiness to stop traffic and keep liveness for detecting a stuck process.

How do I tell a node problem from an application problem?

Run kubectl get pods -o wide and see whether failing pods share a node. Then check node conditions with kubectl describe node for memory, disk or PID pressure, and look for Evicted pods.

References

  1. Kubernetes: Debug Pods
  2. Kubernetes: Pod Lifecycle
  3. Kubernetes: Configure Liveness, Readiness and Startup Probes
  4. Kubernetes: Debugging DNS Resolution
  5. Kubernetes: Node-pressure Eviction
  6. Kubernetes: Resource Management for Pods and Containers

Share this article

Stay Ahead of What Matters.

Practical guides on observability & cloud and more, delivered to your inbox.