Kubernetes OOMKilled: Why Pods Die With Exit Code 137 and How to Fix Them
Kubernetes OOMKilled means the Linux kernel killed a container for crossing its memory limit. This guide explains exit code 137, separates container OOM from node OOM and eviction, and gives measured fixes for limits, runtimes, and leaks.
Introduction
Kubernetes OOMKilled is a kernel verdict, not an application crash. The container crossed its memory limit, the Linux OOM killer sent SIGKILL, and Kubernetes recorded exit code 137. Fixing it means proving which memory mechanism fired, then sizing the limit, the runtime heap, or the workload itself.
The pattern is familiar to anyone who has carried a pager. A checkout worker with a 512Mi memory limit restarts every forty minutes or so. CPU graphs look calm. Application logs stop mid-request with no stack trace, no panic, and no graceful shutdown message. Between restarts the service answers normally, so dashboards average the pain away. Only the restart count tells the truth, climbing steadily while each new container starts healthy and dies on the same schedule.
That rhythm is the signature of a memory ceiling, and it is why Kubernetes OOMKilled deserves its own triage path instead of a reflexive limit increase. Doubling the limit stops the alert for a leaking process only until the leak grows into the new ceiling. Raising the limit for a spiky batch job can starve neighbouring pods on the node. The durable fix starts with evidence: which container died, what the kernel recorded, how memory behaved before the kill, and whether the workload, the runtime, or the node owns the problem. Repeated kills also push the pod toward Kubernetes CrashLoopBackOff troubleshooting territory, where restart back-off hides the original memory signal under a second failure state.
This guide walks the full path. It explains what exit code 137 proves and what it does not, how cgroup memory limits are enforced, how requests and QoS classes change eviction risk, and how to separate a container-limit kill from a node-level OOM and a kubelet eviction. It then covers measured limit sizing, JVM, Go, and Node.js runtime tuning, leak and spike fixes, and the alerts that catch memory pressure before the kernel does.
1. Kubernetes OOMKilled: What Exit Code 137 Actually Means
Kubernetes OOMKilled means the Linux kernel terminated a container because its memory use reached the limit set in the pod spec. Kubernetes records Reason OOMKilled with exit code 137, which is 128 plus signal 9. The application did not crash; the kernel killed it, and the kubelet restarted it.
Exit code 137 comes from a Unix convention: when a process dies from a signal, the reported exit status is 128 plus the signal number. SIGKILL is signal 9, so 128 plus 9 gives 137. SIGKILL cannot be caught, blocked, or handled by the process, which is why OOMKilled containers leave no shutdown logs. The process receives no chance to flush buffers, close connections, or print a final error. From the application's point of view, execution simply stops.
The reason field carries more information than the exit code. The container runtime watches the oom_kill counter in the container cgroup memory.events file, and when that counter rises it marks the terminated container with Reason OOMKilled. Exit code 137 alone is weaker evidence, because other paths also end in SIGKILL. A liveness probe failure can end with a SIGKILL after the termination grace period, and an evicted pod can show exit code 137 with Reason Error. Treat 137 as a pointer and OOMKilled as the confirmation.
Scope matters as well. An OOM kill targets the container that breached its limit, not the whole pod. A pod with an application container and a logging sidecar can show one container restarting while the other keeps running, which confuses teams that only read pod-level status. Kubernetes restarts the killed container according to the pod restartPolicy, normally Always for Deployments, so the pod survives and the restart count climbs. The container is always read in the past tense: OOMKilled describes a previous run recorded under Last State, while the current run may already be healthy and consuming memory again.
2. Kubernetes OOMKilled: How the Kernel Enforces Memory Limits
Kubernetes OOMKilled happens inside the Linux memory cgroup, where the pod memory limit becomes the memory.max ceiling. When usage reaches that ceiling and reclaim cannot free enough pages, the kernel invokes the OOM killer inside the cgroup. The runtime then reports the kill to the kubelet.
Every container with a memory limit runs in its own memory cgroup on the node. The kubelet passes the limit to the container runtime, and the runtime writes it into the cgroup interface, memory.max on cgroup v2 systems. The kernel charges the container for the memory it touches: anonymous pages holding heap and stack data, page cache for files it reads and writes, and kernel memory accounted to the cgroup. When an allocation would push the charge past memory.max, the kernel first tries to reclaim memory, dropping clean page cache and shrinking other reclaimable pools. Only when reclaim cannot make room does the OOM killer select a process in the cgroup and send SIGKILL.
This mechanism explains a common puzzle: a container can OOMKill while application heap metrics look comfortable. The cgroup charge is larger than the heap. Thread stacks, metaspace, direct buffers, memory-mapped files, child processes, and page cache all count toward the same ceiling. A JVM with a heap ceiling close to the limit still dies when non-heap memory pushes the total over memory.max, and the heap graph never shows an out-of-memory error because the heap itself never filled. The control-plane and node components behind this path are mapped in Kubernetes architecture and workload orchestration, which helps when separating kubelet behaviour from kernel behaviour during an incident.
The cgroup also records the evidence. The memory.events file counts events such as max, oom, and oomkill for the cgroup, and the oomkill counter is what the runtime uses to label the container OOMKilled. On the node, the kernel log distinguishes a limit kill with a line about a memory cgroup running out of memory from a global kill where the whole node ran dry. Operators rarely read node kernel logs first, but that distinction decides whether the fix belongs to one container limit or to node capacity and packing.
3. Kubernetes OOMKilled: Requests, Limits, and QoS Classes
Kubernetes OOMKilled is governed by the memory limit, while the memory request governs scheduling and eviction order. Requests reserve capacity when the scheduler places the pod. Limits cap the cgroup at runtime. QoS class, derived from requests and limits, decides which pods the kubelet sacrifices first under node pressure.
The scheduler reads requests, not limits. When a pod is placed, the scheduler ensures the sum of requests on a node fits within allocatable capacity. Limits are invisible at placement time, so the sum of limits on a node can exceed physical memory by design. That overcommit is safe only while actual usage stays below capacity. The kernel enforces limits at runtime through the cgroup, and memory enforcement has no soft landing. CPU is compressible: a container over its CPU limit is throttled and slows down. Memory is incompressible: a container over its memory limit is killed. There is no way to give a process nine tenths of a page.
QoS class turns those numbers into survival priority. A pod is Guaranteed when every container sets CPU and memory requests equal to limits. It is BestEffort when no container sets any request or limit. Everything else is Burstable. The kubelet translates QoS into an oomscoreadj value for the kernel: Guaranteed pods receive -997 and are killed last, BestEffort pods receive 1000 and are killed first, and Burstable pods fall between 2 and 999 based on their memory request relative to node capacity. Under node memory pressure the kubelet evicts BestEffort and over-request Burstable pods first, ranked by priority and by how far usage exceeds requests, and leaves Guaranteed pods until last.
The practical lesson is that requests are a safety control, not paperwork. A pod using 1Gi against a 256Mi request is a prime eviction candidate even if its limit is generous, because the kubelet ranks victims by excess over request. Setting memory requests near measured usage, and following the resource hygiene in Kubernetes best practices, keeps both the scheduler and the eviction manager honest.
| QoS class | Condition | oomscoreadj | Eviction order |
|---|---|---|---|
| Guaranteed | Every container has CPU and memory requests equal to limits | -997 | Last |
| Burstable | At least one request or limit set, Guaranteed rule not met | 2 to 999 | Middle, furthest over request first |
| BestEffort | No requests or limits on any container | 1000 | First |
4. Kubernetes OOMKilled: Container OOM vs Node OOM vs Eviction
Kubernetes OOMKilled covers three different memory mechanisms that need three different fixes. A container-limit kill ends one container inside its cgroup. A node-level OOM ends whichever process the kernel picks on a dry node. A kubelet eviction removes a whole pod before the kernel is forced to act.
The container-limit kill is the classic case. One container reaches memory.max, reclaim fails, the kernel kills a process in that cgroup, and the runtime marks Reason OOMKilled with exit code 137. The pod stays on the node and the container restarts. The fix lives with that container: its limit, its runtime heap settings, or the workload memory behaviour.
A node-level OOM is a capacity failure. No single container needs to be at its limit; the node as a whole runs out of memory, often because limits were overcommitted and several pods grew at once, or because a pod with no limit consumed what neighbours expected to use. The kernel picks a victim across the machine guided by oomscoreadj, so a well-behaved BestEffort pod can die for another pod's growth. The kernel log shows a global out-of-memory kill without a memory cgroup reference, and several pods may restart in the same minute. Raising one limit makes this failure worse, not better.
Kubelet eviction is Kubernetes acting before the kernel must. The kubelet watches node memory through its own memory.available signal, and when available memory falls below the eviction threshold, 100Mi by default on Linux nodes, it terminates whole pods to protect the node. Evicted pods end in the Failed phase with reason Evicted and a message naming the resource, such as the node was low on resource memory. The pod is not restarted in place; its controller creates a replacement, possibly on another node. Eviction messages name the container usage and request, which makes them unusually honest evidence about dishonest requests.
| Mechanism | Who kills | Scope | Evidence | First fix |
|---|---|---|---|---|
| Container OOMKilled | Kernel OOM killer in the container cgroup | One container | Reason OOMKilled, exit 137, usage at limit | Size the limit, tune the runtime, or fix the workload |
| Node-level OOM | Kernel global OOM killer | Any process on the node | Global kernel kill line, several pods restart together | Add capacity, reduce overcommit, set missing limits |
| Kubelet eviction | Kubelet under memory pressure | Whole pod | Phase Failed, reason Evicted, low memory message | Raise requests to match usage, fix node packing |
5. Kubernetes OOMKilled: Confirm the Kill With kubectl
Kubernetes OOMKilled confirmation starts with the Last State block in kubectl describe pod output. Reason OOMKilled with exit code 137 proves a kernel memory kill. Previous container logs, pod events, and per-container usage then show which container died and what it was doing at the time.
Run describe against the pod and read every container, not just the first one. Multi-container pods hide the truth in the sidecar block more often than teams expect. The Last State section shows the termination reason, exit code, and start and finish times for the previous run. The gap between Started and Finished is diagnostic on its own: a container killed seconds after starting usually has a limit below its steady working set, while a container killed after a consistent run time points at growth, a leak, or a periodic job.
kubectl describe pod checkout-worker-7f9c8 -n production
kubectl get pod checkout-worker-7f9c8 -n production -o jsonpath='{.status.containerStatuses[*].lastState.terminated.reason}'
kubectl logs checkout-worker-7f9c8 -n production --previous --tail=100
kubectl get events -n production --sort-by=.lastTimestamp
kubectl top pod checkout-worker-7f9c8 -n production --containers
Previous logs deserve a careful read because the last lines before the kill often name the job, payload, or request that pushed memory over the edge. Events separate the lookalikes: failed liveness probe messages with Killing events point at probe configuration, while an Evicted reason on the pod points at node pressure. The command patterns behind these checks are covered in depth in the kubectl master guide, including jsonpath extraction for restart reasons across a namespace.
One caution protects the whole investigation: exit code 137 without Reason OOMKilled is not proof of a memory kill. Probe kills and eviction grace-period kills also produce 137. When the reason reads Error, check events and node conditions before touching memory limits. When the reason reads OOMKilled but usage graphs show headroom under the limit, suspect a node-level kill and check the node for MemoryPressure and neighbouring pod restarts in the same window.
6. Kubernetes OOMKilled: Leak, Spike, or Undersized Limit
Kubernetes OOMKilled triage depends on the shape of memory over time. Flat usage near the limit means the limit is undersized. A sharp peak means a spike needs bounding or headroom. A steady climb that resets at each restart means a leak that no limit increase will cure.
Single snapshots mislead. kubectl top shows current usage for running containers, and the killed container is gone by definition, so the snapshot after a restart shows a young process with low memory. Diagnosis needs a time series. Prometheus exposes containermemoryworkingsetbytes, which estimates the memory the container actively uses by subtracting inactive file cache from total usage, and containermemoryusage_bytes, which reflects the fuller cgroup charge including page cache. The working set is the right series for sizing decisions, while usage explains why page-cache-heavy workloads can hit memory.max while working set graphs look calm.
Three shapes cover most incidents. A flat line hugging the limit all day means steady-state memory exceeds the ceiling, often after a deploy added a cache, a larger dataset, or a new dependency. The fix is a measured limit increase. A sawtooth that climbs for hours and drops to zero at each restart means memory is allocated and never returned: an unbounded cache, a growing queue buffer, retained request objects, or a native memory leak. Raising the limit only stretches the interval between kills. A mostly flat line with narrow peaks means a spike: a large payload, a batch export, a report job, or a traffic burst with high concurrency. The fix bounds the work or sizes the limit for the peak with eyes open about cost.
| Memory shape | Likely cause | Confirm with | Durable fix |
|---|---|---|---|
| Flat near the limit | Limit below steady working set | Working set series across a full traffic cycle | Raise limit to measured peak plus headroom |
| Steady climb, resets on restart | Memory leak or unbounded cache | Two usage samples an hour apart, heap profile | Fix the code or bound the cache |
| Narrow peaks over the limit | Spike from payload, batch, or concurrency | Last log lines before the kill, peak timestamps | Bound the work, stream data, or size for the peak |
| One container of several dies | Sidecar at its own limit | Per-container Last State and usage | Fix that container limit and requests |
Compare the shape against deploy history before changing anything. Kills that began with a new ReplicaSet usually trace to the change that shipped with it: a config value, a feature flag, a dependency upgrade, or a larger in-memory dataset. Reverting or fixing that change is faster than re-sizing around it.
7. Kubernetes OOMKilled: Size the Memory Limit From Measurements
Kubernetes OOMKilled fixes start from measured peak working set, not from doubling. Set the memory request near real usage so scheduling and eviction ranking stay honest, set the limit above the measured peak with headroom, and verify the new values across a full traffic cycle before calling the incident closed.
Measurement comes first. Collect the working set series for the container across at least one full traffic cycle, including peak hours, batch windows, and deploys. Note the sustained peak rather than a single sample. A container peaking at 480Mi against a 512Mi limit has no room for variance, cache growth, or a slightly larger payload, and will keep dying on schedule. A limit set from that peak plus a deliberate margin, paired with a request close to typical usage, turns an unpredictable kill into a monitored budget.
apiVersion: apps/v1
kind: Deployment
metadata:
name: checkout-worker
namespace: production
spec:
replicas: 3
selector:
matchLabels:
app: checkout-worker
template:
metadata:
labels:
app: checkout-worker
spec:
containers:
- name: checkout-worker
image: checkout-worker:stable
resources:
requests:
cpu: 250m
memory: 384Mi
limits:
memory: 768Mi
Two sizing debates deserve explicit answers. Setting the memory limit equal to the request makes OOM behaviour predictable and, with matching CPU values, earns Guaranteed QoS, at the cost of giving up burst headroom above the request. Many stateless services run well with request below limit, provided the request reflects real usage so eviction ranking stays fair. What never works is a token request far below usage: the scheduler packs the node on false numbers and the kubelet ranks the pod first for eviction. Rightsizing help exists in the HPA vs VPA in Kubernetes comparison, where VPA recommendations give an evidence-based starting point for requests, applied in recommendation mode before any automated updates.
Apply limit changes as a controlled experiment. Change one workload, watch working set against the new limit through peak traffic, and confirm restart counts stay flat. A limit raised during an incident to stop the bleeding is a valid stabilising move, but it buys investigation time rather than closing the incident. Record the measured peak, the chosen headroom, and the review date in the change, so the next engineer can tell a sized limit from a guessed one.
8. Kubernetes OOMKilled: Tune JVM, Go, and Node.js Runtimes
Kubernetes OOMKilled often survives a correct limit because the language runtime sizes its heap without regard to the cgroup ceiling. The container limit covers the whole process, heap plus non-heap. JVM, Go, and Node.js each need explicit settings so garbage collection acts before the kernel does.
The JVM reads container limits on modern JDKs and derives its default maximum heap from MaxRAMPercentage, which defaults to a conservative share of the limit. The failure mode runs in both directions. A heap ceiling set too close to the limit leaves no room for metaspace, code cache, thread stacks, and direct buffers, so the cgroup total crosses memory.max while heap metrics show space to spare. A heap ceiling left at the conservative default wastes the memory the team is paying for and can throw application out-of-memory errors far below the limit. Set MaxRAMPercentage explicitly so the heap takes a planned share of the limit, commonly in the 60 to 75 percent range, leaving the remainder for non-heap memory. Add ExitOnOutOfMemoryError so a genuine heap exhaustion exits the process for a clean restart instead of leaving a half-broken JVM running.
Go takes the opposite default: the runtime derives no heap limit from the cgroup, so garbage collection targets a growth ratio rather than a ceiling and memory can drift into the limit under load. GOMEMLIMIT sets a soft memory limit that makes the collector work harder as usage approaches the target. Set it below the container limit so collection pressure rises before the kernel intervenes, and treat it as a soft target that the runtime may exceed briefly under extreme allocation pressure rather than a hard cap.
Node.js sizes its old-space heap from its own defaults, which can exceed a small container limit or undershoot a large one. The max-old-space-size flag sets the heap ceiling in megabytes. Size it as a share of the container limit with room for buffers, native addons, and the runtime itself, and remember that large Buffer allocations live outside the old-space heap while still counting toward the cgroup charge.
apiVersion: v1
kind: Pod
metadata:
name: checkout-worker-runtime-example
namespace: production
spec:
containers:
- name: checkout-worker
image: checkout-worker:stable
resources:
requests:
memory: 1Gi
limits:
memory: 1Gi
env:
- name: JAVATOOLOPTIONS
value: "-XX:MaxRAMPercentage=65 -XX:+ExitOnOutOfMemoryError"
- name: GOMEMLIMIT
value: "800MiB"
- name: NODE_OPTIONS
value: "--max-old-space-size=640"
The example sets one runtime variable per stack for illustration; a real container sets only the variable its runtime reads. The sizing rule stays constant across stacks: heap ceiling plus non-heap plus safety margin must fit under the container limit, and the heap ceiling should scale with the limit so a limit change resizes the runtime instead of silently breaking the ratio.
9. Kubernetes OOMKilled: Fix Leaks, Spikes, and Unbounded Work
Kubernetes OOMKilled caused by a leak or a spike will outgrow any limit increase. Leaks need code fixes and bounded caches. Spikes need bounded payloads, streaming instead of buffering, and concurrency limits. The memory graph shape from triage decides which fix applies.
Leak hunting starts by proving growth inside the process. Compare heap or resident memory at the same traffic level across hours; growth that survives garbage collection cycles and quiet periods is retained memory, not load. Common retainers include caches without size or time bounds, queues that buffer faster than consumers drain, request-scoped objects captured by long-lived structures, and native allocations that bypass the managed heap. Heap profiles and allocation sampling identify the retaining path. Until the fix ships, a larger limit plus a restart-count alert is a containment plan, and it should be labelled as containment in the incident record.
Spikes need work bounding. Loading a whole file, result set, or request body into memory makes peak usage proportional to the largest input anyone sends. Streaming reads, pagination, chunked processing, and explicit payload size limits convert an unbounded peak into a budgeted one. Concurrency multiplies everything: ten parallel requests each holding a large buffer need ten times the headroom, so semaphore limits and worker pool sizes are memory controls as much as CPU controls. Batch jobs deserve their own sizing conversation, because a job that exports a full dataset will use memory in proportion to data growth, and yesterday's safe limit becomes next quarter's kill.
Two quiet contributors catch teams out. Memory-backed emptyDir volumes, configured with medium Memory, charge their contents to the container cgroup, so a tmpfs scratch space filled with intermediate files counts against the same limit as the heap. Sidecar containers carry their own limits and their own failure modes; a log shipper or proxy buffering through a downstream outage can OOMKill while the application container stays healthy, and pod-level dashboards blame the wrong process. Per-container limits, per-container graphs, and per-container Last State checks keep the blame accurate.
10. Kubernetes OOMKilled: Node Pressure, Evictions, and Capacity
Kubernetes OOMKilled at node scale signals packing and capacity problems rather than one bad limit. When several pods restart together, the node reports MemoryPressure, or pods end Evicted, the fix is honest requests, missing limits, and node capacity, in that order of investigation.
Start with the node. A MemoryPressure condition, eviction messages naming memory, and simultaneous restarts across unrelated pods point away from individual limits. Check which pods on the node run far above their requests, which run with no limit at all, and whether a recent rollout concentrated memory-heavy pods onto fewer nodes. The eviction message itself ranks the evidence: it names the container usage and request that made the pod a victim. A pod evicted while using several times its request was scheduled on numbers nobody believed.
Requests are the first correction because they drive both placement and eviction ranking. Raising requests to measured usage makes the scheduler spread pods truthfully and moves well-behaved pods to the back of the eviction queue. Limits are the second correction: every production container should carry a memory limit so one runaway process dies inside its own cgroup instead of taking neighbours with it through a global OOM. Capacity is the third: if honest requests no longer fit, the node pool is too small or too densely packed, and no YAML tuning changes that arithmetic.
Global OOM kills deserve special respect because the kernel chooses victims by score, not by fault. A BestEffort batch pod can be killed for a neighbour's growth, and in the worst case a system process dies and the node destabilises. The defence is boring and effective: no BestEffort pods in production namespaces, memory limits everywhere, requests that match measurements, and alerts on node memory headroom that fire while eviction is still avoidable.
11. Kubernetes OOMKilled: Troubleshooting Matrix
Kubernetes OOMKilled troubleshooting routes faster with a symptom matrix than with guesswork. Match the observed signal to the mechanism, run the confirming command, and apply the fix that belongs to that mechanism. Changing limits before identifying the mechanism adds a second problem.
| Symptom | Root cause | Diagnosis command | Resolution |
|---|---|---|---|
| Reason OOMKilled, exit 137, usage flat at limit | Limit below steady working set | kubectl top pod --containers plus working set graph | Raise limit to measured peak plus headroom |
| Reason OOMKilled on a steady interval, usage climbing | Memory leak or unbounded cache | Compare usage samples an hour apart | Fix the leak, bound the cache, contain with a temporary limit |
| Reason OOMKilled seconds after Started | Limit below startup working set | kubectl describe pod Last State times | Raise limit, check startup caches and dataset loads |
| Exit 137 with Reason Error and probe events | Liveness probe kill, not OOM | kubectl get events sorted by time | Fix probe timing and SIGTERM handling |
| Pod Failed with reason Evicted | Kubelet eviction under node pressure | kubectl describe pod and node conditions | Raise requests to match usage, fix node packing |
| Several pods restart in the same minute | Node-level OOM | kubectl describe node MemoryPressure | Add capacity, set missing limits, reduce overcommit |
| READY 1/2 with one container OOMKilled | Sidecar at its own limit | Per-container Last State in describe output | Fix the sidecar limit and requests |
| OOMKilled while heap metrics look fine | Non-heap memory over the cgroup ceiling | Compare working set with heap series | Lower heap share, budget non-heap, raise limit |
| OOMKilled after a new ReplicaSet | Deploy raised memory use | Compare ReplicaSet ages and spec changes | Revert or fix the change, then re-size |
Read the matrix from evidence to action. The reason field and the memory shape come first, the command confirms the mechanism, and only then does a limit, runtime flag, or code change enter the conversation. Teams that keep this order close OOM incidents in one change; teams that start by doubling limits close them twice.
12. Kubernetes OOMKilled: Prevention Checklist and Alerts
Kubernetes OOMKilled prevention combines sized limits, runtime ceilings, and alerts on memory headroom. Alert when working set approaches the limit and when the oomkill counter moves, review memory after every deploy that touches data paths, and treat restart-count growth as a paging signal rather than background noise.
Prevention starts at admission time. Every production container sets a memory request from measured usage and a memory limit above the measured peak. Runtime heap ceilings scale with the limit through MaxRAMPercentage, GOMEMLIMIT, or max-old-space-size, with non-heap memory budgeted rather than discovered. Work that scales with input size streams or paginates, caches carry size bounds, and concurrency limits reflect the memory each parallel unit holds. Load tests include a memory soak at peak concurrency, because leaks and slow cache growth hide from short tests. The alerting patterns behind these checks align with production monitoring and alerting troubleshooting, where symptom-based alerts page on user impact while cause-based alerts warn on shrinking headroom.
Alert on headroom, not only on death. A working set sustained above a high share of the limit warns days before the first kill. An increase in the container oomkill counter is a certain signal that a kill already happened and deserves a ticket even when restarts look harmless. Restart count growth on a Deployment, node MemoryPressure conditions, and eviction events complete the set. Review the graphs after deploys that change datasets, caches, batch sizes, or dependencies, because the most common OOMKilled trigger is a change that quietly raised the working set past a limit nobody revisited.
The closing discipline is simple. Every OOMKilled incident ends with a recorded mechanism, a measured peak, the change that addressed it, and a review date for the limit. Limits sized from evidence stay correct for quarters. Limits guessed during incidents drift until the kernel collects the debt again.
Frequently Asked Questions
What does Kubernetes OOMKilled mean?
Kubernetes OOMKilled means the Linux kernel killed a container because its memory use reached the limit in the pod spec. The runtime records Reason OOMKilled with exit code 137, and the kubelet restarts the container according to the pod restartPolicy. The application did not crash on its own; the kernel ended it for crossing the memory ceiling.
Why does Kubernetes OOMKilled show exit code 137?
Kubernetes OOMKilled shows exit code 137 because signal deaths report 128 plus the signal number, and the OOM killer sends SIGKILL, signal 9. Exit code 137 alone does not prove a memory kill, since probe kills and eviction grace-period kills also end in SIGKILL. Reason OOMKilled in the Last State block is the confirming evidence.
What is the difference between Kubernetes OOMKilled and Evicted?
Kubernetes OOMKilled is a container-level kernel kill when one container crosses its memory limit, and the container restarts in place. Evicted is a pod-level kubelet action under node memory pressure: the pod ends Failed with reason Evicted and its controller creates a replacement. OOMKilled points at a container limit; Evicted points at node packing and requests.
How do I fix a Kubernetes OOMKilled pod that keeps restarting?
Fix a Kubernetes OOMKilled pod by first confirming Reason OOMKilled in kubectl describe output, then reading the memory graph shape. Flat usage at the limit needs a measured limit increase. Climbing usage needs a leak fix. Narrow peaks need bounded work or peak sizing. Restarting pods without this triage usually repeat the same kill on a longer interval.
Does raising the memory limit fix Kubernetes OOMKilled?
Raising the memory limit fixes Kubernetes OOMKilled only when the limit sits below the steady working set. For leaks, a larger limit delays the kill until growth fills the new ceiling. For spikes, it helps only when sized for the peak. Measure the peak working set, add deliberate headroom, and fix leaks or unbounded work in code.
Why does Kubernetes OOMKilled happen when kubectl top shows low memory?
Kubernetes OOMKilled can follow low kubectl top readings because top shows the restarted container, not the killed one, and single snapshots miss peaks. The cgroup charge also includes page cache and non-heap memory that heap graphs hide. Use the working set time series across the kill window and compare it with the limit before ruling out memory pressure.
How do requests and limits affect Kubernetes OOMKilled risk?
Requests affect Kubernetes OOMKilled risk through scheduling and eviction ranking, while limits set the cgroup ceiling the kernel enforces. Pods using far more than their requests are evicted first under node pressure. Honest requests near measured usage, plus a limit above the measured peak, keep both placement and kill behaviour predictable.
How do I stop Kubernetes OOMKilled in JVM, Go, and Node.js services?
Stop Kubernetes OOMKilled in managed runtimes by sizing the heap as a share of the container limit. Set MaxRAMPercentage for the JVM with room for non-heap memory, GOMEMLIMIT below the limit for Go, and max-old-space-size for Node.js. The heap ceiling plus non-heap plus margin must fit under the limit, and the ceiling should scale when the limit changes.
Preparing for Senior Platform & SRE Interviews
Practice real-world cluster triage, RBAC debugging, and pod scheduling scenarios in our Kubernetes scenario interview questions hub.
Explore Interview Scenarios →