Skip to content

Commit 0f32977

Browse files
authored
Merge pull request kubernetes#2794 from ehashman/swap-api-update
Update NoSwap SwapBehavior to LimitedSwap
2 parents 4c21926 + ed940a8 commit 0f32977

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

keps/sig-node/2400-node-swap/README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ type KubeletConfiguration struct {
343343

344344
type MemorySwapConfiguration struct {
345345
// Configure swap memory available to container workloads. May be one of
346-
// "", "NoSwap": workloads cannot use swap
346+
// "", "LimitedSwap": workload combined memory and swap usage cannot exceed pod memory limit
347347
// "UnlimitedSwap": workloads can use unlimited swap, up to the allocatable limit.
348348
SwapBehavior string
349349
}
@@ -353,13 +353,22 @@ We want to expose common swap configurations based on the [Docker] and open
353353
container specification for the `--memory-swap` flag. Thus, the
354354
`MemorySwapConfiguration.SwapBehavior` setting will have the following effects:
355355

356-
* If `SwapBehavior` is not set or set to `"NoSwap"`, containers do not have
357-
access to swap. This value effectively prevents a container from using swap,
358-
even if it is enabled on a system.
356+
* If `SwapBehavior` is not set or set to `"LimitedSwap"`, containers do not have
357+
access to swap beyond their memory limit. This value prevents a container
358+
from using swap in excess of their memory limit, even if it is enabled on a
359+
system.
360+
* With cgroups v1, it is possible for a container to use _some_ swap if its
361+
combined memory and swap usage do not exceed the
362+
[`memory.memsw.limit_in_bytes`] limit.
363+
* With cgroups v2, swap is configured independently from memory. Thus, the
364+
container runtimes can set [`memory.swap.max`] to 0 in this case, and _no_ swap
365+
usage will be permitted.
359366
* If `SwapBehavior` is set to `"UnlimitedSwap"`, the container is allowed to
360367
use unlimited swap, up to the maximum amount available on the host system.
361368

362369
[docker]: https://docs.docker.com/config/containers/resource_constraints/#--memory-swap-details
370+
[`memory.memsw.limit_in_bytes`]: https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v1/memory.html
371+
[`memory.swap.max`]: https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html#memory
363372

364373
#### CRI Changes
365374

@@ -400,7 +409,7 @@ phase of graduation.
400409
#### Alpha
401410

402411
- Kubelet can be started with swap enabled and will support two configurations
403-
for Kubernetes workloads: `NoSwap` and `UnlimitedSwap`.
412+
for Kubernetes workloads: `LimitedSwap` and `UnlimitedSwap`.
404413
- Kubelet can configure CRI to allocate swap to Kubernetes workloads. By
405414
default, workloads will not be allocated any swap.
406415
- e2e test jobs are configured for Linux systems with swap enabled.

0 commit comments

Comments
 (0)