Skip to content

Commit bc35539

Browse files
sathieutengqm
andauthored
Improve "Reserve Compute Resources for System Daemons" doc (#45771)
* Improve "Reserve Compute Resources for System Daemons" doc Remove deprecated CLI flags and replace by KubeletConfiguration settings * Apply suggestions from code review Co-authored-by: Qiming Teng <[email protected]> * keep the heading --------- Co-authored-by: Qiming Teng <[email protected]>
1 parent 26b1fc9 commit bc35539

File tree

1 file changed

+51
-54
lines changed

1 file changed

+51
-54
lines changed

content/en/docs/tasks/administer-cluster/reserve-compute-resources.md

Lines changed: 51 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ reviewers:
55
- dashpole
66
title: Reserve Compute Resources for System Daemons
77
content_type: task
8-
min-kubernetes-server-version: 1.8
98
weight: 290
109
---
1110

@@ -25,10 +24,10 @@ on each node.
2524

2625
## {{% heading "prerequisites" %}}
2726

28-
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
29-
Your Kubernetes server must be at or later than version 1.17 to use
30-
the kubelet command line option `--reserved-cpus` to set an
31-
[explicitly reserved CPU list](#explicitly-reserved-cpu-list).
27+
{{< include "task-tutorial-prereqs.md" >}}
28+
29+
You can configure below kubelet [configuration settings](/docs/reference/config-api/kubelet-config.v1beta1/)
30+
using the [kubelet configuration file](/docs/tasks/administer-cluster/kubelet-config-file/).
3231

3332
<!-- steps -->
3433

@@ -48,15 +47,14 @@ Resources can be reserved for two categories of system daemons in the `kubelet`.
4847
### Enabling QoS and Pod level cgroups
4948

5049
To properly enforce node allocatable constraints on the node, you must
51-
enable the new cgroup hierarchy via the `--cgroups-per-qos` flag. This flag is
50+
enable the new cgroup hierarchy via the `cgroupsPerQOS` setting. This setting is
5251
enabled by default. When enabled, the `kubelet` will parent all end-user pods
5352
under a cgroup hierarchy managed by the `kubelet`.
5453

5554
### Configuring a cgroup driver
5655

5756
The `kubelet` supports manipulation of the cgroup hierarchy on
58-
the host using a cgroup driver. The driver is configured via the
59-
`--cgroup-driver` flag.
57+
the host using a cgroup driver. The driver is configured via the `cgroupDriver` setting.
6058

6159
The supported values are the following:
6260

@@ -73,41 +71,41 @@ be configured to use the `systemd` cgroup driver.
7371

7472
### Kube Reserved
7573

76-
- **Kubelet Flag**: `--kube-reserved=[cpu=100m][,][memory=100Mi][,][ephemeral-storage=1Gi][,][pid=1000]`
77-
- **Kubelet Flag**: `--kube-reserved-cgroup=`
74+
- **KubeletConfiguration Setting**: `kubeReserved: {}`. Example value `{cpu: 100m, memory: 100Mi, ephemeral-storage: 1Gi, pid=1000}`
75+
- **KubeletConfiguration Setting**: `kubeReservedCgroup: ""`
7876

79-
`kube-reserved` is meant to capture resource reservation for kubernetes system
80-
daemons like the `kubelet`, `container runtime`, `node problem detector`, etc.
77+
`kubeReserved` is meant to capture resource reservation for kubernetes system
78+
daemons like the `kubelet`, `container runtime`, etc.
8179
It is not meant to reserve resources for system daemons that are run as pods.
82-
`kube-reserved` is typically a function of `pod density` on the nodes.
80+
`kubeReserved` is typically a function of `pod density` on the nodes.
8381

8482
In addition to `cpu`, `memory`, and `ephemeral-storage`, `pid` may be
8583
specified to reserve the specified number of process IDs for
8684
kubernetes system daemons.
8785

88-
To optionally enforce `kube-reserved` on kubernetes system daemons, specify the parent
89-
control group for kube daemons as the value for `--kube-reserved-cgroup` kubelet
90-
flag.
86+
To optionally enforce `kubeReserved` on kubernetes system daemons, specify the parent
87+
control group for kube daemons as the value for `kubeReservedCgroup` setting,
88+
and [add `kube-reserved` to `enforceNodeAllocatable`](#enforcing-node-allocatable).
9189

9290
It is recommended that the kubernetes system daemons are placed under a top
9391
level control group (`runtime.slice` on systemd machines for example). Each
9492
system daemon should ideally run within its own child control group. Refer to
9593
[the design proposal](https://git.k8s.io/design-proposals-archive/node/node-allocatable.md#recommended-cgroups-setup)
9694
for more details on recommended control group hierarchy.
9795

98-
Note that Kubelet **does not** create `--kube-reserved-cgroup` if it doesn't
96+
Note that Kubelet **does not** create `kubeReservedCgroup` if it doesn't
9997
exist. The kubelet will fail to start if an invalid cgroup is specified. With `systemd`
10098
cgroup driver, you should follow a specific pattern for the name of the cgroup you
101-
define: the name should be the value you set for `--kube-reserved-cgroup`,
99+
define: the name should be the value you set for `kubeReservedCgroup`,
102100
with `.slice` appended.
103101

104102
### System Reserved
105103

106-
- **Kubelet Flag**: `--system-reserved=[cpu=100m][,][memory=100Mi][,][ephemeral-storage=1Gi][,][pid=1000]`
107-
- **Kubelet Flag**: `--system-reserved-cgroup=`
104+
- **KubeletConfiguration Setting**: `systemReserved: {}`. Example value `{cpu: 100m, memory: 100Mi, ephemeral-storage: 1Gi, pid=1000}`
105+
- **KubeletConfiguration Setting**: `systemReservedCgroup: ""`
108106

109-
`system-reserved` is meant to capture resource reservation for OS system daemons
110-
like `sshd`, `udev`, etc. `system-reserved` should reserve `memory` for the
107+
`systemReserved` is meant to capture resource reservation for OS system daemons
108+
like `sshd`, `udev`, etc. `systemReserved` should reserve `memory` for the
111109
`kernel` too since `kernel` memory is not accounted to pods in Kubernetes at this time.
112110
Reserving resources for user login sessions is also recommended (`user.slice` in
113111
systemd world).
@@ -116,33 +114,32 @@ In addition to `cpu`, `memory`, and `ephemeral-storage`, `pid` may be
116114
specified to reserve the specified number of process IDs for OS system
117115
daemons.
118116

119-
To optionally enforce `system-reserved` on system daemons, specify the parent
120-
control group for OS system daemons as the value for `--system-reserved-cgroup`
121-
kubelet flag.
117+
To optionally enforce `systemReserved` on system daemons, specify the parent
118+
control group for OS system daemons as the value for `systemReservedCgroup` setting,
119+
and [add `system-reserved` to `enforceNodeAllocatable`](#enforcing-node-allocatable).
122120

123121
It is recommended that the OS system daemons are placed under a top level
124122
control group (`system.slice` on systemd machines for example).
125123

126-
Note that `kubelet` **does not** create `--system-reserved-cgroup` if it doesn't
124+
Note that `kubelet` **does not** create `systemReservedCgroup` if it doesn't
127125
exist. `kubelet` will fail if an invalid cgroup is specified. With `systemd`
128126
cgroup driver, you should follow a specific pattern for the name of the cgroup you
129-
define: the name should be the value you set for `--system-reserved-cgroup`,
127+
define: the name should be the value you set for `systemReservedCgroup`,
130128
with `.slice` appended.
131129

132130
### Explicitly Reserved CPU List
133131

134132
{{< feature-state for_k8s_version="v1.17" state="stable" >}}
135133

136-
**Kubelet Flag**: `--reserved-cpus=0-3`
137-
**KubeletConfiguration Flag**: `reservedSystemCPUs: 0-3`
134+
**KubeletConfiguration Setting**: `reservedSystemCPUs:`. Example value `0-3`
138135

139-
`reserved-cpus` is meant to define an explicit CPU set for OS system daemons and
140-
kubernetes system daemons. `reserved-cpus` is for systems that do not intend to
136+
`reservedSystemCPUs` is meant to define an explicit CPU set for OS system daemons and
137+
kubernetes system daemons. `reservedSystemCPUs` is for systems that do not intend to
141138
define separate top level cgroups for OS system daemons and kubernetes system daemons
142139
with regard to cpuset resource.
143-
If the Kubelet **does not** have `--system-reserved-cgroup` and `--kube-reserved-cgroup`,
144-
the explicit cpuset provided by `reserved-cpus` will take precedence over the CPUs
145-
defined by `--kube-reserved` and `--system-reserved` options.
140+
If the Kubelet **does not** have `kubeReservedCgroup` and `systemReservedCgroup`,
141+
the explicit cpuset provided by `reservedSystemCPUs` will take precedence over the CPUs
142+
defined by `kubeReservedCgroup` and `systemReservedCgroup` options.
146143

147144
This option is specifically designed for Telco/NFV use cases where uncontrolled
148145
interrupts/timers may impact the workload performance. you can use this option
@@ -155,23 +152,23 @@ For example: in Centos, you can do this using the tuned toolset.
155152

156153
### Eviction Thresholds
157154

158-
**Kubelet Flag**: `--eviction-hard=[memory.available<500Mi]`
155+
**KubeletConfiguration Setting**: `evictionHard: {memory.available: "100Mi", nodefs.available: "10%", nodefs.inodesFree: "5%", imagefs.available: "15%"}`. Example value: `{memory.available: "<500Mi"}`
159156

160157
Memory pressure at the node level leads to System OOMs which affects the entire
161158
node and all pods running on it. Nodes can go offline temporarily until memory
162159
has been reclaimed. To avoid (or reduce the probability of) system OOMs kubelet
163160
provides [out of resource](/docs/concepts/scheduling-eviction/node-pressure-eviction/)
164161
management. Evictions are
165162
supported for `memory` and `ephemeral-storage` only. By reserving some memory via
166-
`--eviction-hard` flag, the `kubelet` attempts to evict pods whenever memory
163+
`evictionHard` setting, the `kubelet` attempts to evict pods whenever memory
167164
availability on the node drops below the reserved value. Hypothetically, if
168165
system daemons did not exist on a node, pods cannot use more than `capacity -
169166
eviction-hard`. For this reason, resources reserved for evictions are not
170167
available for pods.
171168

172169
### Enforcing Node Allocatable
173170

174-
**Kubelet Flag**: `--enforce-node-allocatable=pods[,][system-reserved][,][kube-reserved]`
171+
**KubeletConfiguration setting**: `enforceNodeAllocatable: [pods]`. Example value: `[pods,system-reserved,kube-reserved]`
175172

176173
The scheduler treats 'Allocatable' as the available `capacity` for pods.
177174

@@ -180,35 +177,35 @@ by evicting pods whenever the overall usage across all pods exceeds
180177
'Allocatable'. More details on eviction policy can be found
181178
on the [node pressure eviction](/docs/concepts/scheduling-eviction/node-pressure-eviction/)
182179
page. This enforcement is controlled by
183-
specifying `pods` value to the kubelet flag `--enforce-node-allocatable`.
180+
specifying `pods` value to the KubeletConfiguration setting `enforceNodeAllocatable`.
184181

185-
Optionally, `kubelet` can be made to enforce `kube-reserved` and
186-
`system-reserved` by specifying `kube-reserved` & `system-reserved` values in
187-
the same flag. Note that to enforce `kube-reserved` or `system-reserved`,
188-
`--kube-reserved-cgroup` or `--system-reserved-cgroup` needs to be specified
182+
Optionally, `kubelet` can be made to enforce `kubeReserved` and
183+
`systemReserved` by specifying `kube-reserved` & `system-reserved` values in
184+
the same setting. Note that to enforce `kubeReserved` or `systemReserved`,
185+
`kubeReservedCgroup` or `systemReservedCgroup` needs to be specified
189186
respectively.
190187

191188
## General Guidelines
192189

193-
System daemons are expected to be treated similar to
194-
[Guaranteed pods](/docs/tasks/configure-pod-container/quality-service-pod/#create-a-pod-that-gets-assigned-a-qos-class-of-guaranteed).
190+
System daemons are expected to be treated similar to
191+
[Guaranteed pods](/docs/tasks/configure-pod-container/quality-service-pod/#create-a-pod-that-gets-assigned-a-qos-class-of-guaranteed).
195192
System daemons can burst within their bounding control groups and this behavior needs
196193
to be managed as part of kubernetes deployments. For example, `kubelet` should
197-
have its own control group and share `kube-reserved` resources with the
194+
have its own control group and share `kubeReserved` resources with the
198195
container runtime. However, Kubelet cannot burst and use up all available Node
199-
resources if `kube-reserved` is enforced.
196+
resources if `kubeReserved` is enforced.
200197

201-
Be extra careful while enforcing `system-reserved` reservation since it can lead
198+
Be extra careful while enforcing `systemReserved` reservation since it can lead
202199
to critical system services being CPU starved, OOM killed, or unable
203200
to fork on the node. The
204-
recommendation is to enforce `system-reserved` only if a user has profiled their
201+
recommendation is to enforce `systemReserved` only if a user has profiled their
205202
nodes exhaustively to come up with precise estimates and is confident in their
206203
ability to recover if any process in that group is oom-killed.
207204

208205
* To begin with enforce 'Allocatable' on `pods`.
209206
* Once adequate monitoring and alerting is in place to track kube system
210-
daemons, attempt to enforce `kube-reserved` based on usage heuristics.
211-
* If absolutely necessary, enforce `system-reserved` over time.
207+
daemons, attempt to enforce `kubeReserved` based on usage heuristics.
208+
* If absolutely necessary, enforce `systemReserved` over time.
212209

213210
The resource requirements of kube system daemons may grow over time as more and
214211
more features are added. Over time, kubernetes project will attempt to bring
@@ -222,9 +219,9 @@ So expect a drop in `Allocatable` capacity in future releases.
222219
Here is an example to illustrate Node Allocatable computation:
223220

224221
* Node has `32Gi` of `memory`, `16 CPUs` and `100Gi` of `Storage`
225-
* `--kube-reserved` is set to `cpu=1,memory=2Gi,ephemeral-storage=1Gi`
226-
* `--system-reserved` is set to `cpu=500m,memory=1Gi,ephemeral-storage=1Gi`
227-
* `--eviction-hard` is set to `memory.available<500Mi,nodefs.available<10%`
222+
* `kubeReserved` is set to `{cpu: 1000m, memory: 2Gi, ephemeral-storage: 1Gi}`
223+
* `systemReserved` is set to `{cpu: 500m, memory: 1Gi, ephemeral-storage: 1Gi}`
224+
* `evictionHard` is set to `{memory.available: "<500Mi", nodefs.available: "<10%"}`
228225

229226
Under this scenario, 'Allocatable' will be 14.5 CPUs, 28.5Gi of memory and
230227
`88Gi` of local storage.
@@ -234,7 +231,7 @@ Kubelet evicts pods whenever the overall memory usage across pods exceeds 28.5Gi
234231
or if overall disk usage exceeds 88Gi. If all processes on the node consume as
235232
much CPU as they can, pods together cannot consume more than 14.5 CPUs.
236233

237-
If `kube-reserved` and/or `system-reserved` is not enforced and system daemons
234+
If `kubeReserved` and/or `systemReserved` is not enforced and system daemons
238235
exceed their reservation, `kubelet` evicts pods whenever the overall node memory
239236
usage is higher than 31.5Gi or `storage` is greater than 90Gi.
240237

0 commit comments

Comments
 (0)