Skip to content

Nodes swap memory fix 2 #92421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions modules/nodes-nodes-swap-memory.adoc
Original file line number Diff line number Diff line change
@@ -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`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I'm not entirely sure what this means.

It wouldn't be possible to boot openshift if failSwapOn is true.

Any thing on the node could use swap but kubelet would not start if swap is enabled on the node.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kannon92 What I was getting at is that when you set failSwapOn: false, whether you set swapBehavior: NoSwap or swapBehavior: LimitedSwap, and non-OCP workloads can use swap.
That was how I read the Kubernetes docs you suggested. (They have a nice example in system daemons, that perhaps I could add.)


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_).
Expand All @@ -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.
Expand Down Expand Up @@ -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.