1
1
---
2
- reviewers :
3
- - vishh
4
- - derekwaynecarr
5
- - dashpole
6
2
title : 为系统守护进程预留计算资源
7
3
content_type : task
8
4
min-kubernetes-server-version : 1.8
@@ -28,15 +24,15 @@ node.
28
24
29
25
The `kubelet` exposes a feature named 'Node Allocatable' that helps to reserve
30
26
compute resources for system daemons. Kubernetes recommends cluster
31
- administrators to configure ` Node Allocatable` based on their workload density
27
+ administrators to configure ' Node Allocatable' based on their workload density
32
28
on each node.
33
29
-->
34
30
Kubernetes 的节点可以按照 ` Capacity ` 调度。默认情况下 pod 能够使用节点全部可用容量。
35
31
这是个问题,因为节点自己通常运行了不少驱动 OS 和 Kubernetes 的系统守护进程。
36
32
除非为这些系统守护进程留出资源,否则它们将与 pod 争夺资源并导致节点资源短缺问题。
37
33
38
34
` kubelet ` 公开了一个名为 'Node Allocatable' 的特性,有助于为系统守护进程预留计算资源。
39
- Kubernetes 推荐集群管理员按照每个节点上的工作负载密度配置 ` Node Allocatable ` 。
35
+ Kubernetes 推荐集群管理员按照每个节点上的工作负载密度配置 “ Node Allocatable” 。
40
36
41
37
## {{% heading "prerequisites" %}}
42
38
@@ -72,7 +68,7 @@ Resources can be reserved for two categories of system daemons in the `kubelet`.
72
68
73
69
Kubernetes 节点上的 'Allocatable' 被定义为 pod 可用计算资源量。
74
70
调度器不会超额申请 'Allocatable'。
75
- 目前支持 'CPU', 'memory' 和 'ephemeral-storage' 这几个参数。
71
+ 目前支持 'CPU'、 'memory' 和 'ephemeral-storage' 这几个参数。
76
72
77
73
可分配的节点暴露为 API 中 ` v1.Node ` 对象的一部分,也是 CLI 中
78
74
` kubectl describe node ` 的一部分。
@@ -87,7 +83,7 @@ enable the new cgroup hierarchy via the `--cgroups-per-qos` flag. This flag is
87
83
enabled by default. When enabled, the `kubelet` will parent all end-user pods
88
84
under a cgroup hierarchy managed by the `kubelet`.
89
85
-->
90
- ### 启用 QoS 和 Pod 级别的 cgroups
86
+ ### 启用 QoS 和 Pod 级别的 cgroups {#enabling-qos-and-pod-level-cgroups}
91
87
92
88
为了恰当的在节点范围实施节点可分配约束,你必须通过 ` --cgroups-per-qos `
93
89
标志启用新的 cgroup 层次结构。这个标志是默认启用的。
@@ -110,10 +106,10 @@ transient slices for resources that are supported by that init system.
110
106
Depending on the configuration of the associated container runtime,
111
107
operators may have to choose a particular cgroup driver to ensure
112
108
proper system behavior. For example, if operators use the `systemd`
113
- cgroup driver provided by the `docker ` runtime, the `kubelet` must
109
+ cgroup driver provided by the `containerd ` runtime, the `kubelet` must
114
110
be configured to use the `systemd` cgroup driver.
115
111
-->
116
- ### 配置 cgroup 驱动
112
+ ### 配置 cgroup 驱动 {#configuring-a-cgroup-driver}
117
113
118
114
` kubelet ` 支持在主机上使用 cgroup 驱动操作 cgroup 层次结构。
119
115
驱动通过 ` --cgroup-driver ` 标志配置。
@@ -127,7 +123,7 @@ be configured to use the `systemd` cgroup driver.
127
123
128
124
取决于相关容器运行时的配置,操作员可能需要选择一个特定的 cgroup 驱动
129
125
来保证系统正常运行。
130
- 例如,如果操作员使用 ` docker ` 运行时提供的 ` systemd ` cgroup 驱动时,
126
+ 例如,如果操作员使用 ` containerd ` 运行时提供的 ` systemd ` cgroup 驱动时,
131
127
必须配置 ` kubelet ` 使用 ` systemd ` cgroup 驱动。
132
128
133
129
<!--
@@ -191,7 +187,6 @@ exist. Kubelet will fail if an invalid cgroup is specified.
191
187
- **Kubelet Flag**: `--system-reserved=[cpu=100m][,][memory=100Mi][,][ephemeral-storage=1Gi][,][pid=1000]`
192
188
- **Kubelet Flag**: `--system-reserved-cgroup=`
193
189
194
-
195
190
`system-reserved` is meant to capture resource reservation for OS system daemons
196
191
like `sshd`, `udev`, etc. `system-reserved` should reserve `memory` for the
197
192
`kernel` too since `kernel` memory is not accounted to pods in Kubernetes at this time.
@@ -237,14 +232,15 @@ exist. `kubelet` will fail if an invalid cgroup is specified.
237
232
238
233
<!--
239
234
### Explicitly Reserved CPU List
240
-
241
- -**Kubelet Flag**: `--reserved-cpus=0-3`
242
235
-->
243
236
### 显式保留的 CPU 列表 {#explicitly-reserved-cpu-list}
244
237
245
238
{{< feature-state for_k8s_version="v1.17" state="stable" >}}
246
239
247
- -** Kubelet 标志** : ` --reserved-cpus=0-3 `
240
+ <!--
241
+ **Kubelet Flag**: `--reserved-cpus=0-3`
242
+ -->
243
+ ** Kubelet 标志** :` --reserved-cpus=0-3 `
248
244
249
245
<!--
250
246
`reserved-cpus` is meant to define an explicit CPU set for OS system daemons and
@@ -283,7 +279,7 @@ cpuset 上,应使用 Kubernetes 之外的其他机制。
283
279
<!--
284
280
### Eviction Thresholds
285
281
286
- - **Kubelet Flag**: `--eviction-hard=[memory.available<500Mi]`
282
+ **Kubelet Flag**: `--eviction-hard=[memory.available<500Mi]`
287
283
288
284
Memory pressure at the node level leads to System OOMs which affects the entire
289
285
node and all pods running on it. Nodes can go offline temporarily until memory
@@ -299,7 +295,7 @@ available for pods.
299
295
-->
300
296
### 驱逐阈值 {#eviction-Thresholds}
301
297
302
- - ** Kubelet 标志** : ` --eviction-hard=[memory.available<500Mi] `
298
+ ** Kubelet 标志** : ` --eviction-hard=[memory.available<500Mi] `
303
299
304
300
节点级别的内存压力将导致系统内存不足,这将影响到整个节点及其上运行的所有 Pod。
305
301
节点可以暂时离线直到内存已经回收为止。
@@ -314,7 +310,7 @@ available for pods.
314
310
<!--
315
311
### Enforcing Node Allocatable
316
312
317
- - **Kubelet Flag**: `--enforce-node-allocatable=pods[,][system-reserved][,][kube-reserved]`
313
+ **Kubelet Flag**: `--enforce-node-allocatable=pods[,][system-reserved][,][kube-reserved]`
318
314
319
315
The scheduler treats 'Allocatable' as the available `capacity` for pods.
320
316
@@ -333,7 +329,7 @@ respectively.
333
329
-->
334
330
### 实施节点可分配约束 {#enforcing-node-allocatable}
335
331
336
- - ** Kubelet 标志** : ` --enforce-node-allocatable=pods[,][system-reserved][,][kube-reserved] `
332
+ ** Kubelet 标志** : ` --enforce-node-allocatable=pods[,][system-reserved][,][kube-reserved] `
337
333
338
334
调度器将 'Allocatable' 视为 Pod 可用的 ` capacity ` (资源容量)。
339
335
@@ -344,7 +340,7 @@ respectively.
344
340
可通过设置 kubelet ` --enforce-node-allocatable ` 标志值为 ` pods ` 控制这个措施。
345
341
346
342
可选地,通过在同一标志中同时指定 ` kube-reserved ` 和 ` system-reserved ` 值,
347
- 可以使 ` kubelet ` 强制实施 ` kube-reserved ` 和 ` system-reserved ` 约束。
343
+ 可以使 ` kubelet ` 强制实施 ` kube-reserved ` 和 ` system-reserved ` 约束。
348
344
请注意,要想执行 ` kube-reserved ` 或者 ` system-reserved ` 约束,
349
345
需要对应设置 ` --kube-reserved-cgroup ` 或者 ` --system-reserved-cgroup ` 。
350
346
@@ -355,7 +351,7 @@ System daemons are expected to be treated similar to
355
351
[Guaranteed pods](/docs/tasks/configure-pod-container/quality-service-pod/#create-a-pod-that-gets-assigned-a-qos-class-of-guaranteed).
356
352
System daemons can burst within their bounding control groups and this behavior needs
357
353
to be managed as part of kubernetes deployments. For example, `kubelet` should
358
- have its own control group and share `Kube -reserved` resources with the
354
+ have its own control group and share `kube -reserved` resources with the
359
355
container runtime. However, Kubelet cannot burst and use up all available Node
360
356
resources if `kube-reserved` is enforced.
361
357
-->
@@ -366,7 +362,7 @@ resources if `kube-reserved` is enforced.
366
362
一样对待。
367
363
系统守护进程可以在与其对应的控制组中出现突发资源用量,这一行为要作为
368
364
kubernetes 部署的一部分进行管理。
369
- 例如,` kubelet ` 应该有它自己的控制组并和容器运行时共享 ` Kube -reserved` 资源。
365
+ 例如,` kubelet ` 应该有它自己的控制组并和容器运行时共享 ` kube -reserved` 资源。
370
366
不过,如果执行了 ` kube-reserved ` 约束,则 kubelet 不可出现突发负载并用光
371
367
节点的所有可用资源。
372
368
@@ -391,7 +387,7 @@ ability to recover if any process in that group is oom-killed.
391
387
392
388
* 作为起步,可以先针对 ` pods ` 上执行 'Allocatable' 约束。
393
389
* 一旦用于追踪系统守护进程的监控和告警的机制到位,可尝试基于用量估计的
394
- 方式执行 ` kube-reserved ` 策略。
390
+ 方式执行 ` kube-reserved ` 策略。
395
391
* 随着时间推进,在绝对必要的时候可以执行 ` system-reserved ` 策略。
396
392
397
393
<!--
@@ -437,7 +433,7 @@ much CPU as they can, pods together cannot consume more than 14.5 CPUs.
437
433
438
434
If `kube-reserved` and/or `system-reserved` is not enforced and system daemons
439
435
exceed their reservation, `kubelet` evicts pods whenever the overall node memory
440
- usage is higher than 31.5Gi or `storage` is greater than 90Gi
436
+ usage is higher than 31.5Gi or `storage` is greater than 90Gi.
441
437
-->
442
438
在这个场景下,'Allocatable' 将会是 14.5 CPUs、28.5Gi 内存以及 ` 88Gi ` 本地存储。
443
439
调度器保证这个节点上的所有 Pod 的内存 ` requests ` 总量不超过 28.5Gi,
@@ -448,6 +444,6 @@ kubelet 将会驱逐它们。
448
444
14.5 CPUs 的资源。
449
445
450
446
当没有执行 ` kube-reserved ` 和/或 ` system-reserved ` 策略且系统守护进程
451
- 使用量超过其预留时,如果节点内存用量高于 31.5Gi 或` 存储 ` 大于 90Gi,
447
+ 使用量超过其预留时,如果节点内存用量高于 31.5Gi 或 ` storage ` 大于 90Gi,
452
448
kubelet 将会驱逐 Pod。
453
449
0 commit comments