Short answer: the container crossed its memory limit and the kernel killed it
OOMKilled means the container went over its memory ceiling (resources.limits.memory) and the kernel's OOM killer ended it with SIGKILL (signal 9). That is why the exit code is 128 + 9 = 137, and why the app log often just stops mid-stream.
First check: is it really OOMKilled?
kubectl describe pod checkout-7d9f8-x2k1p | grep -A4 "Last State"
Last State: Terminated
Reason: OOMKilled
Exit Code: 137
Restart Count: 6
If the exit code is 137 but the reason is not OOMKilled, it was killed for another reason, usually a failed liveness probe — look for Liveness probe failed in kubectl get events. Node-wide memory pressure shows up as Evicted, not OOMKilled.
How much was it using?
kubectl top pod checkout-7d9f8-x2k1p --containers
kubectl top shows only this instant and misses peaks. If you have monitoring, compare the recent peak of container_memory_working_set_bytes with the limit — that is the value the OOM decision uses.
Cause 1: the limit is below the peak
Memory spikes only at certain moments (traffic peaks, batch jobs) and restarts cluster around them. Raise the limit to 1.2–1.5× the recent peak and set requests near normal usage. Requests that are far too small pack too many pods onto a node, which spreads into node memory pressure (Evicted).
resources:
requests:
memory: "512Mi" # near normal usage — used for scheduling
limits:
memory: "1Gi" # about recent peak × 1.3
Cause 2: a memory leak
Restarts at a steady interval regardless of traffic, with a sawtooth graph (slow climb, sudden drop), mean a leak. Raising the limit only stretches the interval. Find what keeps growing with a heap dump or profiler; if it started after a deploy, suspect that change first.
Cause 3: the runtime heap does not fit the limit
The JVM, Node.js and Go have their own heap ceilings. If that ceiling sits too close to the limit, off-heap memory (thread stacks, buffers) pushes it over. Setting -Xmx equal to the limit is a common mistake.
JAVA_TOOL_OPTIONS="-XX:MaxRAMPercentage=75.0" # Java 10+: a share of the limit
NODE_OPTIONS="--max-old-space-size=768" # Node.js: 70–75% of the limit (MB)
GOMEMLIMIT=900MiB # Go 1.19+: soft limit
What not to do
- Removing the limit — if that pod eats the node's memory, other pods on the node die too.
- Raising the limit again and again without a cause — with a leak, you only buy time.
The order to work in
- Confirm
Reason: OOMKilledindescribe(otherwise a probe or an external kill) - Compare the recent peak with the limit
- Over only at peaks → adjust the limit; steady repeats → investigate a leak
- For the JVM, Node and Go, set the heap ceiling to 70–75% of the limit
To practise the same situation as a problem, start with the one-minute quiz Exit Code 137 (OOMKilled).
Quick diagnostic checklist
- Confirm
Reason: OOMKilledunder Last State inkubectl describe pod - 137 without OOMKilled points to a failed liveness probe or an external kill
- Node memory pressure shows up as Evicted, not OOMKilled
- Compare the recent peak of
container_memory_working_set_byteswith the limit - Over only at peaks: limit at 1.2–1.5× the peak, requests near normal usage
- Steady restart intervals and a sawtooth graph mean a leak
- Set JVM, Node and Go heap ceilings to 70–75% of the limit (never -Xmx = limit)
- Do not remove the limit — other pods on the node are put at risk