Skip to content

Commit a02bed0

Browse files
authored
Merge pull request #41755 from ehashman/swap-docs
Add documentation for NodeSwap tech preview feature
2 parents ad47755 + ad527ec commit a02bed0

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

modules/nodes-nodes-swap-memory.adoc

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
:_content-type: PROCEDURE
2+
[id="nodes-nodes-swap-memory_{context}"]
3+
4+
= Managing swap memory on nodes
5+
6+
:FeatureName: Configuring swap memory usage on nodes
7+
include::snippets/technology-preview.adoc[]
8+
9+
In {product-title}, you can configure nodes to use swap memory. By default, the Kubelet will not start in the presence of swap memory without further configuration.
10+
11+
[WARNING]
12+
====
13+
Enabling swap memory can negatively impact workload performance and out-of-resource handling. Do not enable swap memory on master nodes.
14+
====
15+
16+
.Prerequisites
17+
* You have a running {product-title} cluster that uses version 4.10 or later.
18+
* You are logged in to the cluster as a user with administrative privileges.
19+
* Tech Preview features are enabled on the cluster.
20+
* On cgroups v2, nodes must have swap accounting enabled (kernel argument `swapaccount=1`).
21+
22+
.Procedure
23+
24+
. Apply a custom kubelet label to the machine config pool where swap is enabled.
25+
+
26+
[source,terminal]
27+
----
28+
$ oc label machineconfigpool worker kubelet-swap=enabled
29+
----
30+
31+
. Create a custom KubeletConfig to enable swap settings.
32+
+
33+
[source,yaml]
34+
----
35+
apiVersion: machineconfiguration.openshift.io/v1
36+
kind: KubeletConfig
37+
metadata:
38+
name: swap-config
39+
spec:
40+
machineConfigPoolSelector:
41+
matchLabels:
42+
kubelet-swap: enabled
43+
kubeletConfig:
44+
failSwapOn: false <1>
45+
memorySwap:
46+
swapBehavior: LimitedSwap <2>
47+
----
48+
<1> Ensures Kubelet will start in the presence of swap on a system.
49+
<2> Specifies swap behavior for the kubelet. If unspecified, defaults to `LimitedSwap`.
50+
+
51+
The available configuration options for `swapBehavior` are:
52+
+
53+
* `LimitedSwap`: Kubernetes workloads are limited in how much swap they can
54+
use. Workloads on the node not managed by Kubernetes can still swap.
55+
The behaviour of the `LimitedSwap` setting depends if the node is running
56+
with v1 or v2 of control groups (also known as "cgroups"):
57+
** **cgroups v1:** Kubernetes workloads can use any combination of memory and
58+
swap, up to the pod's memory limit, if set.
59+
** **cgroups v2:** Kubernetes workloads cannot use swap memory.
60+
* `UnlimitedSwap`: Kubernetes workloads can use as much swap memory as they
61+
request, up to the system limit.
62+
63+
. Enable swap memory on the machines. Kubelets will not start in the presence of swap memory without the above configuration, so if swap memory is enabled on an already running cluster, the custom Kubelet configurations must be provided first. If there is no swap memory present on a system, this configuration will not change any default behaviours.

nodes/nodes/nodes-nodes-working.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ ifdef::openshift-webscale[]
3939
include::modules/nodes-nodes-rtkernel-arguments.adoc[leveloffset=+1]
4040
endif::openshift-webscale[]
4141
include::modules/nodes-nodes-cgroups-2.adoc[leveloffset=+1]
42+
include::modules/nodes-nodes-swap-memory.adoc[leveloffset=+1]

0 commit comments

Comments
 (0)