1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/nodes-nodes-swap-memory.adoc

85 lines
3.2 KiB
Plaintext

// Module included in the following assemblies:
//
// * nodes/nodes/nodes-nodes-managing.adoc
:_mod-docs-content-type: PROCEDURE
[id="nodes-nodes-swap-memory_{context}"]
= Allowing swap memory use on nodes
[role="_abstract"]
You can allow workloads on the cluster nodes to use swap memory.
:FeatureName: Swap memory support on nodes
include::snippets/technology-preview.adoc[]
[NOTE]
====
Swap memory support is available only for container-native virtualization (CNV) users or use cases.
====
To allow swap memory usage on your nodes, create a `kubeletconfig` custom resource (CR) to set the `failSwapOn` parameter to `false`.
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:
* `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.
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 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_).
+
[NOTE]
====
Enabling the `TechPreviewNoUpgrade` feature set cannot be undone and prevents minor version updates. These feature sets are not recommended on production clusters.
====
.Procedure
. Apply a custom label to the machine config pool where you want to allow swap memory.
+
[source,terminal]
----
$ oc label machineconfigpool worker kubelet-swap=enabled
----
. Create a custom resource (CR) to enable and configure swap settings.
+
[source,yaml]
----
apiVersion: machineconfiguration.openshift.io/v1
kind: KubeletConfig
metadata:
name: swap-config
spec:
machineConfigPoolSelector:
matchLabels:
kubelet-swap: enabled
kubeletConfig:
failSwapOn: false
memorySwap:
swapBehavior: LimitedSwap
#...
----
+
where:
+
`failSwapOn`:: Set to `false` to enable swap memory use on the associated nodes. Set to `true` to disable swap memory use.
`swapBehavior`:: 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 nodes by setting the `swapaccount=1` kernel argument and configure swap memory as needed.