From b5fc3c972e319379ad4d69145a5ffd4facbf2431 Mon Sep 17 00:00:00 2001 From: Michael Burke Date: Mon, 21 Apr 2025 16:19:24 -0400 Subject: [PATCH] Nodes fix swap memory part 2 --- modules/nodes-nodes-swap-memory.adoc | 42 ++++++++++++++++------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/modules/nodes-nodes-swap-memory.adoc b/modules/nodes-nodes-swap-memory.adoc index 021800962265..3e99dc14891f 100644 --- a/modules/nodes-nodes-swap-memory.adoc +++ b/modules/nodes-nodes-swap-memory.adoc @@ -1,39 +1,44 @@ // Module included in the following assemblies: // -// * nodes/nodes/nodes-nodes-managing.:_mod-docs-content-type: PROCEDURE +// * nodes/nodes/nodes-nodes-managing.adoc :_mod-docs-content-type: PROCEDURE [id="nodes-nodes-swap-memory_{context}"] -= Enabling swap memory use on nodes += Allowing swap memory use on nodes -:FeatureName: Enabling swap memory use on nodes +You can allow workloads on the cluster nodes to use swap memory. + +:FeatureName: Swap memory support on nodes include::snippets/technology-preview.adoc[] [NOTE] ==== -Enabling swap memory is only available for container-native virtualization (CNV) users or use cases. +Swap memory support is available only for container-native virtualization (CNV) users or use cases. ==== -[WARNING] -==== -Enabling swap memory can negatively impact workload performance and out-of-resource handling. Do not enable swap memory on control plane nodes. -==== +To allow swap memory usage on your nodes, create a `kubeletconfig` custom resource (CR) to set the `failSwapOn` parameter to `false`. -To enable swap memory, create a `kubeletconfig` custom resource (CR) to set the `swapbehavior` parameter. You can set limited or unlimited swap memory: +Optionally, you can control swap memory usage by {product-title} workloads on those nodes by setting the `swapBehavior` parameter to one of the following values: -* Limited: Use the `LimitedSwap` value to limit how much swap memory workloads can use. Any workloads on the node that are not managed by {product-title} can still use swap memory. The `LimitedSwap` behavior depends on whether the node is running with Linux control groups link:https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v1/index.html[version 1 (cgroups v1)] or link:https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html[version 2 (cgroup v2)]: -** cgroup v1: {product-title} workloads can use any combination of memory and swap, up to the pod's memory limit, if set. -** cgroup v2: {product-title} workloads cannot use swap memory. +* `NoSwap` prevents {product-title} worloads from using swap memory. +* `LimitedSwap` allows {product-title} workloads that fall under the Burstable QoS class to use swap memory. -* Unlimited: Use the `UnlimitedSwap` value to allow workloads to use as much swap memory as they request, up to the system limit. +Regardless of the `swapBehavior` setting, any workloads that are not managed by {product-title} on that node can still use swap memory if the `failSwapOn` parameter is `false`. -Because the kubelet will not start in the presence of swap memory without this configuration, you must enable swap memory in {product-title} before enabling swap memory on the nodes. If there is no swap memory present on a node, enabling swap memory in {product-title} has no effect. +Because the kubelet will not start in the presence of swap memory without this configuration, you must allow swap memory in {product-title} before enabling swap memory on the nodes. If there is no swap memory present on a node, enabling swap memory in {product-title} has no effect. + +[WARNING] +==== +Using swap memory can negatively impact workload performance and out-of-resource handling. Do not enable swap memory on control plane nodes. +==== .Prerequisites * You have a running {product-title} cluster that uses version 4.10 or later. +* Your cluster is configured to use cgroup v2. Swap memory is not supported on nodes in clusters that use cgroup v1. + * You are logged in to the cluster as a user with administrative privileges. * You have enabled the `TechPreviewNoUpgrade` feature set on the cluster (see _Nodes -> Working with clusters -> Enabling features using feature gates_). @@ -43,8 +48,6 @@ Because the kubelet will not start in the presence of swap memory without this c Enabling the `TechPreviewNoUpgrade` feature set cannot be undone and prevents minor version updates. These feature sets are not recommended on production clusters. ==== -* If cgroup v2 is enabled on a node, you must enable swap accounting on the node, by setting the `swapaccount=1` kernel argument. - .Procedure . Apply a custom label to the machine config pool where you want to allow swap memory. @@ -73,6 +76,9 @@ spec: #... ---- <1> Set to `false` to enable swap memory use on the associated nodes. Set to `true` to disable swap memory use. -<2> Specify the swap memory behavior. If unspecified, the default is `LimitedSwap`. +<2> Optional: Specify the swap memory behavior for {product-title} pods. ++ +* `NoSwap`: {product-title} pods cannot use swap. This is the default. +* `LimitedSwap`: {product-title} pods of Burstable QoS class only are permitted to employ swap. -. Enable swap memory on the machines. +. Enable swap memory on the nodes by setting the `swapaccount=1` kernel argument and configure swap memory as needed.