{"id":3487,"date":"2026-12-04T13:06:08","date_gmt":"2026-12-04T13:06:08","guid":{"rendered":"https:\/\/www.rajeshkumar.xyz\/blog\/?p=3487"},"modified":"2026-12-04T13:06:13","modified_gmt":"2026-12-04T13:06:13","slug":"oomkilled-vs-memory-pressure-a-kubernetes-debugging-lab","status":"publish","type":"post","link":"https:\/\/www.rajeshkumar.xyz\/blog\/oomkilled-vs-memory-pressure-a-kubernetes-debugging-lab\/","title":{"rendered":"OOMKilled vs Memory Pressure: A Kubernetes Debugging Lab"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">These situations look similar at first. Both can cause application failures, container restarts and service disruptions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, <strong>OOMKilled and MemoryPressure describe different parts of Kubernetes memory management.<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>OOMKilled<\/code> usually indicates that the container reached its cgroup memory limit and the Linux OOM killer terminated a process.<\/li>\n\n\n\n<li><code>MemoryPressure<\/code> is a Kubernetes node condition. It indicates that available node memory has reached a configured eviction threshold.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This distinction matters when investigating production incidents.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">OOMKilled vs MemoryPressure: What Is the Difference?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Start with this comparison.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Area<\/th><th>OOMKilled<\/th><th>Node MemoryPressure<\/th><\/tr><tr><td>Meaning<\/td><td>A process was killed by an out-of-memory event<\/td><td>Available node memory reached an eviction threshold<\/td><\/tr><tr><td>Main scope<\/td><td>Container or cgroup<\/td><td>Kubernetes node<\/td><\/tr><tr><td>Typical trigger<\/td><td>Container memory limit exceeded<\/td><td>Node memory becoming insufficient<\/td><\/tr><tr><td>Main enforcement<\/td><td>Linux kernel OOM mechanism<\/td><td>Kubelet eviction manager<\/td><\/tr><tr><td>Common evidence<\/td><td>Container termination reason <code>OOMKilled<\/code><\/td><td>Node condition <code>MemoryPressure=True<\/code><\/td><\/tr><tr><td>Pod outcome<\/td><td>Container may restart<\/td><td>Pod may be terminated and replaced<\/td><\/tr><tr><td>Exit code<\/td><td>Commonly 137<\/td><td>Can vary<\/td><\/tr><tr><td>Main investigation<\/td><td>Container memory usage and limits<\/td><td>Node memory, other Pods and kubelet events<\/td><\/tr><tr><td>Primary fix<\/td><td>Correct application usage or container resources<\/td><td>Restore node memory headroom and investigate aggregate usage<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Kubernetes documents that container memory limits are enforced through Linux cgroups. When memory consumption cannot be reclaimed, the kernel may terminate a process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Node-pressure eviction is a separate process in which the kubelet proactively terminates Pods to recover node resources.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sources: <a href=\"https:\/\/kubernetes.io\/docs\/concepts\/configuration\/manage-resources-containers\/\">Kubernetes Resource Management<\/a> and <a href=\"https:\/\/kubernetes.io\/docs\/concepts\/scheduling-eviction\/node-pressure-eviction\/\">Node-pressure Eviction<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Does OOMKilled Mean in Kubernetes?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">OOMKilled means that a process inside a container was terminated by an out-of-memory mechanism.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On Linux Kubernetes nodes, container memory limits are enforced using control groups, commonly called cgroups.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Consider this container configuration:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">resources:\n  requests:\n    memory: <span class=\"hljs-string\">\"128Mi\"<\/span>\n  <span class=\"hljs-attr\">limits<\/span>:\n    memory: <span class=\"hljs-string\">\"256Mi\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">The container requests 128 MiB of memory and has a configured limit of 256 MiB.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the container requires more memory than its limit allows, the kernel may invoke its OOM mechanism.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the container&#8217;s main process is terminated, Kubernetes records the termination information. The container may restart depending on the Pod&#8217;s restart policy.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Common Signs of OOMKilled<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">kubectl <span class=\"hljs-keyword\">get<\/span> pods<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Then inspect the affected Pod:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\">kubectl describe pod <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">pod-name<\/span>&gt;<\/span> -n <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">namespace<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Look for output similar to:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">Last State:     Terminated\n  Reason:       OOMKilled\n  <span class=\"hljs-keyword\">Exit<\/span> Code:    <span class=\"hljs-number\">137<\/span>\n\nRestart Count:  <span class=\"hljs-number\">3<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">This indicates that the container was terminated and has restarted three times.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check the exact termination state:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">kubectl <span class=\"hljs-keyword\">get<\/span> pod &lt;pod-name&gt; -n &lt;namespace&gt; \\\n  -o jsonpath='{range .status.containerStatuses&#91;*]}{.name}{<span class=\"hljs-string\">\" reason=\"<\/span>}{.lastState.terminated.reason}{<span class=\"hljs-string\">\" exit=\"<\/span>}{.lastState.terminated.exitCode}{<span class=\"hljs-string\">\" restarts=\"<\/span>}{.restartCount}{<span class=\"hljs-string\">\"\\n\"<\/span>}{end}<span class=\"hljs-string\">'<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">This command is useful when the container has already restarted.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the container is currently terminated rather than restarted, inspect <code>.state.terminated<\/code> instead of <code>.lastState.terminated<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Is Exit Code 137 Always OOMKilled?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Exit code 137 usually means that a process received. <code>SIGKILL<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">OOM termination is one possible reason.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Other causes can include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Kubelet-initiated termination<\/li>\n\n\n\n<li>Node-pressure eviction<\/li>\n\n\n\n<li>Manual container termination<\/li>\n\n\n\n<li>An external process sending SIGKILL<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Therefore, do not diagnose OOMKilled using exit code 137 alone.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check the recorded termination reason, Pod events and node conditions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Microsoft&#8217;s AKS troubleshooting guidance also makes this distinction between <code>OOMKilled<\/code> and a generic <code>Error<\/code> with exit code 137.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Source: <a href=\"https:\/\/learn.microsoft.com\/en-us\/troubleshoot\/azure\/azure-kubernetes\/availability-performance\/identify-memory-saturation-aks\">Troubleshoot Memory Saturation in AKS<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Does MemoryPressure Mean in Kubernetes?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">MemoryPressure is a condition reported on a Kubernetes Node.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It indicates that available node memory has reached an eviction threshold.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Kubernetes uses the kubelet to monitor resource availability.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One important signal is:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">memory<\/span><span class=\"hljs-selector-class\">.available<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">When this signal reaches the configured eviction threshold, the node can enter MemoryPressure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check the nodes:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">kubectl <span class=\"hljs-keyword\">get<\/span> nodes<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Inspect a particular node:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\">kubectl describe node <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">node-name<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Look for:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">Conditions:\n  Type             Status\n  ----             ------\n  MemoryPressure   <span class=\"hljs-keyword\">True<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">The exact reason and message depend on the node&#8217;s condition and the incident.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can also display the condition directly:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">kubectl <span class=\"hljs-keyword\">get<\/span> node &lt;node-name&gt; \\\n  -o jsonpath='{range .status.conditions&#91;?(@.type==<span class=\"hljs-string\">\"MemoryPressure\"<\/span>)]}{.status}{<span class=\"hljs-string\">\" reason=\"<\/span>}{.reason}{<span class=\"hljs-string\">\" message=\"<\/span>}{.message}{<span class=\"hljs-string\">\"\\n\"<\/span>}{end}<span class=\"hljs-string\">'<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Why Does Node MemoryPressure Occur?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Possible causes include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Multiple Pods consuming more memory than expected<\/li>\n\n\n\n<li>Containers using more memory than their requests<\/li>\n\n\n\n<li>Memory leaks across workloads<\/li>\n\n\n\n<li>Large in-memory caches<\/li>\n\n\n\n<li>High traffic or workload spikes<\/li>\n\n\n\n<li>Memory-backed <code>emptyDir<\/code> volumes<\/li>\n\n\n\n<li>Sidecars and monitoring agents<\/li>\n\n\n\n<li>System daemons using unreserved memory<\/li>\n\n\n\n<li>Insufficient node capacity<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Node memory pressure is an aggregate problem.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The container with the largest memory usage is not automatically the only cause.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How Does Kubernetes Respond to Node Memory Pressure?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When node memory becomes scarce, the kubelet attempts to reclaim resources before evicting end-user Pods.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If available memory remains below the relevant threshold, the kubelet can begin terminating Pods.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It considers:<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Whether a Pod&#8217;s memory usage exceeds its requests.<\/li>\n\n\n\n<li>Pod Priority.<\/li>\n\n\n\n<li>Memory usage relative to requests.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">This matters because a Pod&#8217;s Quality of Service class alone does not fully determine kubelet eviction order.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A BestEffort Pod may be vulnerable, but the kubelet uses the more detailed eviction criteria above.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The kubelet can also assign <code>oom_score_adj<\/code> values based on Pod QoS when the kernel itself must handle a node-level OOM event.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This means a node-wide kernel OOM kill and a normal kubelet eviction are not identical processes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sources: <a href=\"https:\/\/kubernetes.io\/docs\/concepts\/scheduling-eviction\/node-pressure-eviction\/\">Kubernetes Node-pressure Eviction<\/a> and <a href=\"https:\/\/kubernetes.io\/docs\/concepts\/workloads\/pods\/pod-qos\/\">Pod QoS Classes<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Understand Kubernetes Memory Requests and Limits<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Requests and limits control different parts of resource management.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Memory Request<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A memory request tells Kubernetes how much memory a container needs for scheduling.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The scheduler uses requests when deciding whether a Pod fits on a node.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">resources:\n  requests:\n    memory: <span class=\"hljs-string\">\"128Mi\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">A request is not a hard memory ceiling.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A container can use more than its request when resources are available.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, using more than its request becomes important when the node experiences pressure.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Memory Limit<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A memory limit sets a maximum memory boundary for the container&#8217;s cgroup.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">resources:\n  limits:\n    memory: <span class=\"hljs-string\">\"256Mi\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">If the container exceeds the limit and memory cannot be reclaimed, the kernel may kill a process.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Requests and Limits Together<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Consider:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">resources:\n  requests:\n    memory: <span class=\"hljs-string\">\"128Mi\"<\/span>\n  <span class=\"hljs-attr\">limits<\/span>:\n    memory: <span class=\"hljs-string\">\"256Mi\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Here:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The scheduler uses 128 MiB as the request.<\/li>\n\n\n\n<li>The kernel-enforced container memory boundary is 256 MiB.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The gap between request and limit allows the container to use additional memory when available.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But if several containers use that extra memory at the same time, the node may experience pressure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is why requests should reflect realistic workload requirements rather than arbitrary small numbers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Practical Lab 1: Reproduce a Container-Level OOMKilled Event<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This lab creates a small Python container that continuously allocates memory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Its memory limit is deliberately low so that you can observe a controlled cgroup OOM event.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Safety:<\/strong> 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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Lab Requirements<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You need:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A working Kubernetes cluster<\/li>\n\n\n\n<li><code>kubectl<\/code> access<\/li>\n\n\n\n<li>Permission to create a namespace and Pod<\/li>\n\n\n\n<li>A container runtime able to pull <code>python:3.12-slim<\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Check the cluster:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">kubectl version\nkubectl <span class=\"hljs-keyword\">get<\/span> nodes\nkubectl cluster-info<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Create a namespace:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">kubectl create <span class=\"hljs-keyword\">namespace<\/span> <span class=\"hljs-title\">oom<\/span>-<span class=\"hljs-title\">lab<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Step 1: Create the Memory Stress Pod<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Save the following manifest as <code>oom-demo.yaml<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-16\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">apiVersion: v1\n<span class=\"hljs-attr\">kind<\/span>: Pod\n<span class=\"hljs-attr\">metadata<\/span>:\n  name: cgroup-oom-demo\n  <span class=\"hljs-attr\">namespace<\/span>: oom-lab\n  <span class=\"hljs-attr\">labels<\/span>:\n    app: cgroup-oom-demo\n<span class=\"hljs-attr\">spec<\/span>:\n  restartPolicy: Never\n  <span class=\"hljs-attr\">containers<\/span>:\n    - name: allocator\n      <span class=\"hljs-attr\">image<\/span>: python:<span class=\"hljs-number\">3.12<\/span>-slim\n      <span class=\"hljs-attr\">command<\/span>:\n        - python\n        - -u\n        - -c\n      <span class=\"hljs-attr\">args<\/span>:\n        - |\n          <span class=\"hljs-keyword\">import<\/span> time\n\n          chunks = &#91;]\n          total = <span class=\"hljs-number\">0<\/span>\n\n          <span class=\"hljs-keyword\">while<\/span> True:\n              chunks.append(bytearray(<span class=\"hljs-number\">8<\/span> * <span class=\"hljs-number\">1024<\/span> * <span class=\"hljs-number\">1024<\/span>))\n              total += <span class=\"hljs-number\">8<\/span>\n\n              print(\n                  f<span class=\"hljs-string\">\"Allocated approximately {total} MiB\"<\/span>,\n                  flush=True\n              )\n\n              time.sleep(<span class=\"hljs-number\">1<\/span>)\n\n      <span class=\"hljs-attr\">resources<\/span>:\n        requests:\n          memory: <span class=\"hljs-string\">\"32Mi\"<\/span>\n        <span class=\"hljs-attr\">limits<\/span>:\n          memory: <span class=\"hljs-string\">\"64Mi\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-16\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Apply the manifest:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-17\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">kubectl<\/span> <span class=\"hljs-selector-tag\">apply<\/span> <span class=\"hljs-selector-tag\">-f<\/span> <span class=\"hljs-selector-tag\">oom-demo<\/span><span class=\"hljs-selector-class\">.yaml<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-17\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Watch the Pod:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-18\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">kubectl <span class=\"hljs-keyword\">get<\/span> pod cgroup-oom-demo -n oom-lab -w<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-18\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">The Python process continuously allocates 8 MiB blocks.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Eventually, its memory usage should exceed the configured 64 MiB limit and the kernel should terminate the process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Pod uses <code>restartPolicy: Never<\/code> so that Kubernetes does not repeatedly restart the container during this demonstration.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Inspect the Container Termination<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">kubectl describe pod cgroup-oom-demo -n oom-lab<\/code><\/span><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Look for the termination information.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">An expected result is similar to:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-19\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">State:       Terminated\n  Reason:    OOMKilled\n  <span class=\"hljs-keyword\">Exit<\/span> Code: <span class=\"hljs-number\">137<\/span>\n\nRestart Count: <span class=\"hljs-number\">0<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-19\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">The exact displayed fields can vary with the Kubernetes version and runtime.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The important evidence is the recorded <code>OOMKilled<\/code> termination reason.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Inspect the Container Logs<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">kubectl logs cgroup-oom-demo -n oom-lab<\/code><\/span><\/pre>\n\n\n<p class=\"wp-block-paragraph\">You may see output similar to:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">Allocated approximately 8 MiB\nAllocated approximately 16 MiB\nAllocated approximately 24 MiB\nAllocated approximately 32 MiB\nAllocated approximately 40 MiB<\/code><\/span><\/pre>\n\n\n<p class=\"wp-block-paragraph\">The output stops when the process is terminated.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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&#8217;s consumption.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Check the Pod&#8217;s Detailed Status<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-20\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">kubectl <span class=\"hljs-keyword\">get<\/span> pod cgroup-oom-demo -n oom-lab -o yaml<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-20\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Inspect:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>status.phase<\/code><\/li>\n\n\n\n<li><code>status.containerStatuses<\/code><\/li>\n\n\n\n<li><code>state.terminated<\/code><\/li>\n\n\n\n<li><code>reason<\/code><\/li>\n\n\n\n<li><code>exitCode<\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Because this Pod was configured with <code>restartPolicy: Never<\/code>, its phase is expected to become <code>Failed<\/code> after the container terminates.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Check the Node Condition<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now inspect the node that ran the Pod:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-21\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">kubectl <span class=\"hljs-keyword\">get<\/span> pod cgroup-oom-demo \\\n  -n oom-lab -o wide<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-21\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Identify the node and inspect it:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-22\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\">kubectl describe node <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">node-name<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-22\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">For this container-limit experiment, the node may still show:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-23\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">MemoryPressure   <span class=\"hljs-keyword\">False<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-23\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">That is an important finding.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The container was OOMKilled even though the node did not need to enter MemoryPressure.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is the central difference demonstrated by Lab 1.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Practical Lab 2: Diagnose Node-Level Memory Pressure<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This second exercise is an observation and incident-replay lab.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It does not deliberately exhaust node memory. Creating artificial node-wide memory pressure can destabilise a cluster and interrupt unrelated workloads.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Check All Node Conditions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-24\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">kubectl <span class=\"hljs-keyword\">get<\/span> nodes<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-24\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Select the node that experienced the incident:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-25\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\">kubectl describe node <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">node-name<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-25\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Review:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>MemoryPressure<\/code><\/li>\n\n\n\n<li><code>Ready<\/code><\/li>\n\n\n\n<li>Node capacity<\/li>\n\n\n\n<li>Allocatable memory<\/li>\n\n\n\n<li>Node events<\/li>\n\n\n\n<li>Conditions and messages<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Check Node Memory Usage<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If Metrics Server is installed, run:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">kubectl top nodes<\/code><\/span><\/pre>\n\n\n<p class=\"wp-block-paragraph\">This provides a current resource-usage sample.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It does not provide historical memory peaks.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Identify High-Memory Pods<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">kubectl top pods -A --sort-by=memory<\/code><\/span><\/pre>\n\n\n<p class=\"wp-block-paragraph\">To inspect containers in one Pod:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-26\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\">kubectl top pod <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">pod-name<\/span>&gt;<\/span> \\\n  -n <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">namespace<\/span>&gt;<\/span> --containers<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-26\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Metrics Server is required for these commands.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use Prometheus, cloud monitoring or another time-series system when historical memory graphs are needed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Find Evicted Pods<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">List failed Pods:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-27\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">kubectl <span class=\"hljs-keyword\">get<\/span> pods -A \\\n  --field-selector=status.phase=Failed<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-27\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Inspect any Pod that appears to have been evicted:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-28\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\">kubectl describe pod <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">pod-name<\/span>&gt;<\/span> -n <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">namespace<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-28\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Look for a Pod termination reason such as:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-29\" data-shcb-language-name=\"HTTP\" data-shcb-language-slug=\"http\"><span><code class=\"hljs language-http\"><span class=\"hljs-attribute\">Reason<\/span>: Evicted<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-29\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTTP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">http<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">The message may indicate that the node was low on memory.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Review Recent Events<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-30\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">kubectl <span class=\"hljs-keyword\">get<\/span> events -A \\\n  --sort-by=.metadata.creationTimestamp<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-30\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">On Linux or macOS, you can filter the output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-31\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">kubectl <span class=\"hljs-keyword\">get<\/span> events -A \\\n  --sort-by=.metadata.creationTimestamp |\n  grep -Ei 'Evicted|MemoryPressure|OOM|Killing'<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-31\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">In PowerShell, use <code>Select-String<\/code> with the same patterns.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example Incident: Node MemoryPressure<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The following is an illustrative incident, not a live cluster capture.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Suppose the investigation shows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-32\" data-shcb-language-name=\"HTTP\" data-shcb-language-slug=\"http\"><span><code class=\"hljs language-http\"><span class=\"hljs-attribute\">Node<\/span>: worker-01\n\nMemoryPressure: True\n\nPod: application-a\nMemory request: 256Mi\nObserved usage: 850Mi\n\nPod: application-b\nMemory request: 512Mi\nObserved usage: 700Mi\n\nPod: cache-service\nMemory request: 128Mi\nObserved usage: 600Mi\n\nNode memory available: Below eviction threshold<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-32\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTTP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">http<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">This suggests that multiple workloads are consuming more memory than their requests.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The correct investigation should examine their memory trends, limits, application behaviour and the node&#8217;s remaining capacity.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do not immediately assume that <code>application-a<\/code> is the only problem because it has the highest usage.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Inspect all contributing workloads and system processes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 6: Understand the Result<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The replacement may be scheduled on another suitable node if capacity is available.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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&#8217;s normal termination grace period in the same way.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Therefore, a PDB should not be treated as protection against node memory starvation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Source: <a href=\"https:\/\/kubernetes.io\/docs\/concepts\/scheduling-eviction\/node-pressure-eviction\/\">Kubernetes Node-pressure Eviction<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Compare Both Problems During an Incident<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use this diagnosis table before changing any resources.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Question<\/th><th>Container OOM<\/th><th>Node MemoryPressure<\/th><\/tr><tr><td>Is <code>OOMKilled<\/code> recorded?<\/td><td>Strong evidence<\/td><td>Possible, especially if kernel OOM occurs before kubelet eviction<\/td><\/tr><tr><td>Is <code>MemoryPressure=True<\/code>?<\/td><td>Not required<\/td><td>Expected when pressure is currently recognised<\/td><\/tr><tr><td>Is <code>Reason: Evicted<\/code> present?<\/td><td>Not typical of an ordinary container limit OOM<\/td><td>Strong evidence of kubelet eviction<\/td><\/tr><tr><td>Is the memory limit too low?<\/td><td>Possible direct cause<\/td><td>May contribute to aggregate pressure, but not always<\/td><\/tr><tr><td>Are several Pods affected?<\/td><td>Not necessary<\/td><td>Common clue<\/td><\/tr><tr><td>Are system processes consuming memory?<\/td><td>Not needed to explain a cgroup-limit OOM<\/td><td>Important to investigate<\/td><\/tr><tr><td>Should the container limit be increased?<\/td><td>Only after measuring workload needs<\/td><td>Not automatically<\/td><\/tr><tr><td>Should node capacity be reviewed?<\/td><td>May be relevant<\/td><td>Usually important<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">No single field should be interpreted in isolation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The event timeline matters.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Investigate Exit Code 137 Correctly<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Exit code 137 is frequently misunderstood.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is commonly associated with SIGKILL, but it does not identify the reason by itself.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Start with:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-33\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\">kubectl describe pod <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">pod-name<\/span>&gt;<\/span> -n <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">namespace<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-33\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Then inspect the previous container logs when the container has restarted:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-34\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\">kubectl logs <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">pod-name<\/span>&gt;<\/span> \\\n  -n <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">namespace<\/span>&gt;<\/span> --previous<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-34\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Compare:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Last termination reason<\/li>\n\n\n\n<li>Exit code<\/li>\n\n\n\n<li>Restart count<\/li>\n\n\n\n<li>Pod events<\/li>\n\n\n\n<li>Node conditions<\/li>\n\n\n\n<li>Node memory history<\/li>\n\n\n\n<li>Application logs<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Example A: Confirmed Container OOM<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-35\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">Last State:\n  Terminated:\n    Reason: OOMKilled\n    <span class=\"hljs-keyword\">Exit<\/span> Code: <span class=\"hljs-number\">137<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-35\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">This supports a container cgroup memory-limit OOM diagnosis.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example B: Generic SIGKILL<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-36\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">Last State:\n  Terminated:\n    Reason: <span class=\"hljs-built_in\">Error<\/span>\n    Exit Code: <span class=\"hljs-number\">137<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-36\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">This only confirms that the process was killed with SIGKILL.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Investigate kubelet events, eviction messages, manual termination and node-level OOM records.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Microsoft&#8217;s AKS guidance documents both patterns and explains why exit code 137 alone is not enough.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How QoS Classes Affect Memory Eviction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Kubernetes assigns a Pod one of three Quality of Service classes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Guaranteed<\/li>\n\n\n\n<li>Burstable<\/li>\n\n\n\n<li>BestEffort<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">These classes depend on resource requests and limits.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Guaranteed<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For the standard container-level classification, every container needs matching positive CPU and memory requests and limits.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-37\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">resources:\n  requests:\n    memory: <span class=\"hljs-string\">\"256Mi\"<\/span>\n    <span class=\"hljs-attr\">cpu<\/span>: <span class=\"hljs-string\">\"500m\"<\/span>\n  <span class=\"hljs-attr\">limits<\/span>:\n    memory: <span class=\"hljs-string\">\"256Mi\"<\/span>\n    <span class=\"hljs-attr\">cpu<\/span>: <span class=\"hljs-string\">\"500m\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-37\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">This Pod meets the usual Guaranteed criteria when all its containers follow the same rule.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Burstable<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A Pod is Burstable when it has at least one CPU or memory request or limit but does not meet the Guaranteed criteria.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-38\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">resources:\n  requests:\n    memory: <span class=\"hljs-string\">\"128Mi\"<\/span>\n  <span class=\"hljs-attr\">limits<\/span>:\n    memory: <span class=\"hljs-string\">\"512Mi\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-38\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">It has a memory request and a larger limit.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">BestEffort<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A Pod is BestEffort when it has no CPU or memory requests or limits at the Pod or container level.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">containers:\n  - name: example\n    image: nginx<\/code><\/span><\/pre>\n\n\n<p class=\"wp-block-paragraph\">BestEffort workloads do not have memory reservations or limits from these resource fields.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">They can therefore become vulnerable when the node has insufficient available memory.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Important Eviction Detail<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Do not assume that Kubernetes uses a simple fixed order of BestEffort, Burstable and Guaranteed Pods for every eviction.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The kubelet&#8217;s documented ranking considers whether memory usage exceeds requests, Pod Priority and usage relative to requests.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The kernel also uses OOM scoring adjustments for node-level OOM handling.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">References:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/kubernetes.io\/docs\/concepts\/workloads\/pods\/pod-qos\/\">Pod Quality of Service Classes<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/kubernetes.io\/docs\/concepts\/scheduling-eviction\/node-pressure-eviction\/\">Node-pressure Eviction<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Common Root Causes of Kubernetes Memory Problems<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Memory Limits Are Too Low<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">An application may legitimately need more memory than its configured limit.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A limit should be based on observed application requirements, expected peak usage and a suitable safety margin.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Application Memory Leak<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Memory usage increases over time and does not return to its expected baseline.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Possible causes include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Unreleased objects<\/li>\n\n\n\n<li>Growing application caches<\/li>\n\n\n\n<li>Unbounded queues<\/li>\n\n\n\n<li>Memory retained by background tasks<\/li>\n\n\n\n<li>Native or off-heap allocations<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Use application profiling and time-series memory metrics to investigate the pattern.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Large In-Memory Caches<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Caching can improve response time, but an unbounded cache can consume increasing amounts of memory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Configure cache limits and monitor memory behaviour under representative workloads.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. Memory-Backed emptyDir Volumes<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A memory-backed <code>emptyDir<\/code> uses tmpfs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Its consumption is counted against container or Pod memory rather than ordinary local ephemeral storage.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">An unexpectedly large temporary data directory can therefore contribute to OOM problems.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. Sidecar Memory Consumption<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A Pod&#8217;s memory budget must account for its containers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, a service mesh proxy, logging sidecar or monitoring agent can increase total Pod memory use.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Review every container rather than only the main application.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6. Node Overcommitment<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The sum of memory requests can look acceptable while actual usage rises above those requests.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">During simultaneous traffic spikes, many Burstable containers may consume their additional allowance.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The resulting aggregate memory demand can create node pressure.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Fix OOMKilled and MemoryPressure Problems<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Choose a correction based on the evidence.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Fix Container-Level OOM<\/h3>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Inspect the current and previous container logs.<\/li>\n\n\n\n<li>Identify the application memory pattern.<\/li>\n\n\n\n<li>Review container requests and limits.<\/li>\n\n\n\n<li>Profile memory-intensive application code.<\/li>\n\n\n\n<li>Check caches, queues and temporary memory storage.<\/li>\n\n\n\n<li>Increase the limit only when measured requirements justify it.<\/li>\n\n\n\n<li>Update the request to reflect realistic scheduling needs.<\/li>\n\n\n\n<li>Monitor the workload after redeployment.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Do not use a higher memory limit as the only response to a suspected memory leak.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Fix Node-Level MemoryPressure<\/h3>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Identify all high-memory Pods on the affected node.<\/li>\n\n\n\n<li>Check whether usage exceeds declared requests.<\/li>\n\n\n\n<li>Inspect system daemon and operating-system memory.<\/li>\n\n\n\n<li>Review kubelet eviction settings and reserved memory.<\/li>\n\n\n\n<li>Check whether memory is being used by tmpfs volumes or sidecars.<\/li>\n\n\n\n<li>Correct unrealistic requests and limits.<\/li>\n\n\n\n<li>Move workloads or add suitable node capacity when necessary.<\/li>\n\n\n\n<li>Review Pod Priority and QoS policies.<\/li>\n\n\n\n<li>Confirm node memory has recovered.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Do not lower every container&#8217;s request simply to make the scheduler fit more Pods.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That can create more runtime overcommitment.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Monitoring Kubernetes Memory Before It Becomes an Incident<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A single <code>kubectl top<\/code> command cannot explain memory behaviour over time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use monitoring to understand:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Current memory usage<\/li>\n\n\n\n<li>Historical peaks<\/li>\n\n\n\n<li>Container restarts<\/li>\n\n\n\n<li>OOM events<\/li>\n\n\n\n<li>Node MemoryPressure<\/li>\n\n\n\n<li>Pod evictions<\/li>\n\n\n\n<li>Memory requests and limits<\/li>\n\n\n\n<li>Application memory trends<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">With Prometheus and a compatible cAdvisor or kubelet metrics pipeline, teams commonly monitor metrics such as:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">container_memory_working_set_bytes\ncontainer_memory_rss<\/code><\/span><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Metric availability and labels depend on the monitoring stack.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>kubectl top<\/code> 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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For deeper Linux cgroup v2 investigations, the kernel also exposes memory counters in files such as <code>memory.current<\/code> and <code>memory.events<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">These can help identify memory-limit activity and OOM kills when the operator has appropriate node-level access.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Source: <a href=\"https:\/\/docs.kernel.org\/admin-guide\/cgroup-v2.html\">Linux Kernel cgroup v2 Documentation<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Final Kubernetes Debugging Checklist<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Container-Level OOM<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Inspect <code>kubectl describe pod<\/code>.<\/li>\n\n\n\n<li>Check the exact last termination reason.<\/li>\n\n\n\n<li>Confirm whether <code>OOMKilled<\/code> is recorded.<\/li>\n\n\n\n<li>Review exit code and restart count.<\/li>\n\n\n\n<li>Retrieve previous container logs.<\/li>\n\n\n\n<li>Inspect memory requests and limits.<\/li>\n\n\n\n<li>Check all containers and sidecars.<\/li>\n\n\n\n<li>Review application memory trends.<\/li>\n\n\n\n<li>Investigate memory-backed volumes.<\/li>\n\n\n\n<li>Verify the correction after redeployment.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Node-Level MemoryPressure<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Inspect <code>kubectl describe node<\/code>.<\/li>\n\n\n\n<li>Check the <code>MemoryPressure<\/code> condition.<\/li>\n\n\n\n<li>Inspect node memory metrics.<\/li>\n\n\n\n<li>Find high-memory Pods.<\/li>\n\n\n\n<li>Review evicted Pod messages.<\/li>\n\n\n\n<li>Check requests against actual usage.<\/li>\n\n\n\n<li>Inspect system and daemon memory.<\/li>\n\n\n\n<li>Review kubelet eviction thresholds.<\/li>\n\n\n\n<li>Check node reserved memory.<\/li>\n\n\n\n<li>Confirm memory availability has recovered.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Is OOMKilled the same as MemoryPressure?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can a Pod be OOMKilled when MemoryPressure is False?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Does exit code 137 always mean OOMKilled?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. Exit code 137 indicates SIGKILL. Check the container&#8217;s termination reason, events and node condition before identifying the cause.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What is the difference between OOMKilled and Evicted?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can increasing memory requests fix OOMKilled?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Should I increase the container memory limit?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Only when measured usage shows that the application legitimately requires more memory. Investigate leaks, caches, temporary storage and sidecars before changing the limit.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Does a Guaranteed Pod still get killed during node OOM?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can a PodDisruptionBudget prevent MemoryPressure eviction?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Does Kubernetes MemoryPressure always mean that a container reached its limit?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. MemoryPressure concerns available memory across the node. A node can reach an eviction threshold even when individual containers remain below their limits.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">OOMKilled and MemoryPressure are related, but they are not interchangeable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A container-level OOM usually points toward its cgroup memory limit. Node MemoryPressure points toward insufficient available memory on the entire node.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Start with the exact termination reason. Then inspect Pod events, resource requests, container limits and node conditions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use the controlled OOM lab to understand container-level termination. Use node telemetry and eviction records to investigate node-level memory pressure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction A Kubernetes container can restart because it exceeds its own memory limit. A Kubernetes node can also run out&#8230; <\/p>\n","protected":false},"author":7,"featured_media":3488,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[734,735,713],"tags":[753,142,70,170,754,747,755,752,751,26],"series":[],"class_list":["post-3487","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-careers","category-devops","category-devops-careers","tag-containermemory","tag-devops","tag-devopsschool","tag-kubernetes","tag-kubernetesdebugging","tag-kubernetestroubleshooting","tag-linuxcgroups","tag-memorypressure","tag-oomkilled","tag-sre"],"_links":{"self":[{"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/posts\/3487","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/comments?post=3487"}],"version-history":[{"count":1,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/posts\/3487\/revisions"}],"predecessor-version":[{"id":3489,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/posts\/3487\/revisions\/3489"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/media\/3488"}],"wp:attachment":[{"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/media?parent=3487"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/categories?post=3487"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/tags?post=3487"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/series?post=3487"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}