
Introduction
A Kubernetes container can restart because it exceeds its own memory limit. A Kubernetes node can also run out of available memory and start evicting Pods.
These situations look similar at first. Both can cause application failures, container restarts and service disruptions.
However, OOMKilled and MemoryPressure describe different parts of Kubernetes memory management.
OOMKilledusually indicates that the container reached its cgroup memory limit and the Linux OOM killer terminated a process.MemoryPressureis a Kubernetes node condition. It indicates that available node memory has reached a configured eviction threshold.
A container can be OOMKilled even when its node has no MemoryPressure condition. A node can also evict Pods because of memory pressure without every affected container being marked OOMKilled.
This distinction matters when investigating production incidents.
This guide explains both conditions and includes a practical Kubernetes lab. You will reproduce a container-level OOM event, investigate its termination state and learn how to diagnose node-level memory pressure safely.
OOMKilled vs MemoryPressure: What Is the Difference?
Start with this comparison.
| Area | OOMKilled | Node MemoryPressure |
|---|---|---|
| Meaning | A process was killed by an out-of-memory event | Available node memory reached an eviction threshold |
| Main scope | Container or cgroup | Kubernetes node |
| Typical trigger | Container memory limit exceeded | Node memory becoming insufficient |
| Main enforcement | Linux kernel OOM mechanism | Kubelet eviction manager |
| Common evidence | Container termination reason OOMKilled | Node condition MemoryPressure=True |
| Pod outcome | Container may restart | Pod may be terminated and replaced |
| Exit code | Commonly 137 | Can vary |
| Main investigation | Container memory usage and limits | Node memory, other Pods and kubelet events |
| Primary fix | Correct application usage or container resources | Restore node memory headroom and investigate aggregate usage |
Kubernetes documents that container memory limits are enforced through Linux cgroups. When memory consumption cannot be reclaimed, the kernel may terminate a process.
Node-pressure eviction is a separate process in which the kubelet proactively terminates Pods to recover node resources.
Sources: Kubernetes Resource Management and Node-pressure Eviction.
What Does OOMKilled Mean in Kubernetes?
OOMKilled means that a process inside a container was terminated by an out-of-memory mechanism.
On Linux Kubernetes nodes, container memory limits are enforced using control groups, commonly called cgroups.
Consider this container configuration:
resources:
requests:
memory: "128Mi"
limits:
memory: "256Mi"Code language: JavaScript (javascript)
The container requests 128 MiB of memory and has a configured limit of 256 MiB.
If the container requires more memory than its limit allows, the kernel may invoke its OOM mechanism.
If the container’s main process is terminated, Kubernetes records the termination information. The container may restart depending on the Pod’s restart policy.
Common Signs of OOMKilled
Run:
kubectl get podsCode language: JavaScript (javascript)
Then inspect the affected Pod:
kubectl describe pod <pod-name> -n <namespace>Code language: HTML, XML (xml)
Look for output similar to:
Last State: Terminated
Reason: OOMKilled
Exit Code: 137
Restart Count: 3Code language: PHP (php)
This indicates that the container was terminated and has restarted three times.
Check the exact termination state:
kubectl get pod <pod-name> -n <namespace> \
-o jsonpath='{range .status.containerStatuses[*]}{.name}{" reason="}{.lastState.terminated.reason}{" exit="}{.lastState.terminated.exitCode}{" restarts="}{.restartCount}{"\n"}{end}'Code language: JavaScript (javascript)
This command is useful when the container has already restarted.
If the container is currently terminated rather than restarted, inspect .state.terminated instead of .lastState.terminated.
Is Exit Code 137 Always OOMKilled?
No.
Exit code 137 usually means that a process received. SIGKILL.
OOM termination is one possible reason.
Other causes can include:
- Kubelet-initiated termination
- Node-pressure eviction
- Manual container termination
- An external process sending SIGKILL
Therefore, do not diagnose OOMKilled using exit code 137 alone.
Check the recorded termination reason, Pod events and node conditions.
Microsoft’s AKS troubleshooting guidance also makes this distinction between OOMKilled and a generic Error with exit code 137.
Source: Troubleshoot Memory Saturation in AKS.
What Does MemoryPressure Mean in Kubernetes?
MemoryPressure is a condition reported on a Kubernetes Node.
It indicates that available node memory has reached an eviction threshold.
Kubernetes uses the kubelet to monitor resource availability.
One important signal is:
memory.availableCode language: CSS (css)
When this signal reaches the configured eviction threshold, the node can enter MemoryPressure.
Check the nodes:
kubectl get nodesCode language: JavaScript (javascript)
Inspect a particular node:
kubectl describe node <node-name>Code language: HTML, XML (xml)
Look for:
Conditions:
Type Status
---- ------
MemoryPressure TrueCode language: PHP (php)
The exact reason and message depend on the node’s condition and the incident.
You can also display the condition directly:
kubectl get node <node-name> \
-o jsonpath='{range .status.conditions[?(@.type=="MemoryPressure")]}{.status}{" reason="}{.reason}{" message="}{.message}{"\n"}{end}'Code language: JavaScript (javascript)
Why Does Node MemoryPressure Occur?
Possible causes include:
- Multiple Pods consuming more memory than expected
- Containers using more memory than their requests
- Memory leaks across workloads
- Large in-memory caches
- High traffic or workload spikes
- Memory-backed
emptyDirvolumes - Sidecars and monitoring agents
- System daemons using unreserved memory
- Insufficient node capacity
Node memory pressure is an aggregate problem.
The container with the largest memory usage is not automatically the only cause.
How Does Kubernetes Respond to Node Memory Pressure?
When node memory becomes scarce, the kubelet attempts to reclaim resources before evicting end-user Pods.
If available memory remains below the relevant threshold, the kubelet can begin terminating Pods.
It considers:
- Whether a Pod’s memory usage exceeds its requests.
- Pod Priority.
- Memory usage relative to requests.
This matters because a Pod’s Quality of Service class alone does not fully determine kubelet eviction order.
A BestEffort Pod may be vulnerable, but the kubelet uses the more detailed eviction criteria above.
The kubelet can also assign oom_score_adj values based on Pod QoS when the kernel itself must handle a node-level OOM event.
This means a node-wide kernel OOM kill and a normal kubelet eviction are not identical processes.
Sources: Kubernetes Node-pressure Eviction and Pod QoS Classes.
Understand Kubernetes Memory Requests and Limits
Requests and limits control different parts of resource management.
Memory Request
A memory request tells Kubernetes how much memory a container needs for scheduling.
The scheduler uses requests when deciding whether a Pod fits on a node.
For example:
resources:
requests:
memory: "128Mi"Code language: JavaScript (javascript)
A request is not a hard memory ceiling.
A container can use more than its request when resources are available.
However, using more than its request becomes important when the node experiences pressure.
Memory Limit
A memory limit sets a maximum memory boundary for the container’s cgroup.
Example:
resources:
limits:
memory: "256Mi"Code language: JavaScript (javascript)
If the container exceeds the limit and memory cannot be reclaimed, the kernel may kill a process.
Requests and Limits Together
Consider:
resources:
requests:
memory: "128Mi"
limits:
memory: "256Mi"Code language: JavaScript (javascript)
Here:
- The scheduler uses 128 MiB as the request.
- The kernel-enforced container memory boundary is 256 MiB.
The gap between request and limit allows the container to use additional memory when available.
But if several containers use that extra memory at the same time, the node may experience pressure.
This is why requests should reflect realistic workload requirements rather than arbitrary small numbers.
Practical Lab 1: Reproduce a Container-Level OOMKilled Event
This lab creates a small Python container that continuously allocates memory.
Its memory limit is deliberately low so that you can observe a controlled cgroup OOM event.
Safety: Run this only in a disposable test cluster or isolated development environment. Do not use production namespaces. The example is bounded by a 64 MiB container limit, but it still intentionally terminates its process.
Lab Requirements
You need:
- A working Kubernetes cluster
kubectlaccess- Permission to create a namespace and Pod
- A container runtime able to pull
python:3.12-slim
Check the cluster:
kubectl version
kubectl get nodes
kubectl cluster-infoCode language: JavaScript (javascript)
Create a namespace:
kubectl create namespace oom-labCode language: PHP (php)
Step 1: Create the Memory Stress Pod
Save the following manifest as oom-demo.yaml.
apiVersion: v1
kind: Pod
metadata:
name: cgroup-oom-demo
namespace: oom-lab
labels:
app: cgroup-oom-demo
spec:
restartPolicy: Never
containers:
- name: allocator
image: python:3.12-slim
command:
- python
- -u
- -c
args:
- |
import time
chunks = []
total = 0
while True:
chunks.append(bytearray(8 * 1024 * 1024))
total += 8
print(
f"Allocated approximately {total} MiB",
flush=True
)
time.sleep(1)
resources:
requests:
memory: "32Mi"
limits:
memory: "64Mi"Code language: JavaScript (javascript)
Apply the manifest:
kubectl apply -f oom-demo.yamlCode language: CSS (css)
Watch the Pod:
kubectl get pod cgroup-oom-demo -n oom-lab -wCode language: JavaScript (javascript)
The Python process continuously allocates 8 MiB blocks.
Eventually, its memory usage should exceed the configured 64 MiB limit and the kernel should terminate the process.
The Pod uses restartPolicy: Never so that Kubernetes does not repeatedly restart the container during this demonstration.
Step 2: Inspect the Container Termination
Run:
kubectl describe pod cgroup-oom-demo -n oom-lab
Look for the termination information.
An expected result is similar to:
State: Terminated
Reason: OOMKilled
Exit Code: 137
Restart Count: 0Code language: PHP (php)
The exact displayed fields can vary with the Kubernetes version and runtime.
The important evidence is the recorded OOMKilled termination reason.
Step 3: Inspect the Container Logs
Run:
kubectl logs cgroup-oom-demo -n oom-lab
You may see output similar to:
Allocated approximately 8 MiB
Allocated approximately 16 MiB
Allocated approximately 24 MiB
Allocated approximately 32 MiB
Allocated approximately 40 MiB
The output stops when the process is terminated.
The last printed value is not guaranteed to be exactly the memory limit. Python itself, imported libraries and other process memory also count toward the container’s consumption.
Step 4: Check the Pod’s Detailed Status
Run:
kubectl get pod cgroup-oom-demo -n oom-lab -o yamlCode language: JavaScript (javascript)
Inspect:
status.phasestatus.containerStatusesstate.terminatedreasonexitCode
Because this Pod was configured with restartPolicy: Never, its phase is expected to become Failed after the container terminates.
Step 5: Check the Node Condition
Now inspect the node that ran the Pod:
kubectl get pod cgroup-oom-demo \
-n oom-lab -o wideCode language: JavaScript (javascript)
Identify the node and inspect it:
kubectl describe node <node-name>Code language: HTML, XML (xml)
For this container-limit experiment, the node may still show:
MemoryPressure FalseCode language: PHP (php)
That is an important finding.
The container was OOMKilled even though the node did not need to enter MemoryPressure.
This is the central difference demonstrated by Lab 1.
Practical Lab 2: Diagnose Node-Level Memory Pressure
This second exercise is an observation and incident-replay lab.
It does not deliberately exhaust node memory. Creating artificial node-wide memory pressure can destabilise a cluster and interrupt unrelated workloads.
Use an isolated disposable cluster if you need to reproduce a complete node-pressure incident. For this diagnosis exercise, use real node telemetry when available or the clearly labelled sample incident below.
Step 1: Check All Node Conditions
Run:
kubectl get nodesCode language: JavaScript (javascript)
Select the node that experienced the incident:
kubectl describe node <node-name>Code language: HTML, XML (xml)
Review:
MemoryPressureReady- Node capacity
- Allocatable memory
- Node events
- Conditions and messages
Step 2: Check Node Memory Usage
If Metrics Server is installed, run:
kubectl top nodes
This provides a current resource-usage sample.
It does not provide historical memory peaks.
Step 3: Identify High-Memory Pods
Run:
kubectl top pods -A --sort-by=memory
To inspect containers in one Pod:
kubectl top pod <pod-name> \
-n <namespace> --containersCode language: HTML, XML (xml)
Metrics Server is required for these commands.
Use Prometheus, cloud monitoring or another time-series system when historical memory graphs are needed.
Step 4: Find Evicted Pods
List failed Pods:
kubectl get pods -A \
--field-selector=status.phase=FailedCode language: JavaScript (javascript)
Inspect any Pod that appears to have been evicted:
kubectl describe pod <pod-name> -n <namespace>Code language: HTML, XML (xml)
Look for a Pod termination reason such as:
Reason: EvictedCode language: HTTP (http)
The message may indicate that the node was low on memory.
Step 5: Review Recent Events
Run:
kubectl get events -A \
--sort-by=.metadata.creationTimestampCode language: JavaScript (javascript)
On Linux or macOS, you can filter the output:
kubectl get events -A \
--sort-by=.metadata.creationTimestamp |
grep -Ei 'Evicted|MemoryPressure|OOM|Killing'Code language: JavaScript (javascript)
In PowerShell, use Select-String with the same patterns.
Example Incident: Node MemoryPressure
The following is an illustrative incident, not a live cluster capture.
Suppose the investigation shows:
Node: worker-01
MemoryPressure: True
Pod: application-a
Memory request: 256Mi
Observed usage: 850Mi
Pod: application-b
Memory request: 512Mi
Observed usage: 700Mi
Pod: cache-service
Memory request: 128Mi
Observed usage: 600Mi
Node memory available: Below eviction thresholdCode language: HTTP (http)
This suggests that multiple workloads are consuming more memory than their requests.
The correct investigation should examine their memory trends, limits, application behaviour and the node’s remaining capacity.
Do not immediately assume that application-a is the only problem because it has the highest usage.
Inspect all contributing workloads and system processes.
Step 6: Understand the Result
If the kubelet evicts a Pod because of node pressure, the Pod has failed and is normally replaced by its controlling Deployment, StatefulSet or other workload controller.
The replacement may be scheduled on another suitable node if capacity is available.
Remember that node-pressure eviction is not the same as an ordinary API-initiated eviction. Kubernetes documents that node-pressure eviction does not respect a PodDisruptionBudget or the Pod’s normal termination grace period in the same way.
Therefore, a PDB should not be treated as protection against node memory starvation.
Source: Kubernetes Node-pressure Eviction.
How to Compare Both Problems During an Incident
Use this diagnosis table before changing any resources.
| Question | Container OOM | Node MemoryPressure |
|---|---|---|
Is OOMKilled recorded? | Strong evidence | Possible, especially if kernel OOM occurs before kubelet eviction |
Is MemoryPressure=True? | Not required | Expected when pressure is currently recognised |
Is Reason: Evicted present? | Not typical of an ordinary container limit OOM | Strong evidence of kubelet eviction |
| Is the memory limit too low? | Possible direct cause | May contribute to aggregate pressure, but not always |
| Are several Pods affected? | Not necessary | Common clue |
| Are system processes consuming memory? | Not needed to explain a cgroup-limit OOM | Important to investigate |
| Should the container limit be increased? | Only after measuring workload needs | Not automatically |
| Should node capacity be reviewed? | May be relevant | Usually important |
No single field should be interpreted in isolation.
A container can be OOMKilled while a node is also under MemoryPressure. In a rapidly developing node incident, the kernel can act before the kubelet has recorded the node condition.
The event timeline matters.
How to Investigate Exit Code 137 Correctly
Exit code 137 is frequently misunderstood.
It is commonly associated with SIGKILL, but it does not identify the reason by itself.
Start with:
kubectl describe pod <pod-name> -n <namespace>Code language: HTML, XML (xml)
Then inspect the previous container logs when the container has restarted:
kubectl logs <pod-name> \
-n <namespace> --previousCode language: HTML, XML (xml)
Compare:
- Last termination reason
- Exit code
- Restart count
- Pod events
- Node conditions
- Node memory history
- Application logs
Example A: Confirmed Container OOM
Last State:
Terminated:
Reason: OOMKilled
Exit Code: 137Code language: PHP (php)
This supports a container cgroup memory-limit OOM diagnosis.
Example B: Generic SIGKILL
Last State:
Terminated:
Reason: Error
Exit Code: 137Code language: JavaScript (javascript)
This only confirms that the process was killed with SIGKILL.
Investigate kubelet events, eviction messages, manual termination and node-level OOM records.
Microsoft’s AKS guidance documents both patterns and explains why exit code 137 alone is not enough.
How QoS Classes Affect Memory Eviction
Kubernetes assigns a Pod one of three Quality of Service classes:
- Guaranteed
- Burstable
- BestEffort
These classes depend on resource requests and limits.
Guaranteed
For the standard container-level classification, every container needs matching positive CPU and memory requests and limits.
Example:
resources:
requests:
memory: "256Mi"
cpu: "500m"
limits:
memory: "256Mi"
cpu: "500m"Code language: JavaScript (javascript)
This Pod meets the usual Guaranteed criteria when all its containers follow the same rule.
Burstable
A Pod is Burstable when it has at least one CPU or memory request or limit but does not meet the Guaranteed criteria.
Example:
resources:
requests:
memory: "128Mi"
limits:
memory: "512Mi"Code language: JavaScript (javascript)
It has a memory request and a larger limit.
BestEffort
A Pod is BestEffort when it has no CPU or memory requests or limits at the Pod or container level.
Example:
containers:
- name: example
image: nginx
BestEffort workloads do not have memory reservations or limits from these resource fields.
They can therefore become vulnerable when the node has insufficient available memory.
Important Eviction Detail
Do not assume that Kubernetes uses a simple fixed order of BestEffort, Burstable and Guaranteed Pods for every eviction.
The kubelet’s documented ranking considers whether memory usage exceeds requests, Pod Priority and usage relative to requests.
The kernel also uses OOM scoring adjustments for node-level OOM handling.
References:
Common Root Causes of Kubernetes Memory Problems
1. Memory Limits Are Too Low
An application may legitimately need more memory than its configured limit.
A limit should be based on observed application requirements, expected peak usage and a suitable safety margin.
2. Application Memory Leak
Memory usage increases over time and does not return to its expected baseline.
Possible causes include:
- Unreleased objects
- Growing application caches
- Unbounded queues
- Memory retained by background tasks
- Native or off-heap allocations
Use application profiling and time-series memory metrics to investigate the pattern.
3. Large In-Memory Caches
Caching can improve response time, but an unbounded cache can consume increasing amounts of memory.
Configure cache limits and monitor memory behaviour under representative workloads.
4. Memory-Backed emptyDir Volumes
A memory-backed emptyDir uses tmpfs.
Its consumption is counted against container or Pod memory rather than ordinary local ephemeral storage.
An unexpectedly large temporary data directory can therefore contribute to OOM problems.
5. Sidecar Memory Consumption
A Pod’s memory budget must account for its containers.
For example, a service mesh proxy, logging sidecar or monitoring agent can increase total Pod memory use.
Review every container rather than only the main application.
6. Node Overcommitment
The sum of memory requests can look acceptable while actual usage rises above those requests.
During simultaneous traffic spikes, many Burstable containers may consume their additional allowance.
The resulting aggregate memory demand can create node pressure.
How to Fix OOMKilled and MemoryPressure Problems
Choose a correction based on the evidence.
Fix Container-Level OOM
- Inspect the current and previous container logs.
- Identify the application memory pattern.
- Review container requests and limits.
- Profile memory-intensive application code.
- Check caches, queues and temporary memory storage.
- Increase the limit only when measured requirements justify it.
- Update the request to reflect realistic scheduling needs.
- Monitor the workload after redeployment.
Do not use a higher memory limit as the only response to a suspected memory leak.
Fix Node-Level MemoryPressure
- Identify all high-memory Pods on the affected node.
- Check whether usage exceeds declared requests.
- Inspect system daemon and operating-system memory.
- Review kubelet eviction settings and reserved memory.
- Check whether memory is being used by tmpfs volumes or sidecars.
- Correct unrealistic requests and limits.
- Move workloads or add suitable node capacity when necessary.
- Review Pod Priority and QoS policies.
- Confirm node memory has recovered.
Do not lower every container’s request simply to make the scheduler fit more Pods.
That can create more runtime overcommitment.
Monitoring Kubernetes Memory Before It Becomes an Incident
A single kubectl top command cannot explain memory behaviour over time.
Use monitoring to understand:
- Current memory usage
- Historical peaks
- Container restarts
- OOM events
- Node MemoryPressure
- Pod evictions
- Memory requests and limits
- Application memory trends
With Prometheus and a compatible cAdvisor or kubelet metrics pipeline, teams commonly monitor metrics such as:
container_memory_working_set_bytes
container_memory_rss
Metric availability and labels depend on the monitoring stack.
kubectl top shows a recent sampled value through the Metrics API. It is useful for quick checks, but it can miss short-lived memory spikes that trigger an OOM event.
For deeper Linux cgroup v2 investigations, the kernel also exposes memory counters in files such as memory.current and memory.events.
These can help identify memory-limit activity and OOM kills when the operator has appropriate node-level access.
Source: Linux Kernel cgroup v2 Documentation.
Final Kubernetes Debugging Checklist
Container-Level OOM
- Inspect
kubectl describe pod. - Check the exact last termination reason.
- Confirm whether
OOMKilledis recorded. - Review exit code and restart count.
- Retrieve previous container logs.
- Inspect memory requests and limits.
- Check all containers and sidecars.
- Review application memory trends.
- Investigate memory-backed volumes.
- Verify the correction after redeployment.
Node-Level MemoryPressure
- Inspect
kubectl describe node. - Check the
MemoryPressurecondition. - Inspect node memory metrics.
- Find high-memory Pods.
- Review evicted Pod messages.
- Check requests against actual usage.
- Inspect system and daemon memory.
- Review kubelet eviction thresholds.
- Check node reserved memory.
- Confirm memory availability has recovered.
Frequently Asked Questions
Is OOMKilled the same as MemoryPressure?
No. OOMKilled usually describes a process killed by a container or cgroup memory OOM event. MemoryPressure is a node condition indicating that available memory reached a kubelet eviction threshold.
Can a Pod be OOMKilled when MemoryPressure is False?
Yes. A container can exceed its own memory limit even when its node has enough available memory. Node MemoryPressure is not required for a container-level cgroup OOM.
Does exit code 137 always mean OOMKilled?
No. Exit code 137 indicates SIGKILL. Check the container’s termination reason, events and node condition before identifying the cause.
What is the difference between OOMKilled and Evicted?
OOMKilled records an out-of-memory termination for a container. Evicted indicates that Kubernetes terminated the Pod to reclaim a node resource or because another eviction process applied.
Can increasing memory requests fix OOMKilled?
Not by itself. A request influences scheduling and can affect node-pressure behaviour. The container memory limit is the relevant cgroup ceiling for an ordinary container-limit OOM.
Should I increase the container memory limit?
Only when measured usage shows that the application legitimately requires more memory. Investigate leaks, caches, temporary storage and sidecars before changing the limit.
Does a Guaranteed Pod still get killed during node OOM?
Guaranteed QoS gives stronger protection, but it is not absolute immunity from every node-level OOM event. The kernel and kubelet still need to protect node stability under extreme conditions.
Can a PodDisruptionBudget prevent MemoryPressure eviction?
No. Kubernetes node-pressure eviction does not respect a PodDisruptionBudget in the same way as API-initiated eviction. Critical services still need enough capacity and suitable workload design.
Does Kubernetes MemoryPressure always mean that a container reached its limit?
No. MemoryPressure concerns available memory across the node. A node can reach an eviction threshold even when individual containers remain below their limits.
Conclusion
OOMKilled and MemoryPressure are related, but they are not interchangeable.
A container-level OOM usually points toward its cgroup memory limit. Node MemoryPressure points toward insufficient available memory on the entire node.
Start with the exact termination reason. Then inspect Pod events, resource requests, container limits and node conditions.
Use the controlled OOM lab to understand container-level termination. Use node telemetry and eviction records to investigate node-level memory pressure.
The most effective fix addresses the source of memory growth or overcommitment. Simply increasing limits or restarting Pods can hide the symptoms without solving the underlying problem.








