The knowledge base / All cheat sheets
● Always in your toolkitAbout the project ↗

Kubernetes OOMKilled and memory limit investigation cheat sheet

Trace a container OOMKilled restart through its memory limit, previous logs and node conditions.

Kubernetes with kubectl; metrics commands require Metrics Server and appropriate access.

Updated · Kubernetes · 6 min read

CommandWhat it does
kubectl config current-contextConfirm the cluster
kubectl describe pod web -n productionInspect termination and limits
kubectl logs web -n production --previousRead previous container logs
kubectl top pod web -n production --containersInspect current usage
kubectl describe node worker-1Inspect node pressure

Walkthrough

Replace production, web and worker-1 with authorized resources. Commands inspect the cluster and do not change limits.

Step 1: Confirm the cluster

kubectl config current-context

Compare the selected context with the approved cluster inventory before reading workload details or interpreting events.

Step 2: Inspect termination and limits

kubectl describe pod web -n production

Review last termination reason, exit code, requests, limits and events. OOMKilled requires investigation and does not alone identify the exact memory consumer.

Step 3: Read previous container logs

kubectl logs web -n production --previous

Inspect the previous container instance where available. Logs may not contain the kernel kill reason and can include sensitive application data.

Step 4: Inspect current usage

kubectl top pod web -n production --containers

Compare current usage with the configured limit when Metrics Server is available. A current sample may miss the peak preceding the restart.

Step 5: Inspect node pressure

kubectl describe node worker-1

Compare node conditions and recent events with the affected Pod. Node pressure eviction and a container OOM kill are related but distinct events.

WORKED INCIDENT

Practical case: A container repeatedly restarts

Fictional teaching scenario; observations are examples, not captured production output.

Situation

A service restarts during traffic spikes and its Pod reports OOMKilled.

Investigation sequence

1. Confirm the cluster

kubectl config current-context

Confirm the affected cluster and namespace before collecting evidence.

2. Inspect termination and limits

kubectl describe pod web -n production

Record the previous termination reason and configured memory limit.

3. Read previous container logs

kubectl logs web -n production --previous

Inspect previous logs and protect sensitive application details.

4. Inspect current usage

kubectl top pod web -n production --containers

Compare current container usage and node pressure with the incident time.

Example findings

Illustrative findings: the container was OOMKilled and monitoring independently shows a memory peak near its configured limit.

Interpret the findings

The measurements support investigating workload memory demand and sizing; a current usage sample alone cannot reconstruct a previous peak.

Verify the outcome

After the owner applies an approved correction, monitor restarts, memory peaks and application health under comparable load.

Escalation handoff

Share sanitized termination details, limits and time-correlated metrics with the workload owner.

Primary references

Documented reference; examples above are teaching scenarios. Confirm behavior against your deployed version.