FDE Times dataFDE jobs open 911▼17 Change in open roles over 7 days, like-for-like: roles from companies we started tracking this week are left outNew in 7 days 66Companies hiring 200Remote-friendly 24%Median US pay $200kTop hirer Databricks 106
中文VI

The newspaper of the Forward Deployed Engineer

Guides

A pod that keeps restarting with empty logs is not a dead end

A five-step kubectl routine separates application bugs from infrastructure faults when a customer's cluster throws CrashLoopBackOff, OOMKilled or DNS errors.

A doctor in a white coat leans in to hold a stethoscope to a swollen orange container, beneath a circular arrow, amid a stack of blue and white containers.
ShareLinkedInFacebookX

In brief

  • Every diagnostic session should start with kubectl describe pod: check State, Last State, the restart count and the Events section.
  • Exit code 137 with Reason OOMKilled means the container exceeded its memory limit and received SIGKILL; logs from the current run are almost useless, so add --previous.
  • When you suspect the network, run nslookup kubernetes.default from a dnsutils pod before blaming the application.
Bar chart of how long kubelet waits before each pod restart: 10, 20, 40, 80 and 160 seconds. By the sixth restart, the wait hits the 300-second (5-minute) cap. That bar is shaded orange.
Backoff delay doubles after each crash until it reaches a five-minute cap. So a pod that is not up straight after you fix a config does not mean the fix is wrong. Source: Site24x7, as cited in the article.

The customer’s pod has restarted 14 times. You type kubectl logs and get back an empty screen. This is where many engineers start guessing, when the answer is usually already sitting in two commands they have not yet run.

This guide builds a five-step kubectl diagnostic routine for three incidents that come up often when deploying into a customer’s cluster: CrashLoopBackOff, OOMKilled, and network or DNS failures. Each step comes with a command, what to check once it has run, and a mistake people commonly make.

Why this skill matters for FDEs is simple. Picture yourself in front of a cluster that is not yours, with nothing but a terminal, and an operations team waiting to see whether you can tell an application fault from an infrastructure one.

What do you need?

You need kubectl pointed at a cluster, ideally a test cluster of your own before you touch a real one, plus permission to read pods, logs and events in the namespace in question. The examples below use <pod-name> and <namespace> as placeholders; replace them with real values. Some Service names in the network step are illustrative only.

Step 1: describe first, guess later

The first command is always:

kubectl describe pod <pod-name> -n <namespace>

The Kubernetes Debug Pods documentation recommends starting with the state of the containers: are they all Running, and have there been any recent restarts? After running the command, check three places: the State line, the Last State line and the Restart Count.

At this point you need to separate two cases that are often confused. A pod stuck in Pending has not been scheduled onto any node, so its container has never run and there are no logs to read. CrashLoopBackOff is different: the pod is on a node, the container has run, it just keeps dying.

If it really is CrashLoopBackOff, scroll down to Events. Devtron’s guide advises checking whether any probe (liveness, readiness, startup) is failing there. That is why Events should be read before opening the code: if a probe is the culprit, the answer may lie in the probe configuration rather than in the application.

Step 2: why the logs are empty, and how to get the logs of the run that died

The empty screen in the opening has a simple explanation. When a pod is crash-looping, the logs of the current run often contain nothing yet. The information you need sits in the container that just died, and the --previous flag prints the logs of the previous run if they still exist:

kubectl logs <pod-name> --previous -n <namespace>

Once it has run, look for the last lines before the process exited: a stack trace, a missing environment variable, a refused database connection.

It also pays to understand the restart rhythm so you do not jump to conclusions. According to Site24x7, the kubelet typically waits 10 seconds before the first restart, then 20 seconds, 40 seconds and so on, up to a maximum of 5 minutes. If the wait keeps doubling, after only about five crashes (10, 20, 40, 80, 160 seconds) the next one hits the 300-second ceiling.

This rhythm explains a very common situation. If you fix a config and the pod does not come up straight away, the fix is not necessarily wrong; the pod may simply be waiting out its backoff.

Step 3: what does exit code 137 mean?

