Skip to content

Commit 15a085e

Browse files
committed
[zh] Sync node-pressure-eviction.md
1 parent 58c5aa5 commit 15a085e

File tree

1 file changed

+65
-45
lines changed

1 file changed

+65
-45
lines changed

content/zh-cn/docs/concepts/scheduling-eviction/node-pressure-eviction.md

Lines changed: 65 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@ title: 节点压力驱逐
33
content_type: concept
44
weight: 100
55
---
6-
<!--
6+
<!--
77
title: Node-pressure Eviction
88
content_type: concept
99
weight: 100
1010
-->
1111

1212
{{<glossary_definition term_id="node-pressure-eviction" length="short">}}</br>
1313

14-
{{< feature-state feature_gate_name="KubeletSeparateDiskGC" >}}
15-
1614
{{<note>}}
1715
<!--
16+
{{< feature-state feature_gate_name="KubeletSeparateDiskGC" >}}
1817
The _split image filesystem_ feature, which enables support for the `containerfs`
1918
filesystem, adds several new eviction signals, thresholds and metrics. To use
2019
`containerfs`, the Kubernetes release v{{< skew currentVersion >}} requires the
2120
`KubeletSeparateDiskGC` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
2221
to be enabled. Currently, only CRI-O (v1.29 or higher) offers the `containerfs`
2322
filesystem support.
2423
-->
24+
{{< feature-state feature_gate_name="KubeletSeparateDiskGC" >}}
2525
**拆分镜像文件系统** 功能支持 `containerfs` 文件系统,并增加了几个新的驱逐信号、阈值和指标。
2626
要使用 `containerfs`,Kubernetes 版本 v{{< skew currentVersion >}} 需要启用 `KubeletSeparateDiskGC`
2727
[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)
@@ -46,8 +46,9 @@ Node-pressure eviction is not the same as
4646
当这些资源中的一个或者多个达到特定的消耗水平,
4747
kubelet 可以主动地使节点上一个或者多个 Pod 失效,以回收资源防止饥饿。
4848

49-
在节点压力驱逐期间,kubelet 将所选 Pod 的[阶段](/zh-cn/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase)
50-
设置为 `Failed` 并终止 Pod。
49+
在节点压力驱逐期间,kubelet 将所选 Pod
50+
[阶段](/zh-cn/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase)设置为
51+
`Failed` 并终止 Pod。
5152

5253
节点压力驱逐不同于 [API 发起的驱逐](/zh-cn/docs/concepts/scheduling-eviction/api-eviction/)
5354

