You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: keps/sig-node/2400-node-swap/README.md
+13-26
Original file line number
Diff line number
Diff line change
@@ -193,18 +193,12 @@ This is the total amount of swap available for all the Burstable QoS pods; let's
193
193
194
194
### Steps to Calculate Swap Limit
195
195
196
-
1.**Calculate the total memory requests of the pod:**
197
-
- Sum up the memory requests of all containers in the pod. Let's call this value `TotalMemory`.
196
+
1.**Calculate the container's memory proportionate to the node's memory:**
197
+
- Divide the container's memory request by the total node's physical memory. Let's call this value `ContainerMemoryProportion`.
198
+
- If a container is defined with memory requests == memory limits, its `ContainerMemoryProportion` is defined as 0. Therefore, as can be seen below, its overall swap limit is also 0.
198
199
199
-
2.**Determine the swap proportion for each container:**
200
-
- For each container, divide its memory request by the `TotalMemory`. The result will be the proportion of requested memory for that container within the pod. Let's call this value `RequestedMemoryProportion`.
201
-
- If a container is defined with memory requests == memory limits, its `RequestedMemoryProportion` is defined as 0.Therefore, as can be seen below, its overall swap limit is also 0.
202
-
203
-
3.**Calculate the total swap memory available:**
204
-
-`TotalPodsSwapAvailable` is the total amount of memory available for the pods. Divide the available swap memory by the total physical memory. Let's call this value `SwapMemoryProportion`.
205
-
206
-
4.**Calculate the swap limit for each container:**
207
-
- Multiply the `RequestedMemoryProportion` of a container by its memory request and then multiply the result by the `SwapMemoryProportion`. The result will be the adjusted swap limit for that specific container within the pod.
200
+
2.**Multiply the container memory proportion by the available swap memory for Pods:**
Suppose we have a Burstable QoS pod with two containers:
@@ -214,21 +208,15 @@ Suppose we have a Burstable QoS pod with two containers:
214
208
215
209
Let's assume the total physical memory is 40 GB and the total swap memory available is also 40 GB. Also assume that the system reserved memory is configured at 2GB,
216
210
217
-
Step 1: Calculate `TotalPodsSwapAvailable`, which denotes total available swap memory: 40 GB - 2 GB = 38 GB
218
-
219
-
Step 2: Calculate the total memory requests of the pod: 20 GB + 10 GB = 30 GB
220
-
221
-
Step 2: Determine the requested memory proportion for each container:
222
-
- Container A: (20 GB) / (30 GB) = 2/3
223
-
- Container B: (10 GB) / (30 GB) = 1/3
224
-
225
-
Step 3: Calculate the total swap memory available: Since the total swap memory (38 GB) and physical memory (40 GB), the `SwapMemoryProportion` will be 38 GB / 40 GB = 0.95
211
+
Step 1: Determine the containers memory proportion:
212
+
- Container A: `20G/40G` = `0.5`.
213
+
- Container B: `10G/40G` = `0.25`.
226
214
227
-
Step 4: Calculate the swap limit for each container:
228
-
- Container A: (2/3) * 20 GB * 0.95 ≈ 12.66 GB
229
-
- Container B: (1/3) * 10 GB * 0.95 ≈ 3.16 GB
215
+
Step 2: Determine swap limitation for the containers:
In this example, Container A would have a swap limit of 12.66 GB, and Container B would have a swap limit of 3.16 GB.
219
+
In this example, Container A would have a swap limit of 19 GB, and Container B would have a swap limit of 9.5 GB.
232
220
233
221
This approach allocates swap limits based on each container's memory request and adjusts the proportion based on the total swap memory available in the system. It ensures that each container gets a fair share of the swap space and helps maintain resource allocation efficiency.
234
222
@@ -619,8 +607,7 @@ Here are specific improvements to be made:
619
607
- Remove support for setting unlimited amount of swap (including [swapBehavior](https://kubernetes.io/docs/reference/config-api/kubelet-config.v1beta1/#kubelet-config-k8s-io-v1beta1-MemorySwapConfiguration) flag of the Kubelet) as any workload with aggressive memory allocation can bring down a node with having no limits on swap usage.
620
608
621
609
#### Beta 2
622
-
- Add support for controlling swap consumption at the container level [via cgroups] in Pod API in [container resources](https://github.com/kubernetes/kubernetes/blob/94a15929cf13354fdf3747cb266d511154f8c97b/staging/src/k8s.io/api/core/v1/types.go#L2443). More specifically add a new [ResourceName](https://github.com/kubernetes/kubernetes/blob/94a15929cf13354fdf3747cb266d511154f8c97b/staging/src/k8s.io/api/core/v1/types.go#L5522)`swap`. This will make sure we stay consistent with other resources like `cpu`, `memory` etc.
623
-
- Publish a Kubernetes doc page encouring user to use encrypted swap if they wish to enable this feature.
610
+
- Publish a Kubernetes doc page encoring user to use encrypted swap if they wish to enable this feature.
624
611
- Handle usage of swap during container restart boundaries for writes to tmpfs
625
612
(which may require pod cgroup change beyond what container runtime will do at
0 commit comments