{"id":448,"date":"2025-10-24T12:08:43","date_gmt":"2025-10-24T12:08:43","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=448"},"modified":"2025-10-24T12:08:43","modified_gmt":"2025-10-24T12:08:43","slug":"kubernetes-swap","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=448","title":{"rendered":"Kubernetes Swap Explained With Practical Examples"},"content":{"rendered":"<p>In this guide, you will learn about Kubernetes Swap, how it works, and how to enable it in a <a href=\"https:\/\/devopscube.com\/setup-kubernetes-cluster-kubeadm\/\" rel=\"noreferrer\">Kubernetes cluster<\/a> and use it with pods.<\/p>\n<p>In this guide, you will learn about the following.<\/p>\n<ul>\n<li>How Kubernetes swap works<\/li>\n<li>Swap real world use cases<\/li>\n<li>Hands-on example to enable swap and test it.<\/li>\n<\/ul>\n<h2 id=\"what-is-kubernetes-swap\">What is Kubernetes Swap?<\/h2>\n<p>When you deploy a pod in <a href=\"https:\/\/devopscube.com\/kubernetes-tutorials-beginners\/\" rel=\"noreferrer\">Kubernetes<\/a>, each node uses its physical RAM to run containers.<\/p>\n<p>If a node runs out of memory, Kubernetes may start&nbsp;<strong>killing Pods <\/strong>(OOMKilled)&nbsp;to keep the node stable, even if some of those Pods haven&#8217;t crossed their own memory limits.<\/p>\n<p>To prevent this, Kubernetes provides the option to enable swap memory on nodes.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-blue\">\n<div class=\"kg-callout-emoji\">\ud83d\udca1<\/div>\n<div class=\"kg-callout-text\"><b><strong style=\"white-space: pre-wrap;\">swap<\/strong><\/b> is a part of a node\u2019s disk that the Linux kernel can use as extra &#8220;disk-based virtual memory&#8221;.<\/div>\n<\/div>\n<p>It is built on top of the <strong>Linux swap functionality<\/strong>, but Kubernetes adds its own control through the kubelet and container runtime to manage how <a href=\"https:\/\/devopscube.com\/kubernetes-pod\/\" rel=\"noreferrer\">pods<\/a> use it.<\/p>\n<p>Historically, Kubernetes required swap to be disabled on all nodes (kubelet wouldn&#8217;t start with swap enabled).<\/p>\n<p>However, Kubernetes now has support (in beta as of version 1.34) to allow using swap on nodes.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/10\/image-122.png\" class=\"kg-image\" alt=\"ram vs swap\" loading=\"lazy\" width=\"1920\" height=\"1034\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/10\/image-122.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/10\/image-122.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/10\/image-122.png 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/10\/image-122.png 1920w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<h2 id=\"use-case\">Use Case<\/h2>\n<p>The key use case for swap is for <strong>apps with large memory footprint<\/strong> but low active usage. <\/p>\n<p>For example, tools like&nbsp;<a href=\"https:\/\/devopscube.com\/jenkins-architecture-explained\/\" rel=\"noreferrer\"><strong>Jenkins<\/strong><\/a>&nbsp;or&nbsp;<a href=\"https:\/\/devopscube.com\/setup-and-configure-sonarqube-on-linux\/\" rel=\"noreferrer\"><strong>SonarQube<\/strong><\/a>&nbsp;run on the&nbsp;<strong>Java Virtual Machine (JVM)<\/strong>, which reserves a large amount of memory when it starts. Even if the app doesn\u2019t fully use that memory, the space stays allocated.<\/p>\n<p>In such cases, swap can help by moving the unused or old parts of memory (like inactive Java objects) to disk.<\/p>\n<p>Another example is applications that may occasionally experience <strong>short-term spikes<\/strong>. It can use swap as a safety buffer instead of being OOMKilled.<\/p>\n<p>For example,  batch processing jobs, report generation systems, or data import\/export operations.<\/p>\n<p>On resource-limited nodes (like <strong>edge devices or small VMs<\/strong>), swap provides a bit of extra breathing room for workloads when physical memory runs out.<\/p>\n<p>Even&nbsp;<strong>legacy <\/strong><a href=\"https:\/\/devopscube.com\/deploy-java-app-kubernetes\/\" rel=\"noreferrer\"><strong>Java-based apps<\/strong><\/a>&nbsp;such as Apache Tomcat, WebLogic, or JBoss can benefit from swap in the same way.<\/p>\n<h2 id=\"how-kubernetes-swap-works\">How Kubernetes Swap Works?<\/h2>\n<p>Below is an overall workflow of how Kubernetes Swap works.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/10\/image-116.png\" class=\"kg-image\" alt=\"Kubernetes Swap workflow\" loading=\"lazy\" width=\"1408\" height=\"1332\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/10\/image-116.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/10\/image-116.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/10\/image-116.png 1408w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>When a node\u2019s physical memory (RAM) is full, the kernel moves <strong>less-used memory pages <\/strong>(blocks of memory) to swap space on disk.<\/p>\n<p>This helps prevent the system from crashing due to  OOM (Out Of Memory) errors by providing a temporary buffer.<\/p>\n<p>Swap also comes with a&nbsp;<strong>trade-off<\/strong>. The disk I\/O is much slower than RAM, so performance can drop when the system starts using swap.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-blue\">\n<div class=\"kg-callout-emoji\">\u26a0\ufe0f<\/div>\n<div class=\"kg-callout-text\"><b><strong style=\"white-space: pre-wrap;\">Design Practice:<\/strong><\/b>&nbsp;It is a good practice to allocate swap on a&nbsp;separate, fast disk&nbsp;(SSD preferred) instead of sharing the root or data disk.<\/p>\n<p>This way, swap activity doesn&#8217;t compete with system or application I\/O.<\/p>\n<p>Also, since swap can hold plain data pages, it is advisable to encrypt swap to reduce security risks.<\/p><\/div>\n<\/div>\n<p>Another key thing to note is that the Kubernetes&nbsp;<strong>scheduler ignores swap<\/strong>&nbsp;when deploying workloads. This means the scheduler only deploys pods based on requests\/limits, not swap.<\/p>\n<h2 id=\"pod-qos-classes-swap-eligibility\">Pod QoS Classes &amp; Swap Eligibility<\/h2>\n<p>When swap is enabled in Kubernetes, whether a pod can use swap depends on its&nbsp;<a href=\"https:\/\/newsletter.devopscube.com\/p\/pod-qos?ref=devopscube.com\" rel=\"noopener noreferrer nofollow\">QoS class.<\/a><\/p>\n<p>Guaranteed pods and BestEffort pods&nbsp;<strong>cannot use swap<\/strong>&nbsp;(they are prohibited).<\/p>\n<p><strong>Burstable pods<\/strong>&nbsp;are the only ones allowed swap using the calculation given below.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/10\/image-115.png\" class=\"kg-image\" alt=\"pods that are eligible to use swap\" loading=\"lazy\" width=\"1632\" height=\"762\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/10\/image-115.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/10\/image-115.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/10\/image-115.png 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/10\/image-115.png 1632w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<h2 id=\"how-is-swap-memory-allocated-for-pods\">How is Swap Memory Allocated for Pods?<\/h2>\n<p>A pod cannot use all swap memory because there is a swap limit on the <a href=\"https:\/\/devopscube.com\/troubleshoot-kubernetes-pods\/\" rel=\"noreferrer\">pods<\/a>.<\/p>\n<p>Swap memory for each pod is allocated using the formula below.<\/p>\n<pre><code class=\"language-bash\">containerSwapLimit = (containerMemoryRequest \/ nodeTotalMemory) \u00d7 totalPodsSwapAvailable\n<\/code><\/pre>\n<p>For example, lets say your node has 2GB RAM, 2GB swap memory, and the pod request is 512MiB, then the total swap memory the pod can use is ~512MiB.<\/p>\n<p>Lets look at another example involving two&nbsp;Burstable&nbsp;pods.<\/p>\n<p>Let\u2019s say a a node has&nbsp;<strong>4 GB of RAM<\/strong>&nbsp;and&nbsp;<strong>2 GB of swap space<\/strong>.<\/p>\n<p>Now there are two Burstable pods. Pod A requests 1 GB and Pod B requests 2 GB.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-blue\">\n<div class=\"kg-callout-emoji\">\ud83d\udca1<\/div>\n<div class=\"kg-callout-text\">Total memory requests = 3 GB<\/p>\n<p>Pod A swap = (1 GB \/ 4 GB) \u00d7 2 GB = 0.5 GB<\/p>\n<p>Pod B swap = (2 GB \/ 4 GB) \u00d7 2 GB = 1 GB<\/p><\/div>\n<\/div>\n<p>Together they&nbsp;<strong>use 1.5 GB of swap<\/strong>, leaving 0.5 GB of swap unused.<\/p>\n<h2 id=\"swap-memory-limit\">Swap &amp; Memory Limit<\/h2>\n<p>Even when swap is enabled on a node, a pod can never use more memory than its defined&nbsp;<code>memory.limit<\/code>&nbsp;specified in resource spec.<\/p>\n<p>Here is what happens.<\/p>\n<p>The&nbsp;<strong>memory limit<\/strong>&nbsp;in the pod spec defines the&nbsp;<strong>total memory<\/strong>&nbsp;(RAM + swap) the container can use.<\/p>\n<p>Once a container crosses that limit, the&nbsp;<strong>kubelet will OOMKill<\/strong>&nbsp;(Out-Of-Memory kill) the container even if there is unused swap space.<\/p>\n<p>Swap&nbsp;<strong>does not extend or bypass<\/strong>&nbsp;the limit.<\/p>\n<h2 id=\"how-to-enable-swap-in-kubernetes\">How to Enable Swap in Kubernetes?<\/h2>\n<p>There is no built-in way to enable swap in Kubernetes. You must manually enable swap on each&nbsp;<strong>worker node<\/strong>&nbsp;where you want to use it.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-blue\">\n<div class=\"kg-callout-emoji\">\ud83d\udca1<\/div>\n<div class=\"kg-callout-text\">In enterprise setups, these configs would be part of the VM image used by the cluster.<\/div>\n<\/div>\n<p>Now, lets look at how to enable it.<\/p>\n<p>I am using a two node cluster, and I am going to enable swap on node01.<\/p>\n<pre><code class=\"language-bash\">$ kubectl get no\n\nNAME           STATUS   ROLES    AGE   VERSION\ncontrolplane   Ready    &lt;none&gt;   45m   v1.33.2\nnode01         Ready    &lt;none&gt;   45m   v1.33.2<\/code><\/pre>\n<p>First, ssh into node01.<\/p>\n<pre><code class=\"language-bash\">ssh node01<\/code><\/pre>\n<p>To enable it, the nodes should be Linux-based, and the cgroup should be version 2.<\/p>\n<p>To check the cgroup version, run the following command.<\/p>\n<pre><code class=\"language-bash\">stat -fc %T \/sys\/fs\/cgroup\n<\/code><\/pre>\n<p>If the output is cgroup2fs as shown below, then it&#8217;s version 2.<\/p>\n<pre><code class=\"language-bash\">$ stat -fc %T \/sys\/fs\/cgroup\n\ncgroup2fs<\/code><\/pre>\n<p>Then run the following commands to create a swap file and enable it.<\/p>\n<pre><code class=\"language-bash\">sudo fallocate -l 2G \/swapfile\nsudo chmod 600 \/swapfile\nsudo mkswap \/swapfile\nsudo swapon \/swapfile\nfree -h\n<\/code><\/pre>\n<p>You will get the following output as below a 2GB swap memory is created.<\/p>\n<pre><code class=\"language-bash\">$ free -h\n\n       total        used        free      shared  buff\/cache   available\nMem:   3.7Gi       576Mi       1.2Gi       2.0Mi       2.0Gi       3.0Gi\nSwap:  2.0Gi          0B       2.0Gi<\/code><\/pre>\n<p>Then open the kubelet <a href=\"https:\/\/devopscube.com\/kubernetes-kubeconfig-file\/\" rel=\"noreferrer\">config file<\/a>.<\/p>\n<pre><code class=\"language-bash\">sudo vi \/var\/lib\/kubelet\/config.yaml<\/code><\/pre>\n<div class=\"kg-card kg-callout-card kg-callout-card-blue\">\n<div class=\"kg-callout-emoji\">\ud83d\udca1<\/div>\n<div class=\"kg-callout-text\">In managed Kubernetes services like AWS EKS and Digital Ocean Kubernetes Clusters, the kubelet config file will be inside <code spellcheck=\"false\" style=\"white-space: pre-wrap;\">\/etc\/kubernetes<\/code>.<\/div>\n<\/div>\n<p>And, add the following line to it.<\/p>\n<pre><code class=\"language-bash\">failSwapOn: false\nmemorySwap:\n  swapBehavior: LimitedSwap\n<\/code><\/pre>\n<div class=\"kg-card kg-callout-card kg-callout-card-blue\">\n<div class=\"kg-callout-emoji\">\ud83d\udca1<\/div>\n<div class=\"kg-callout-text\"><b><strong style=\"white-space: pre-wrap;\">Note:<\/strong><\/b>&nbsp;If you use NoSWap instead of LimitedSwap, workloads do not use swap (but system may)<\/div>\n<\/div>\n<p>Save and close the config file and restart kubelet.<\/p>\n<pre><code class=\"language-bash\">sudo systemctl daemon-reload\n\nsudo systemctl restart kubelet<\/code><\/pre>\n<p>Now, come out of the node and run the following command to check if swap is enabled.<\/p>\n<pre><code class=\"language-bash\">kubectl get nodes -o go-template='{{range .items}}{{.metadata.name}}: {{if .status.nodeInfo.swap.capacity}}{{.status.nodeInfo.swap.capacity}}{{else}}&lt;unknown&gt;{{end}}{{\"\\n\"}}{{end}}'<\/code><\/pre>\n<p>If it is enabled for node01, you will get the following output.<\/p>\n<pre><code class=\"language-bash\">controlplane: &lt;unknown&gt;\nnode01: 2147479552<\/code><\/pre>\n<p>You also use the following top command to check the swap memory usage.<\/p>\n<pre><code class=\"language-bash\">kubectl top nodes --show-swap<\/code><\/pre>\n<div class=\"kg-card kg-callout-card kg-callout-card-blue\">\n<div class=\"kg-callout-emoji\">\ud83d\udca1<\/div>\n<div class=\"kg-callout-text\">This command only works if you have <code spellcheck=\"false\" style=\"white-space: pre-wrap;\">Kubectl version 1.34<\/code> or above<\/div>\n<\/div>\n<p>You will get the output as shown below.<\/p>\n<pre><code class=\"language-bash\">NAME          CPU(cores)  CPU(%)  MEMORY(bytes)  MEMORY(%) SWAP(bytes)   SWAP(%)     \n\ncontrolplane  70m         3%      762Mi        64%         &lt;unknown&gt;     &lt;unknown&gt;\nnode01        77m         4%      940Mi           52%         0Mi           0%  <\/code><\/pre>\n<h2 id=\"hands-on-example\">Hands-On Example<\/h2>\n<p>Let\u2019s create a memory stress pod to see what happens when the nodes memory reaches the limit.<\/p>\n<p>I am testing this on a node with 2GB RAM.<\/p>\n<p>Given below are the current usage and available memory of the node.<\/p>\n<pre><code class=\"language-bash\">$ free -h\n\n        total        used        free      shared  buff\/cache   available\n            \nMem:    1.9Gi       917Mi       128Mi       3.3Mi       1.1Gi       1.0Gi\nSwap:   2.0Gi        12Mi       2.0Gi<\/code><\/pre>\n<p>You can see it has it has 1Gi memory left, so i am going to create a stress pod which can create stress upto 1Gi to check memory swaping.<\/p>\n<pre><code class=\"language-yaml\">apiVersion: v1\nkind: Pod\nmetadata:\n  name: swap-demo\nspec:\n  restartPolicy: Never\n  nodeSelector:\n    kubernetes.io\/hostname: swap-test-7vutqmvu9-pokx3\n  containers:\n  - name: stress\n    image: alpine:3.20\n    command: [\"sh\",\"-c\"]\n    args:\n      - |\n        set -e\n        apk add --no-cache stress-ng &gt;\/dev\/null\n        echo \"Before:\"; free -h\n        stress-ng --vm 1 --vm-bytes 1000M --vm-keep --timeout 90s --metrics-brief\n        echo \"After:\"; free -h; sleep 20\n    resources:\n      requests:\n        memory: \"512Mi\"\n      limits:\n        memory: \"1000Mi\"<\/code><\/pre>\n<p>Change the <code>nodeSelector<\/code>, if your nodes name is different.<\/p>\n<p>Apply the above manifest and wait until it starts running.<\/p>\n<p>Once it starts running, <a href=\"https:\/\/devopscube.com\/generate-ssh-key-pair\/\" rel=\"noreferrer\">SSH<\/a> into node01 and run the following command to check the memory usage.<\/p>\n<pre><code class=\"language-bash\">free -h<\/code><\/pre>\n<p>You will get the following output.<\/p>\n<pre><code class=\"language-bash\">$ free -h\n\n        total        used        free      shared  buff\/cache   available\nMem:    1.9Gi       1.7Gi        73Mi       6.7Mi       266Mi       184Mi\nSwap:   2.0Gi       343Mi       1.7Gi<\/code><\/pre>\n<p>As you can see,&nbsp;some data from RAM has been moved to swap (inactive pages). Almost 343 MiB used.<\/p>\n<p>As the system was low on RAM, the kernel started using swap space to offload inactive memory pages.<\/p>\n<p>This prevents the pod from being OOMKilled because of insufficient memory.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-blue\">\n<div class=\"kg-callout-emoji\">\ud83d\udca1<\/div>\n<div class=\"kg-callout-text\">We have tried the same pod on a cluster without enabling swap with exact RAM, the pod got OOMKilled.<\/div>\n<\/div>\n<h2 id=\"identifying-nodes-with-swap\">Identifying Nodes With Swap<\/h2>\n<p>You might not need all the nodes to be swap enabled. So, how do we find nodes with swap?<\/p>\n<p>For this, Kubernetes provides a way to detect hardware features and system configuration using the <a href=\"https:\/\/devopscube.com\/node-feature-discovery\/\" rel=\"noreferrer\">node feature discovery (NFD)<\/a> addon.<\/p>\n<p>If you don&#8217;t have NFD installed, run the following command.<\/p>\n<pre><code class=\"language-bash\">helm install -n node-feature-discovery --create-namespace nfd oci:\/\/registry.k8s.io\/nfd\/charts\/node-feature-discovery --version 0.18.1<\/code><\/pre>\n<p>When you enable swap, kubernetes add <code>feature.node.kubernetes.io\/memory-swap=true<\/code> label to the nodes.<\/p>\n<p>Now, if you want to <strong>schedule pods only on swap-enabled nodes<\/strong>, you can use the nodeSelector feature with this label as shown below.<\/p>\n<pre><code class=\"language-yaml\">nodeSelector:\n  feature.node.kubernetes.io\/memory-swap: \"true\"\n<\/code><\/pre>\n<h2 id=\"monitoring-swap\">Monitoring swap<\/h2>\n<p>If you are enabling swap, you must monitor its usage. This way, you can perform tests to understand how it behaves under actual load.<\/p>\n<p>When you enable swap, Kubernetes provides metrics that you can monitor using tools like <a href=\"https:\/\/devopscube.com\/prometheus-architecture\/\" rel=\"noreferrer\">Prometheus<\/a>. Following are the key metrics that provide <a href=\"https:\/\/devopscube.com\/what-is-observability\/\" rel=\"noreferrer\">observability<\/a> for swap.<\/p>\n<ul>\n<li><code>node_memory_SwapCached_bytes<\/code><\/li>\n<li><code>node_memory_SwapTotal_bytes<\/code><\/li>\n<li><code>node_memory_SwapFree_bytes<\/code><\/li>\n<\/ul>\n<p>Also, <code>machine_swap_bytes<\/code> shows the swap capacity of the node.<\/p>\n<p>This way, cluster operators can see how much swap is being used. This observability helps in&nbsp;<strong>understanding performance impacts<\/strong>&nbsp;and making decisions.<\/p>\n<p>I have already deployed Prometheus on my cluster, and given below is an example of a <a href=\"https:\/\/devopscube.com\/setup-grafana-kubernetes\/\">Grafana<\/a> dashboard, showing how swap memory will be shown in it.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/10\/image-120.png\" class=\"kg-image\" alt=\"dashboard of swap enabled node\" loading=\"lazy\" width=\"1265\" height=\"642\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/10\/image-120.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/10\/image-120.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/10\/image-120.png 1265w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>And, if the node doesn&#8217;t have swap enabled, it will show as not applicable as shown below.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/10\/image-121.png\" class=\"kg-image\" alt=\"dashboard of swap not enabled node\" loading=\"lazy\" width=\"1263\" height=\"612\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/10\/image-121.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/10\/image-121.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/10\/image-121.png 1263w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>In this guide, you have learned about Kubernetes Swap, how it works, how to enable Kubernetes Swap in a <a href=\"https:\/\/devopscube.com\/production-ready-kubernetes-cluster\/\" rel=\"noreferrer\">Kubernetes cluster<\/a>, and tried it in a hands-on section.<\/p>\n<p>While this feature helps in a few use cases, you need to test it and configure it in a way that doesn&#8217;t affect your workloads in the cluster.<\/p>\n<p>Also, the following are the scenarios where you should not use swap for workloads.<\/p>\n<ol>\n<li>Do not use swap for apps that require predictable performance. For example, databases, real\u2010time APIs, microservices etc<\/li>\n<li>If the node storage is slow, do not enable swap. It can make things worse.<\/li>\n<\/ol>\n<p>Over to you.<\/p>\n<p>Give the swap feature and try and let us know if you face any issues.<\/p>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/kubernetes-swap\/\" target=\"_blank\" rel=\"noopener noreferrer\">Kubernetes Swap Explained With Practical Examples \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/kubernetes-swap\/<\/p>\n","protected":false},"author":1,"featured_media":449,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-448","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/448","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=448"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/448\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/media\/449"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=448"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=448"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=448"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}