@@ -65,7 +66,7 @@ kubelet 并不理会你配置的 {{<glossary_tooltip term_id="pod-disruption-bud
6566
如果你使用了[硬驱逐条件](#hard-eviction-thresholds),kubelet 使用 `0s`
6667
宽限期(立即关闭)来终止 Pod。
6768

68-
<!--
69+
<!--
6970
## Self healing behavior
7071
7172
The kubelet attempts to [reclaim node-level resources](#reclaim-node-resources)
@@ -151,6 +152,18 @@ kubelet 使用驱逐信号,通过将信号与驱逐条件进行比较来做出
151152

152153
kubelet 使用以下驱逐信号:
153154

155+
<!--
156+
| Eviction Signal | Description | Linux Only |
157+
|--------------------------|---------------------------------------------------------------------------------------|------------|
158+
| `memory.available` | `memory.available` := `node.status.capacity[memory]` - `node.stats.memory.workingSet` | |
159+
| `nodefs.available` | `nodefs.available` := `node.stats.fs.available` | |
160+
| `nodefs.inodesFree` | `nodefs.inodesFree` := `node.stats.fs.inodesFree` | • |
161+
| `imagefs.available` | `imagefs.available` := `node.stats.runtime.imagefs.available` | |
162+
| `imagefs.inodesFree` | `imagefs.inodesFree` := `node.stats.runtime.imagefs.inodesFree` | • |
163+
| `containerfs.available` | `containerfs.available` := `node.stats.runtime.containerfs.available` | |
164+
| `containerfs.inodesFree` | `containerfs.inodesFree` := `node.stats.runtime.containerfs.inodesFree` | • |
165+
| `pid.available` | `pid.available` := `node.stats.rlimit.maxpid` - `node.stats.rlimit.curproc` | • |
166+
-->
154167
| 驱逐信号 | 描述 | 仅限于 Linux |
155168
|--------------------------|---------------------------------------------------------------------------------------|------------|
156169
| `memory.available` | `memory.available` := `node.status.capacity[memory]` - `node.stats.memory.workingSet` | |
@@ -186,16 +199,15 @@ reproduces the same set of steps that the kubelet performs to calculate
186199
file-backed memory on inactive LRU list) from its calculation as it assumes that
187200
memory is reclaimable under pressure.
188201
-->
189-
190202
#### 内存信号 {#memory-signals}
191203

192204
在 Linux 节点上,`memory.available` 的值来自 cgroupfs,而不是像 `free -m` 这样的工具。
193-
这很重要,因为 `free -m` 在容器中不起作用,如果用户使用
194-
[节点可分配资源](/zh-cn/docs/tasks/administer-cluster/reserve-compute-resources/#node-allocatable)
195-
这一功能特性,资源不足的判定是基于 cgroup 层次结构中的用户 Pod 所处的局部及 cgroup 根节点作出的。
205+
这很重要,因为 `free -m` 在容器中不起作用,
206+
如果用户使用[节点可分配资源](/zh-cn/docs/tasks/administer-cluster/reserve-compute-resources/#node-allocatable)这一功能特性,
207+
资源不足的判定是基于 cgroup 层次结构中的用户 Pod 所处的局部及 cgroup 根节点作出的。
196208
这个[脚本](/zh-cn/examples/admin/resource/memory-available.sh)或者
197-
[cgroupv2 脚本](/zh-cn/examples/admin/resource/memory-available-cgroupv2.sh)
198-
重现了 kubelet 为计算 `memory.available` 而执行的相同步骤。
209+
[cgroupv2 脚本](/zh-cn/examples/admin/resource/memory-available-cgroupv2.sh)重现了
210+
kubelet 为计算 `memory.available` 而执行的相同步骤。
199211
kubelet 在其计算中排除了 inactive_file(非活动 LRU 列表上基于文件来虚拟的内存的字节数),
200212
因为它假定在压力下内存是可回收的。
201213

@@ -206,7 +218,8 @@ system call) by subtracting the node's global [`CommitTotal`](https://learn.micr
206218
-->
207219
在 Windows 节点上,`memory.available` 的值来自节点的全局内存提交级别
208220
(通过 [`GetPerformanceInfo()`](https://learn.microsoft.com/windows/win32/api/psapi/nf-psapi-getperformanceinfo)系统调用查询),
209-
方法是从节点的 [`CommitLimit`](https://learn.microsoft.com/windows/win32/api/psapi/ns-psapi-performance_information)减去节点的全局
221+
方法是从节点的 [`CommitLimit`](https://learn.microsoft.com/windows/win32/api/psapi/ns-psapi-performance_information)
222+
减去节点的全局
210223
[`CommitTotal`](https://learn.microsoft.com/windows/win32/api/psapi/ns-psapi-performance_information)
211224
请注意,如果节点的页面文件大小发生变化,`CommitLimit` 也会发生变化!
212225

@@ -499,24 +512,25 @@ The kubelet maps eviction signals to node conditions as follows:
499512
| `MemoryPressure` | `memory.available` | Available memory on the node has satisfied an eviction threshold |
500513
| `DiskPressure` | `nodefs.available`, `nodefs.inodesFree`, `imagefs.available`, `imagefs.inodesFree`, `containerfs.available`, or `containerfs.inodesFree` | Available disk space and inodes on either the node's root filesystem, image filesystem, or container filesystem has satisfied an eviction threshold |
501514
| `PIDPressure` | `pid.available` | Available processes identifiers on the (Linux) node has fallen below an eviction threshold |
515+
-->
516+
kubelet 根据下表将驱逐信号映射为节点状况:
517+
518+
| 节点状况 | 驱逐信号 | 描述 |
519+
|---------|--------|------|
520+
| `MemoryPressure` | `memory.available` | 节点上的可用内存已满足驱逐条件 |
521+
| `DiskPressure` | `nodefs.available``nodefs.inodesFree``imagefs.available``imagefs.inodesFree``containerfs.available``containerfs.inodesFree` | 节点的根文件系统、镜像文件系统或容器文件系统上的可用磁盘空间和 inode 已满足驱逐阈值 |
522+
| `PIDPressure` | `pid.available` | (Linux)节点上的可用进程标识符已低于驱逐条件 |
502523

524+
<!--
503525
The control plane also [maps](/docs/concepts/scheduling-eviction/taint-and-toleration/#taint-nodes-by-condition)
504526
these node conditions to taints.
505527
506528
The kubelet updates the node conditions based on the configured
507529
`--node-status-update-frequency`, which defaults to `10s`.
508530
-->
509-
kubelet 根据下表将驱逐信号映射为节点状况:
510-
511-
| 节点条件 | 驱逐信号 | 描述 |
512-
|---------|--------|------|
513-
| `MemoryPressure` | `memory.available` | 节点上的可用内存已满足驱逐条件 |
514-
| `DiskPressure` | `nodefs.available`, `nodefs.inodesFree`, `imagefs.available`, `imagefs.inodesFree`, `containerfs.available`, 或 `containerfs.inodesFree` | 节点的根文件系统、镜像文件系统或容器文件系统上的可用磁盘空间和 inode 已满足驱逐阈值 |
515-
| `PIDPressure` | `pid.available` | (Linux) 节点上的可用进程标识符已低于驱逐条件 |
516-
517531
控制平面还将这些节点状况[映射](/zh-cn/docs/concepts/scheduling-eviction/taint-and-toleration/#taint-nodes-by-condition)为其污点。
518532

519-
kubelet 根据配置的 `--node-status-update-frequency` 更新节点条件,默认为 `10s`
533+
kubelet 根据配置的 `--node-status-update-frequency` 更新节点状况,默认为 `10s`
520534

521535
<!--
522536
### Node condition oscillation
@@ -532,10 +546,10 @@ condition to a different state. The transition period has a default value of `5m
532546
### 节点状况波动 {#node-condition-oscillation}
533547

534548
在某些情况下,节点在软驱逐条件上下振荡,而没有保持定义的宽限期。
535-
这会导致报告的节点条件在 `true``false` 之间不断切换,从而导致错误的驱逐决策。
549+
这会导致报告的节点状况在 `true``false` 之间不断切换,从而导致错误的驱逐决策。
536550

537551
为了防止振荡,你可以使用 `eviction-pressure-transition-period` 标志,
538-
该标志控制 kubelet 在将节点条件转换为不同状态之前必须等待的时间
552+
该标志控制 kubelet 在将节点状况转换为不同状态之前必须等待的时间
539553
过渡期的默认值为 `5m`
540554

541555
<!--
@@ -601,12 +615,12 @@ reclaim resources as follows:
601615
- If the `imagefs` filesystem meets the eviction thresholds, the kubelet
602616
deletes all unused images.
603617
-->
604-
#### 使用 `imagefs``containerfs` {#with-imagefs-and-containerfs}
618+
#### `imagefs``containerfs` {#with-imagefs-and-containerfs}
605619

606620
如果节点除了 `imagefs` 文件系统之外还配置了专用的 `containerfs` 以供容器运行时使用,
607621
则 kubelet 将尝试按如下方式回收资源:
608622

609-
- 如果 `containerfs` 文件系统满足驱逐阈值,则 kubelet 将垃圾收集死机的 pod 和容器。
623+
- 如果 `containerfs` 文件系统满足驱逐阈值,则 kubelet 将垃圾收集死机的 Pod 和容器。
610624

611625
- 如果 `imagefs` 文件系统满足驱逐阈值,则 kubelet 将删除所有未使用的镜像。
612626

@@ -649,7 +663,7 @@ As a result, kubelet ranks and evicts pods in the following order:
649663
1. 资源使用量少于请求量的 `Guaranteed` Pod 和 `Burstable` Pod 根据其优先级被最后驱逐。
650664

651665
{{<note>}}
652-
<!--
666+
<!--
653667
The kubelet does not use the pod's [QoS class](/docs/concepts/workloads/pods/pod-qos/) to determine the eviction order.
654668
You can use the QoS class to estimate the most likely pod eviction order when
655669
reclaiming resources like memory. QoS classification does not apply to EphemeralStorage requests,
@@ -741,30 +755,30 @@ kubelet 根据节点是否具有专用的 `imagefs` 文件系统 或者 `contain
741755
- 如果 `containerfs` 触发驱逐,kubelet 将根据
742756
`containerfs` 使用情况(`本地卷 + 日志和所有容器的可写层`)对 Pod 进行排序。
743757

744-
- 如果 `imagefs` 触发驱逐,kubelet 将根据
745-
`镜像存储` 用量对 Pod 进行排序,该用量表示给定镜像的磁盘使用情况。
758+
- 如果 `imagefs` 触发驱逐,kubelet
759+
将根据`镜像存储`用量对 Pod 进行排序,该用量表示给定镜像的磁盘使用情况。
746760

747761
<!--
748762
### Minimum eviction reclaim
763+
-->
764+
### 最小驱逐回收 {#minimum-eviction-reclaim}
749765

750766
{{<note>}}
767+
<!--
751768
As of Kubernetes v{{< skew currentVersion >}}, you cannot set a custom value
752769
for the `containerfs.available` metric. The configuration for this specific
753770
metric will be set automatically to reflect values set for either the `nodefs`
754771
or `imagefs`, depending on the configuration.
772+
-->
773+
在 Kubernetes v{{< skew currentVersion >}} 中,你无法为 `containerfs.available` 指标设置自定义值。
774+
此特定指标的配置将自动设置为反映为 `nodefs``imagefs` 设置的值,具体取决于配置。
755775
{{</note>}}
756776

777+
<!--
757778
In some cases, pod eviction only reclaims a small amount of the starved resource.
758779
This can lead to the kubelet repeatedly hitting the configured eviction thresholds
759780
and triggering multiple evictions.
760781
-->
761-
### 最小驱逐回收 {#minimum-eviction-reclaim}
762-
763-
{{<note>}}
764-
在 Kubernetes v{{< skew currentVersion >}} 中,你无法为 `containerfs.available` 指标设置自定义值。
765-
此特定指标的配置将自动设置为反映为 `nodefs``imagefs` 设置的值,具体取决于配置。
766-
{{</note>}}
767-
768782
在某些情况下,驱逐 Pod 只会回收少量的紧俏资源。
769783
这可能导致 kubelet 反复达到配置的驱逐条件并触发多次驱逐。
770784

@@ -777,8 +791,7 @@ reclaims the quantity you specify.
777791
For example, the following configuration sets minimum reclaim amounts:
778792
-->
779793
你可以使用 `--eviction-minimum-reclaim` 标志或
780-
[kubelet 配置文件](/zh-cn/docs/tasks/administer-cluster/kubelet-config-file/)
781-
为每个资源配置最小回收量。
794+
[kubelet 配置文件](/zh-cn/docs/tasks/administer-cluster/kubelet-config-file/)为每个资源配置最小回收量。
782795
当 kubelet 注意到某个资源耗尽时,它会继续回收该资源,直到回收到你所指定的数量为止。
783796

784797
例如,以下配置设置最小回收量:
@@ -834,20 +847,27 @@ The kubelet sets an `oom_score_adj` value for each container based on the QoS fo
834847

835848
kubelet 根据 Pod 的服务质量(QoS)为每个容器设置一个 `oom_score_adj` 值。
836849

850+
<!--
851+
| Quality of Service | `oom_score_adj` |
852+
|--------------------|-----------------------------------------------------------------------------------|
853+
| `Guaranteed` | -997 |
854+
| `BestEffort` | 1000 |
855+
| `Burstable` | _min(max(2, 1000 - (1000 × memoryRequestBytes) / machineMemoryCapacityBytes), 999)_ |
856+
-->
837857
| 服务质量 | `oom_score_adj` |
838858
|--------------------|---------------------------------------------------------------------------------------|
839859
| `Guaranteed` | -997 |
840860
| `BestEffort` | 1000 |
841861
| `Burstable` | **min(max(2, 1000 - (1000 * memoryRequestBytes) / machineMemoryCapacityBytes), 999)** |
842862

843863
{{<note>}}
844-
<!--
864+
<!--
845865
The kubelet also sets an `oom_score_adj` value of `-997` for any containers in Pods that have
846866
`system-node-critical` {{<glossary_tooltip text="Priority" term_id="pod-priority">}}.
847867
-->
848868
kubelet 还将具有 `system-node-critical`
849-
{{<glossary_tooltip text="优先级" term_id="pod-priority">}}
850-
的任何 Pod 中的容器 `oom_score_adj` 值设为 `-997`。
869+
{{<glossary_tooltip text="优先级" term_id="pod-priority">}}的任何
870+
Pod 中的容器 `oom_score_adj` 值设为 `-997`。
851871
{{</note>}}
852872

853873
<!--
@@ -870,7 +890,7 @@ based on its `restartPolicy`.
870890
这意味着低 QoS Pod 中相对于其调度请求消耗内存较多的容器,将首先被杀死。
871891

872892
与 Pod 驱逐不同,如果容器被 OOM 杀死,
873-
`kubelet` 可以根据其 `restartPolicy` 重新启动它。
893+
kubelet 可以根据其 `restartPolicy` 重新启动它。
874894

875895
<!--
876896
## Good practices {#node-pressure-eviction-good-practices}
@@ -945,8 +965,7 @@ Pod 优先级是做出驱逐决定的主要因素。
945965
如果你不希望 kubelet 驱逐属于 DaemonSet 的 Pod,
946966
请在 Pod 规约中通过指定合适的 `priorityClassName` 为这些 Pod
947967
提供足够高的 `priorityClass`。
948-
你还可以使用较低优先级或默认优先级,以便
949-
仅在有足够资源时才运行 `DaemonSet` Pod。
968+
你还可以使用较低优先级或默认优先级,以便仅在有足够资源时才运行 `DaemonSet` Pod。
950969

951970
<!--
952971
## Known issues
@@ -1014,7 +1033,8 @@ You can work around that behavior by setting the memory limit and memory request
10141033
the same for containers likely to perform intensive I/O activity. You will need
10151034
to estimate or measure an optimal memory limit value for that container.
10161035
-->
1017-
更多细节请参见 [https://github.com/kubernetes/kubernetes/issues/43916](https://github.com/kubernetes/kubernetes/issues/43916)。
1036+
更多细节请参见
1037+
[https://github.com/kubernetes/kubernetes/issues/43916](https://github.com/kubernetes/kubernetes/issues/43916)。
10181038

10191039
你可以通过为可能执行 I/O 密集型活动的容器设置相同的内存限制和内存请求来应对该行为。
10201040
你将需要估计或测量该容器的最佳内存限制值。

0 commit comments

Comments
 (0)