Go back to the describe output and find the container’s Last State block. The snippet below is a trimmed illustration that keeps only the three lines worth reading:

Last State:     Terminated
  Reason:       OOMKilled
  Exit Code:    137

If you see exactly Reason: OOMKilled and Exit Code: 137, your application did not crash on its own; it was killed. The Kubernetes documentation explains that a container using more memory than its limit can be killed and, if it is allowed to restart, the kubelet will start it again.

This cycle of dying and coming back is exactly what makes OOMKilled look identical to CrashLoopBackOff. For fuller data, export the pod as YAML:

kubectl get pod <pod-name> -n <namespace> -o yaml

In the official example, the lastState.terminated field has exitCode: 137 and reason: OOMKilled.

CAST AI breaks 137 down as 128 + 9, meaning the container received SIGKILL (signal 9). The kernel’s OOM killer sends this signal when a container exceeds its cgroup memory limit. But read carefully: 137 on its own only says the container was SIGKILLed; the Reason line is what says memory was the cause, so do not conclude OOM from the exit code alone.

The most common mistake at this step is hunting for a bug in the code. Once Reason says OOMKilled, what you need to take to the customer is the memory limit compared with what the application actually uses.

Step 4: when the image has no shell to exec into

Many customers run minimal images, such as distroless, so kubectl exec has no shell or tools to work with. Exec is also useless once the container has crashed. The Kubernetes documentation points to ephemeral containers for exactly these situations: you temporarily attach a container with a full set of debugging tools to the troubled pod, using kubectl debug.

The command skeleton below is abbreviated and only shows where to start; the flags for choosing the image and target container should be taken from the Ephemeral Containers documentation for your cluster’s version:

# abbreviated skeleton, not enough flags to run
kubectl debug <pod-name> -n <namespace> ...

Before using it on a customer’s cluster, ask whether their security policy allows ephemeral containers to be added.

Step 5: is the fault in the network or the application?

When the application reports that it cannot connect to another service, you need to prove DNS works before changing anything. The Debugging DNS Resolution documentation explains how to run a dnsutils pod (a sample manifest is in that document), then run:

kubectl exec -i -t dnsutils -- nslookup kubernetes.default

If the command returns an address, cluster DNS is working. If not, check CoreDNS in the kube-system namespace:

kubectl get pods -n kube-system -l k8s-app=kube-dns
kubectl logs -n kube-system -l k8s-app=kube-dns

Confirm that these pods are Running and that their logs are not full of errors.

If cluster DNS works but a particular Service does not resolve, the Debug Services documentation suggests trying the short name, then the namespaced name, then the fully qualified domain name. The example below assumes a Service called hostnames in the default namespace and a cluster using the default domain:

kubectl exec -i -t dnsutils -- nslookup hostnames.default
kubectl exec -i -t dnsutils -- nslookup hostnames.default.svc.cluster.local

If the name resolves but traffic still does not arrive, review the ingress NetworkPolicies applied to the target pod. The Debug Services documentation is clear that ingress rules which may affect traffic into the pod need to be checked, so do not skip this step just because DNS is fine.

Why do the first ten minutes on a customer site matter?

Picture the first morning after you deploy an agent onto a bank’s cluster. The pod keeps restarting and the operations team asks whether your product is to blame.

If within ten minutes you can point to Reason: OOMKilled and the memory limit they set, or show that nslookup fails even for kubernetes.default, the conversation shifts from blame to fixing it together.

When reading FDE job descriptions, look out for requirements around debugging deployments on customer infrastructure. On your CV, do not just write “knows Kubernetes”. Write a specific line, such as: diagnosed an OOMKilled incident on a customer’s cluster, identified the memory limit as the cause and proposed a new value.

Next time a pod dies, do not open the code first. Run describe, then logs --previous, and let the cluster tell you where the fault lies.

Was this article useful?

Use with your AI assistantAsk Claude ↗Ask ChatGPT ↗
9 sources
Read next on the roadmap · Stage 2: Broad engineeringA bank on ISO 20022 can still feed your model dirty dataLegacy internal systems keep pouring free text into the new structured messages; the first week's job is measuring how much before a model learns from it.