|
1 | 1 | :_content-type: PROCEDURE
|
2 | 2 | [id="nodes-nodes-swap-memory_{context}"]
|
3 | 3 |
|
4 |
| -= Managing swap memory on nodes |
| 4 | += Enabling swap memory use on nodes |
5 | 5 |
|
6 |
| -:FeatureName: Configuring swap memory usage on nodes |
| 6 | +:FeatureName: Enabling swap memory use on nodes |
7 | 7 | include::snippets/technology-preview.adoc[]
|
8 | 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. |
| 9 | +You can enable swap memory use for {product-title} workloads on a per-node basis. |
10 | 10 |
|
11 | 11 | [WARNING]
|
12 | 12 | ====
|
13 | 13 | Enabling swap memory can negatively impact workload performance and out-of-resource handling. Do not enable swap memory on master nodes.
|
14 | 14 | ====
|
15 | 15 |
|
| 16 | +To enable swap memory, create a `kubeletconfig` custom resource (CR) to set the `swapbehavior` parameter. You can set limited or unlimited swap memory: |
| 17 | + |
| 18 | +* 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 (cgroups v2)]: |
| 19 | +** cgroups v1: {product-title} workloads can use any combination of memory and swap, up to the pod's memory limit, if set. |
| 20 | +** cgroups v2: {product-title} workloads cannot use swap memory. |
| 21 | + |
| 22 | +* Unlimited: Use the `UnlimitedSwap` value to allow workloads to use as much swap memory as they request, up to the system limit. |
| 23 | + |
| 24 | +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. |
| 25 | + |
16 | 26 | .Prerequisites
|
| 27 | + |
17 | 28 | * You have a running {product-title} cluster that uses version 4.10 or later.
|
| 29 | + |
18 | 30 | * 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`). |
| 31 | + |
| 32 | +* You have enabled the `TechPreviewNoUpgrade` feature set on the cluster (see _Nodes -> Enabling features using feature gates_). |
| 33 | ++ |
| 34 | +[NOTE] |
| 35 | +==== |
| 36 | +Enabling the `TechPreviewNoUpgrade` feature set cannot be undone and prevents upgrades. These feature sets are not recommended on production clusters. |
| 37 | +==== |
| 38 | + |
| 39 | +* If cgroups v2 is enabled on a node, you must enable swap accounting on the node, by setting the `swapaccount=1` kernel argument. |
21 | 40 |
|
22 | 41 | .Procedure
|
23 | 42 |
|
24 |
| -. Apply a custom kubelet label to the machine config pool where swap is enabled. |
| 43 | +. Apply a custom label to the machine config pool where you want to allow swap memory. |
25 | 44 | +
|
26 | 45 | [source,terminal]
|
27 | 46 | ----
|
28 | 47 | $ oc label machineconfigpool worker kubelet-swap=enabled
|
29 | 48 | ----
|
30 | 49 |
|
31 |
| -. Create a custom KubeletConfig to enable swap settings. |
| 50 | +. Create a custom resource (CR) to enable and configure swap settings. |
32 | 51 | +
|
33 | 52 | [source,yaml]
|
34 | 53 | ----
|
|
45 | 64 | memorySwap:
|
46 | 65 | swapBehavior: LimitedSwap <2>
|
47 | 66 | ----
|
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. |
| 67 | +<1> Set to `false` to enable swap memory use on the associated nodes. Set to `true` to disable swap memory use. |
| 68 | +<2> Specify the swap memory behavior. If unspecified, the default is `LimitedSwap`. |
| 69 | + |
| 70 | +. Enable swap memory on the machines. |
| 71 | + |
0 commit comments