Skip to content

Commit 678d84d

Browse files
authored
Merge pull request #22774 from jiaj12/patch-33
Update reserve-compute-resources.md
2 parents 168e522 + a16f579 commit 678d84d

File tree

1 file changed

+55
-85
lines changed

1 file changed

+55
-85
lines changed

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

Lines changed: 55 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ reviewers:
55
- dashpole
66
title: 为系统守护进程预留计算资源
77
content_type: task
8+
min-kubernetes-server-version: 1.8
89
---
910
<!--
1011
---
@@ -14,6 +15,7 @@ reviewers:
1415
- dashpole
1516
title: Reserve Compute Resources for System Daemons
1617
content_type: task
18+
min-kubernetes-server-version: 1.8
1719
---
1820
-->
1921

@@ -31,18 +33,23 @@ compute resources for system daemons. Kubernetes recommends cluster
3133
administrators to configure `Node Allocatable` based on their workload density
3234
on each node.
3335
-->
34-
Kubernetes 的节点可以按照 `Capacity` 调度。默认情况下 pod 能够使用节点全部可用容量。这是个问题,因为节点自己通常运行了不少驱动 OS 和 Kubernetes 的系统守护进程。除非为这些系统守护进程留出资源,否则它们将与 pod 争夺资源并导致节点资源短缺问题。
35-
36-
`kubelet` 公开了一个名为 `Node Allocatable` 的特性,有助于为系统守护进程预留计算资源。Kubernetes 推荐集群管理员按照每个节点上的工作负载密度配置 `Node Allocatable`
37-
36+
Kubernetes 的节点可以按照 `Capacity` 调度。默认情况下 pod 能够使用节点全部可用容量。
37+
这是个问题,因为节点自己通常运行了不少驱动 OS 和 Kubernetes 的系统守护进程。
38+
除非为这些系统守护进程留出资源,否则它们将与 pod 争夺资源并导致节点资源短缺问题。
3839

40+
`kubelet` 公开了一个名为 `Node Allocatable` 的特性,有助于为系统守护进程预留计算资源。
41+
Kubernetes 推荐集群管理员按照每个节点上的工作负载密度配置 `Node Allocatable`
3942

4043
## {{% heading "prerequisites" %}}
4144

4245

4346
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
44-
45-
47+
<!--
48+
Your Kubernetes server must be at or later than version 1.17 to use
49+
the kubelet command line option `--reserved-cpus` to set an
50+
[explicitly reserved CPU list](#explicitly-reserved-cpu-list).
51+
-->
52+
您的 kubernetes 服务器版本必须至少是 1.17 版本,才能使用 kubelet 命令行选项 `--reserved-cpus` 来设置 [显式 CPU 保留列表](#explicitly-reserved-cpu-list)
4653

4754
<!-- steps -->
4855

@@ -94,7 +101,8 @@ Resources can be reserved for two categories of system daemons in the `kubelet`.
94101
---------------------------
95102
```
96103

97-
Kubernetes 节点上的 `Allocatable` 被定义为 pod 可用计算资源量。调度器不会超额申请 `Allocatable`。目前支持 `CPU`, `memory``ephemeral-storage` 这几个参数。
104+
Kubernetes 节点上的 `Allocatable` 被定义为 pod 可用计算资源量。调度器不会超额申请 `Allocatable`
105+
目前支持 `CPU`, `memory``ephemeral-storage` 这几个参数。
98106

99107
可分配的节点暴露为 API 中 `v1.Node` 对象的一部分,也是 CLI 中 `kubectl describe node` 的一部分。
100108

@@ -110,7 +118,8 @@ under a cgroup hierarchy managed by the `kubelet`.
110118
-->
111119
### 启用 QoS 和 Pod 级别的 cgroups
112120

113-
为了恰当的在节点范围实施 node allocatable,您必须通过 `--cgroups-per-qos` 标志启用新的 cgroup 层次结构。这个标志是默认启用的。启用后,`kubelet` 将在其管理的 cgroup 层次结构中创建所有终端用户的 pod。
121+
为了恰当的在节点范围实施 node allocatable,您必须通过 `--cgroups-per-qos` 标志启用新的 cgroup 层次结构。
122+
这个标志是默认启用的。启用后,`kubelet` 将在其管理的 cgroup 层次结构中创建所有终端用户的 Pod。
114123

115124
<!--
116125
### Configuring a cgroup driver
@@ -141,7 +150,8 @@ be configured to use the `systemd` cgroup driver.
141150
* `cgroupfs` 是默认的驱动,在主机上直接操作 cgroup 文件系统以对 cgroup 沙箱进行管理。
142151
* `systemd` 是可选的驱动,使用 init 系统支持的资源的瞬时切片管理 cgroup 沙箱。
143152

144-
取决于相关容器运行时的配置,操作员可能需要选择一个特定的 cgroup 驱动来保证系统正常运行。例如如果操作员使用 `docker` 运行时提供的 `systemd` cgroup 驱动时,必须配置 `kubelet` 使用 `systemd` cgroup 驱动。
153+
取决于相关容器运行时的配置,操作员可能需要选择一个特定的 cgroup 驱动来保证系统正常运行。
154+
例如如果操作员使用 `docker` 运行时提供的 `systemd` cgroup 驱动时,必须配置 `kubelet` 使用 `systemd` cgroup 驱动。
145155

146156
<!--
147157
### Kube Reserved
@@ -152,13 +162,7 @@ be configured to use the `systemd` cgroup driver.
152162
`kube-reserved` is meant to capture resource reservation for kubernetes system
153163
daemons like the `kubelet`, `container runtime`, `node problem detector`, etc.
154164
It is not meant to reserve resources for system daemons that are run as pods.
155-
`kube-reserved` is typically a function of `pod density` on the nodes. [This
156-
performance dashboard](http://node-perf-dash.k8s.io/#/builds) exposes `cpu` and
157-
`memory` usage profiles of `kubelet` and `docker engine` at multiple levels of
158-
pod density. [This blog
159-
post](https://kubernetes.io/blog/2016/11/visualize-kubelet-performance-with-node-dashboard)
160-
explains how the dashboard can be interpreted to come up with a suitable
161-
`kube-reserved` reservation.
165+
`kube-reserved` is typically a function of `pod density` on the nodes.
162166
163167
In addition to `cpu`, `memory`, and `ephemeral-storage`, `pid` may be
164168
specified to reserve the specified number of process IDs for
@@ -185,14 +189,14 @@ exist. Kubelet will fail if an invalid cgroup is specified.
185189

186190
`kube-reserved` 是为了给诸如 `kubelet``container runtime``node problem detector` 等 kubernetes 系统守护进程争取资源预留。
187191
这并不代表要给以 pod 形式运行的系统守护进程保留资源。`kube-reserved` 通常是节点上的一个 `pod 密度` 功能。
188-
[这个性能仪表盘](http://node-perf-dash.k8s.io/#/builds) 从 pod 密度的多个层面展示了 `kubelet``docker engine``cpu``内存` 使用情况。
189-
[这个博文](https://kubernetes.io/blog/2016/11/visualize-kubelet-performance-with-node-dashboard)解释了如何仪表板以提出合适的 `kube-reserved` 预留。
190192

191193
除了 `cpu``内存``ephemeral-storage` 之外,`pid` 可能是指定为 kubernetes 系统守护进程预留指定数量的进程 ID。
192194

193195
要选择性的在系统守护进程上执行 `kube-reserved`,需要把 kubelet 的 `--kube-reserved-cgroup` 标志的值设置为 kube 守护进程的父控制组。
194196

195-
推荐将 kubernetes 系统守护进程放置于顶级控制组之下(例如 systemd 机器上的 `runtime.slice`)。理想情况下每个系统守护进程都应该在其自己的子控制组中运行。请参考[这篇文档](https://git.k8s.io/community/contributors/design-proposals/node/node-allocatable.md#recommended-cgroups-setup),获取更过关于推荐控制组层次结构的细节。
197+
推荐将 kubernetes 系统守护进程放置于顶级控制组之下(例如 systemd 机器上的 `runtime.slice`)。
198+
理想情况下每个系统守护进程都应该在其自己的子控制组中运行。
199+
请参考[这篇文档](https://git.k8s.io/community/contributors/design-proposals/node/node-allocatable.md#recommended-cgroups-setup),获取更过关于推荐控制组层次结构的细节。
196200

197201
请注意,如果 `--kube-reserved-cgroup` 不存在,Kubelet 将**不会**创建它。如果指定了一个无效的 cgroup,Kubelet 将会失败。
198202

@@ -243,7 +247,7 @@ exist. Kubelet will fail if an invalid cgroup is specified.
243247
<!--
244248
### Explicitly Reserved CPU List
245249
-->
246-
### 明确保留的 CPU 列表
250+
### 显式保留的 CPU 列表 {#explicitly-reserved-cpu-list}
247251
{{< feature-state for_k8s_version="v1.17" state="stable" >}}
248252

249253
- **Kubelet Flag**: `--reserved-cpus=0-3`
@@ -272,7 +276,10 @@ defined by this option, other mechanism outside Kubernetes should be used.
272276
For example: in Centos, you can do this using the tuned toolset.
273277
-->
274278
此选项是专门为 Telco 或 NFV 用例设计的,在这些用例中不受控制的中断或计时器可能会影响其工作负载性能。
275-
可以使用此选项为系统或 kubernetes 守护程序以及中断或计时器定义显式的 cpuset,因此系统上的其余 CPU 可以专门用于工作负载,而不受不受控制的中断或计时器的影响较小。要将系统守护程序、kubernetes 守护程序和中断或计时器移动到此选项定义的显式 cpuset 上,应使用 Kubernetes 之外的其他机制。
279+
可以使用此选项为系统或 kubernetes 守护程序以及中断或计时器定义显式的 cpuset,因此系统上的
280+
其余 CPU 可以专门用于工作负载,而不受不受控制的中断或计时器的影响较小。
281+
要将系统守护程序、kubernetes 守护程序和中断或计时器移动到此选项定义的显式 cpuset 上,
282+
应使用 Kubernetes 之外的其他机制。
276283
例如:在 Centos 系统中,可以使用 tuned 工具集来执行此操作。
277284

278285
<!--
@@ -283,7 +290,7 @@ For example: in Centos, you can do this using the tuned toolset.
283290
Memory pressure at the node level leads to System OOMs which affects the entire
284291
node and all pods running on it. Nodes can go offline temporarily until memory
285292
has been reclaimed. To avoid (or reduce the probability of) system OOMs kubelet
286-
provides [`Out of Resource`](./out-of-resource.md) management. Evictions are
293+
provides [`Out of Resource`](/docs/tasks/administer-cluster/out-of-resource/) management. Evictions are
287294
supported for `memory` and `ephemeral-storage` only. By reserving some memory via
288295
`--eviction-hard` flag, the `kubelet` attempts to `evict` pods whenever memory
289296
availability on the node drops below the reserved value. Hypothetically, if
@@ -296,7 +303,9 @@ available for pods.
296303
- **Kubelet Flag**: `--eviction-hard=[memory.available<500Mi]`
297304

298305
节点级别的内存压力将导致系统内存不足,这将影响到整个节点及其上运行的所有 pod。节点可以暂时离线直到内存已经回收为止。
299-
为了防止(或减少可能性)系统内存不足,kubelet 提供了[资源不足](./out-of-resource.md)管理。驱逐操作只支持 `memory``ephemeral-storage`
306+
为了防止(或减少可能性)系统内存不足,kubelet 提供了
307+
[资源不足](/zh/docs/tasks/administer-cluster/out-of-resource/)管理。
308+
驱逐操作只支持 `memory``ephemeral-storage`
300309
通过 `--eviction-hard` 标志预留一些内存后,当节点上的可用内存降至保留值以下时,`kubelet` 将尝试`驱逐` pod。
301310
假设,如果节点上不存在系统守护进程,pod 将不能使用超过 `capacity-eviction-hard` 的资源。因此,为驱逐而预留的资源对 pod 是不可用的。
302311

@@ -310,7 +319,7 @@ The scheduler treats `Allocatable` as the available `capacity` for pods.
310319
`kubelet` enforce `Allocatable` across pods by default. Enforcement is performed
311320
by evicting pods whenever the overall usage across all pods exceeds
312321
`Allocatable`. More details on eviction policy can be found
313-
[here](./out-of-resource.md#eviction-policy). This enforcement is controlled by
322+
[here](/docs/tasks/administer-cluster/out-of-resource/#eviction-policy). This enforcement is controlled by
314323
specifying `pods` value to the kubelet flag `--enforce-node-allocatable`.
315324
316325
@@ -326,9 +335,14 @@ respectively.
326335

327336
调度器将 `Allocatable` 按 pod 的可用 `capacity` 对待。
328337

329-
`kubelet` 默认在 pod 中执行 `Allocatable`。无论何时,如果所有 pod 的总用量超过了 `Allocatable`,驱逐 pod 的措施将被执行。有关驱逐策略的更多细节可以在[这里](./out-of-resource.md#eviction-policy)找到。请通过设置 kubelet `--enforce-node-allocatable` 标志值为 `pods` 控制这个措施。
338+
`kubelet` 默认在 Pod 中执行 `Allocatable`。无论何时,如果所有 pod 的总用量超过了 `Allocatable`
339+
驱逐 pod 的措施将被执行。有关驱逐策略的更多细节可以在
340+
[这里](/zh/docs/tasks/administer-cluster/out-of-resource/#eviction-policy).找到。
341+
请通过设置 kubelet `--enforce-node-allocatable` 标志值为 `pods` 控制这个措施。
330342

331-
可选的,通过在相同标志中同时指定 `kube-reserved``system-reserved` 值能够使 `kubelet` 执行 `kube-reserved``system-reserved`。请注意,要想执行 `kube-reserved` 或者 `system-reserved` 时,需要分别指定 `--kube-reserved-cgroup` 或者 `--system-reserved-cgroup`
343+
可选的,通过在相同标志中同时指定 `kube-reserved``system-reserved` 值能够使 `kubelet`
344+
执行 `kube-reserved``system-reserved`。请注意,要想执行 `kube-reserved` 或者 `system-reserved` 时,
345+
需要分别指定 `--kube-reserved-cgroup` 或者 `--system-reserved-cgroup`
332346

333347
<!--
334348
## General Guidelines
@@ -359,17 +373,23 @@ So expect a drop in `Allocatable` capacity in future releases.
359373
-->
360374
## 一般原则
361375

362-
系统守护进程期望被按照类似 `Guaranteed` pod 一样对待。系统守护进程可以在其范围控制组中爆发式增长,您需要将这个行为作为 kubernetes 部署的一部分进行管理。
363-
例如,`kubelet` 应该有它自己的控制组并和容器运行时共享 `Kube-reserved` 资源。然而,如果执行了 `kube-reserved`,则 kubelet 不能突然爆发并耗尽节点的所有可用资源。
376+
系统守护进程期望被按照类似 `Guaranteed` pod 一样对待。系统守护进程可以在其范围控制组中爆发式增长,
377+
您需要将这个行为作为 kubernetes 部署的一部分进行管理。
378+
例如,`kubelet` 应该有它自己的控制组并和容器运行时共享 `Kube-reserved` 资源。
379+
然而,如果执行了 `kube-reserved`,则 kubelet 不能突然爆发并耗尽节点的所有可用资源。
364380

365-
在执行 `system-reserved` 预留操作时请加倍小心,因为它可能导致节点上的关键系统服务 CPU 资源短缺或因为内存不足而被终止。
366-
建议只有当用户详尽地描述了他们的节点以得出精确的估计时才强制执行 `system-reserved`,并且如果该组中的任何进程都是 oom_killed,则对他们恢复的能力充满信心。
381+
在执行 `system-reserved` 预留操作时请加倍小心,因为它可能导致节点上的关键系统服务 CPU 资源短缺
382+
或因为内存不足而被终止。
383+
建议只有当用户详尽地描述了他们的节点以得出精确的估计时才强制执行 `system-reserved`
384+
并且如果该组中的任何进程都是 oom_killed,则对他们恢复的能力充满信心。
367385

368386
*`pods` 上执行 `Allocatable` 作为开始。
369387
* 一旦足够用于追踪系统守护进程的监控和告警的机制到位,请尝试基于用量探索方式执行 `kube-reserved`
370388
* 随着时间推进,如果绝对必要,可以执行 `system-reserved`
371389

372-
随着时间的增长以及越来越多特性的加入,kube 系统守护进程对资源的需求可能也会增加。以后 kubernetes 项目将尝试减少对节点系统守护进程的利用,但目前那并不是优先事项。所以,请期待在将来的发布中将 `Allocatable` 容量降低。
390+
随着时间的增长以及越来越多特性的加入,kube 系统守护进程对资源的需求可能也会增加。
391+
以后 kubernetes 项目将尝试减少对节点系统守护进程的利用,但目前那并不是优先事项。
392+
所以,请期待在将来的发布中将 `Allocatable` 容量降低。
373393

374394

375395

@@ -408,58 +428,8 @@ usage is higher than `31.5Gi` or `storage` is greater than `90Gi`
408428

409429
在这个场景下,`Allocatable` 将会是 `14.5 CPUs``28.5Gi` 内存以及 `88Gi` 本地存储。
410430
调度器保证这个节点上的所有 pod `请求`的内存总量不超过 `28.5Gi`,存储不超过 `88Gi`
411-
当 pod 的内存使用总量超过 `28.5Gi` 或者磁盘使用总量超过 `88Gi` 时,Kubelet 将会驱逐它们。如果节点上的所有进程都尽可能多的使用 CPU,则 pod 加起来不能使用超过 `14.5 CPUs` 的资源。
412-
413-
当没有执行 `kube-reserved` 和/或 `system-reserved` 且系统守护进程使用量超过其预留时,如果节点内存用量高于 `31.5Gi``存储`大于 `90Gi`,kubelet 将会驱逐 pod。
414-
415-
<!--
416-
## Feature Availability
417-
418-
As of Kubernetes version 1.2, it has been possible to **optionally** specify
419-
`kube-reserved` and `system-reserved` reservations. The scheduler switched to
420-
using `Allocatable` instead of `Capacity` when available in the same release.
421-
422-
As of Kubernetes version 1.6, `eviction-thresholds` are being considered by
423-
computing `Allocatable`. To revert to the old behavior set
424-
`--experimental-allocatable-ignore-eviction` kubelet flag to `true`.
425-
426-
As of Kubernetes version 1.6, `kubelet` enforces `Allocatable` on pods using
427-
control groups. To revert to the old behavior unset `--enforce-node-allocatable`
428-
kubelet flag. Note that unless `--kube-reserved`, or `--system-reserved` or
429-
`--eviction-hard` flags have non-default values, `Allocatable` enforcement does
430-
not affect existing deployments.
431-
432-
As of Kubernetes version 1.6, `kubelet` launches pods in their own cgroup
433-
sandbox in a dedicated part of the cgroup hierarchy it manages. Operators are
434-
required to drain their nodes prior to upgrade of the `kubelet` from prior
435-
versions in order to ensure pods and their associated containers are launched in
436-
the proper part of the cgroup hierarchy.
437-
438-
As of Kubernetes version 1.7, `kubelet` supports specifying `storage` as a resource
439-
for `kube-reserved` and `system-reserved`.
440-
441-
As of Kubernetes version 1.8, the `storage` key name was changed to `ephemeral-storage`
442-
for the alpha release.
443-
-->
444-
## 可用特性
445-
446-
截至 Kubernetes 1.2 版本,已经可以**可选**的指定 `kube-reserved``system-reserved` 预留。当在相同的发布中都可用时,调度器将转为使用 `Allocatable` 替代 `Capacity`
447-
448-
截至 Kubernetes 1.6 版本,`eviction-thresholds` 是通过计算 `Allocatable` 进行考虑。要使用旧版本的行为,请设置 `--experimental-allocatable-ignore-eviction` kubelet 标志为 `true`
449-
450-
截至 Kubernetes 1.6 版本,`kubelet` 使用控制组在 pod 上执行 `Allocatable`。要使用旧版本行为,请取消设置 `--enforce-node-allocatable` kubelet 标志。请注意,除非 `--kube-reserved` 或者 `--system-reserved` 或者 `--eviction-hard` 标志没有默认参数,否则 `Allocatable` 的实施不会影响已经存在的 deployment。
451-
452-
截至 Kubernetes 1.6 版本,`kubelet` 在 pod 自己的 cgroup 沙箱中启动它们,这个 cgroup 沙箱在 `kubelet` 管理的 cgroup 层次结构中的一个独占部分中。在从前一个版本升级 kubelet 之前,要求操作员 drain 节点,以保证 pod 及其关联的容器在 cgroup 层次结构中合适的部分中启动。
453-
454-
截至 Kubernetes 1.7 版本,`kubelet` 支持指定 `storage``kube-reserved``system-reserved` 的资源。
455-
456-
截至 Kubernetes 1.8 版本,对于 alpha 版本,`storage` 键值名称已更改为 `ephemeral-storage`
457-
458-
<!--
459-
As of Kubernetes version 1.17, you can optionally specify
460-
explicit cpuset by `reserved-cpus` as CPUs reserved for OS system
461-
daemons/interrupts/timers and Kubernetes daemons.
462-
-->
463-
从 Kubernetes 1.17 版本开始,可以选择将 `reserved-cpus` 显式 cpuset 指定为操作系统守护程序、中断、计时器和 Kubernetes 守护程序保留的 CPU。
464-
431+
当 pod 的内存使用总量超过 `28.5Gi` 或者磁盘使用总量超过 `88Gi` 时,Kubelet 将会驱逐它们。
432+
如果节点上的所有进程都尽可能多的使用 CPU,则 pod 加起来不能使用超过 `14.5 CPUs` 的资源。
465433

434+
当没有执行 `kube-reserved` 和/或 `system-reserved` 且系统守护进程使用量超过其预留时,
435+
如果节点内存用量高于 `31.5Gi``存储`大于 `90Gi`,kubelet 将会驱逐 pod。

0 commit comments

Comments
 (0)