Skip to content

Commit 5812a57

Browse files
committed
[zh-cn] sync pods/pod-lifecycle.md
1 parent 0825aae commit 5812a57

File tree

1 file changed

+122
-9
lines changed

1 file changed

+122
-9
lines changed

content/zh-cn/docs/concepts/workloads/pods/pod-lifecycle.md

+122-9
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ Value | Description
221221

222222
{{< note >}}
223223
<!--
224-
When a pod is failing to start repeatedly, `CrashLoopBackOff` may appear in the `Status` field of some kubectl commands. Similarly, when a pod is being deleted, `Terminating` may appear in the `Status` field of some kubectl commands.
224+
When a pod is failing to start repeatedly, `CrashLoopBackOff` may appear in the `Status` field of some kubectl commands.
225+
Similarly, when a pod is being deleted, `Terminating` may appear in the `Status` field of some kubectl commands.
225226
226227
Make sure not to confuse _Status_, a kubectl display field for user intuition, with the pod's `phase`.
227228
Pod phase is an explicit part of the Kubernetes data model and of the
@@ -511,6 +512,32 @@ kubelet 就会重置该容器的重启延迟计时器。
511512
[Sidecar 容器和 Pod 生命周期](/zh-cn/docs/concepts/workloads/pods/sidecar-containers/#sidecar-containers-and-pod-lifecycle)中解释了
512513
`init containers` 在指定 `restartpolicy` 字段时的行为。
513514

515+
<!--
516+
### Reduced container restart delay
517+
518+
{{< feature-state
519+
feature_gate_name="ReduceDefaultCrashLoopBackOffDecay" >}}
520+
521+
With the alpha feature gate `ReduceDefaultCrashLoopBackOffDecay` enabled,
522+
container start retries across your cluster will be reduced to begin at 1s
523+
(instead of 10s) and increase exponentially by 2x each restart until a maximum
524+
delay of 60s (instead of 300s which is 5 minutes).
525+
526+
If you use this feature along with the alpha feature
527+
`KubeletCrashLoopBackOffMax` (described below), individual nodes may have
528+
different maximum delays.
529+
-->
530+
### 减少容器重启延迟 {#Reduced-container-restart-delay}
531+
532+
{{< feature-state feature_gate_name="ReduceDefaultCrashLoopBackOffDecay" >}}
533+
534+
启用 Alpha 特性开关 `ReduceDefaultCrashLoopBackOffDecay` 后,
535+
集群中容器启动重试的初始延迟将从 10 秒减少到 1 秒,
536+
之后每次重启延迟时间按 2 倍指数增长,直到达到最大延迟 60 秒(之前为 300 秒,即 5 分钟)。
537+
538+
如果你同时使用了下面介绍的 Alpha 特性 `KubeletCrashLoopBackOffMax`
539+
那么单个节点上可能会有不同的最大延迟值。
540+
514541
<!--
515542
### Configurable container restart delay
516543
-->
@@ -576,6 +603,19 @@ crashLoopBackOff:
576603
maxContainerRestartPeriod: "2s"
577604
```
578605
606+
<!--
607+
If you use this feature along with the alpha feature
608+
`ReduceDefaultCrashLoopBackOffDecay` (described above), your cluster defaults
609+
for initial backoff and maximum backoff will no longer be 10s and 300s, but 1s
610+
and 60s. Per node configuration takes precedence over the defaults set by
611+
`ReduceDefaultCrashLoopBackOffDecay`, even if this would result in a node having
612+
a longer maximum backoff than other nodes in the cluster.
613+
-->
614+
如果你将此特性与上文提到的 Alpha 特性 `ReduceDefaultCrashLoopBackOffDecay` 一起使用,
615+
那么集群的初始退避时间和最大退避时间默认值将不再是 10 秒和 300 秒,而是 1 秒和 60 秒。
616+
每个节点上的配置优先于 `ReduceDefaultCrashLoopBackOffDecay` 所设置的默认值,
617+
即使这会导致某些节点的最大退避时间比集群中的其他节点更长。
618+
579619
<!--
580620
## Pod conditions
581621

@@ -921,8 +961,8 @@ containers:
921961

922962
`readinessProbe`
923963
: Indicates whether the container is ready to respond to requests.
924-
If the readiness probe fails, the endpoints controller removes the Pod's IP
925-
address from the endpoints of all Services that match the Pod. The default
964+
If the readiness probe fails, the EndpointSlice controller removes the Pod's IP
965+
address from the EndpointSlices of all Services that match the Pod. The default
926966
state of readiness before the initial delay is `Failure`. If a container does
927967
not provide a readiness probe, the default state is `Success`.
928968

@@ -941,7 +981,7 @@ containers:
941981

942982
`readinessProbe`
943983
: 指示容器是否准备好为请求提供服务。如果就绪态探测失败,
944-
端点控制器将从与 Pod 匹配的所有服务的端点列表中删除该 Pod 的 IP 地址。
984+
EndpointSlice 控制器将从与该 Pod 匹配的所有 Service 的 EndpointSlice 中删除该 Pod 的 IP 地址。
945985
初始延迟之前的就绪态的状态值默认为 `Failure`。
946986
如果容器不提供就绪态探针,则默认状态为 `Success`。
947987

@@ -1094,7 +1134,13 @@ shutdown.
10941134
Pod。
10951135

10961136
<!--
1097-
Typically, with this graceful termination of the pod, kubelet makes requests to the container runtime to attempt to stop the containers in the pod by first sending a TERM (aka. SIGTERM) signal, with a grace period timeout, to the main process in each container. The requests to stop the containers are processed by the container runtime asynchronously. There is no guarantee to the order of processing for these requests. Many container runtimes respect the `STOPSIGNAL` value defined in the container image and, if different, send the container image configured STOPSIGNAL instead of TERM.
1137+
Typically, with this graceful termination of the pod, kubelet makes requests to the container runtime
1138+
to attempt to stop the containers in the pod by first sending a TERM (aka. SIGTERM) signal,
1139+
with a grace period timeout, to the main process in each container.
1140+
The requests to stop the containers are processed by the container runtime asynchronously.
1141+
There is no guarantee to the order of processing for these requests.
1142+
Many container runtimes respect the `STOPSIGNAL` value defined in the container image and,
1143+
if different, send the container image configured STOPSIGNAL instead of TERM.
10981144
Once the grace period has expired, the KILL signal is sent to any remaining
10991145
processes, and the Pod is then deleted from the
11001146
{{< glossary_tooltip text="API Server" term_id="kube-apiserver" >}}. If the kubelet or the
@@ -1112,6 +1158,71 @@ Pod 就会被从 {{< glossary_tooltip text="API 服务器" term_id="kube-apiserv
11121158
集群会从头开始重试,赋予 Pod 完整的体面终止限期。
11131159

11141160
<!--
1161+
### Stop Signals {#pod-termination-stop-signals}
1162+
1163+
The stop signal used to kill the container can be defined in the container image with the `STOPSIGNAL` instruction.
1164+
If no stop signal is defined in the image, the default signal of the container runtime
1165+
(SIGTERM for both containerd and CRI-O) would be used to kill the container.
1166+
-->
1167+
### 停止信号 {#pod-termination-stop-signals}
1168+
1169+
用于终止容器的停止信号可以通过容器镜像中的 `STOPSIGNAL` 指令进行定义。
1170+
如果镜像中未定义停止信号,容器运行时(containerd 和 CRI-O 都是 SIGTERM)
1171+
会使用默认的停止信号来终止容器。
1172+
1173+
<!--
1174+
### Defining custom stop signals
1175+
1176+
{{< feature-state feature_gate_name="ContainerStopSignals" >}}
1177+
1178+
If the `ContainerStopSignals` feature gate is enabled, you can configure a custom stop signal
1179+
for your containers from the container Lifecycle. We require the Pod's `spec.os.name` field
1180+
to be present as a requirement for defining stop signals in the container lifecycle.
1181+
The list of signals that are valid depends on the OS the Pod is scheduled to.
1182+
For Pods scheduled to Windows nodes, we only support SIGTERM and SIGKILL as valid signals.
1183+
1184+
Here is an example Pod spec defining a custom stop signal:
1185+
1186+
```yaml
1187+
spec:
1188+
os:
1189+
name: linux
1190+
containers:
1191+
- name: my-container
1192+
image: container-image:latest
1193+
lifecycle:
1194+
stopSignal: SIGUSR1
1195+
```
1196+
1197+
If a stop signal is defined in the lifecycle, this will override the signal defined in the container image.
1198+
If no stop signal is defined in the container spec, the container would fall back to the default behavior.
1199+
-->
1200+
### 定义自定义停止信号 {#Defining-custom-stop-signals}
1201+
1202+
{{< feature-state feature_gate_name="ContainerStopSignals" >}}
1203+
1204+
如果启用了 `ContainerStopSignals` 特性门控(feature gate),
1205+
你可以通过容器的生命周期(Lifecycle)配置自定义的停止信号。
1206+
在容器生命周期中定义停止信号时,Pod 的 `spec.os.name` 字段必须存在。
1207+
可用的信号列表取决于 Pod 调度到的操作系统。
1208+
对于调度到 Windows 节点的 Pod,仅支持 SIGTERM 和 SIGKILL 信号。
1209+
1210+
以下是一个定义了自定义停止信号的 Pod 示例:
1211+
1212+
```yaml
1213+
spec:
1214+
os:
1215+
name: linux
1216+
containers:
1217+
- name: my-container
1218+
image: container-image:latest
1219+
lifecycle:
1220+
stopSignal: SIGUSR1
1221+
```
1222+
1223+
<!--
1224+
### Pod Termination Flow {#pod-termination-flow}
1225+
11151226
Pod termination flow, illustrated with an example:
11161227

11171228
1. You use the `kubectl` tool to manually delete a specific Pod, with the default grace period
@@ -1124,6 +1235,8 @@ Pod termination flow, illustrated with an example:
11241235
as terminating (a graceful shutdown duration has been set), the kubelet begins the local Pod
11251236
shutdown process.
11261237
-->
1238+
### Pod 终止流程 {#pod-termination-flow}
1239+
11271240
Pod 终止流程,如下例所示:
11281241

11291242
1. 你使用 `kubectl` 工具手动删除某个特定的 Pod,而该 Pod 的体面终止限期是默认值(30 秒)。
@@ -1184,7 +1297,7 @@ Pod 终止流程,如下例所示:
11841297

11851298
<!--
11861299
1. At the same time as the kubelet is starting graceful shutdown of the Pod, the control plane
1187-
evaluates whether to remove that shutting-down Pod from EndpointSlice (and Endpoints) objects,
1300+
evaluates whether to remove that shutting-down Pod from EndpointSlice objects,
11881301
where those objects represent a {{< glossary_tooltip term_id="service" text="Service" >}}
11891302
with a configured {{< glossary_tooltip text="selector" term_id="selector" >}}.
11901303
{{< glossary_tooltip text="ReplicaSets" term_id="replica-set" >}} and other workload resources
@@ -1196,7 +1309,7 @@ Pod 终止流程,如下例所示:
11961309
and completion.
11971310
-->
11981311
3. 在 `kubelet` 启动 Pod 的体面关闭逻辑的同时,控制平面会评估是否将关闭的
1199-
Pod 从对应的 EndpointSlice(和端点)对象中移除,过滤条件是 Pod
1312+
Pod 从对应的 EndpointSlice 对象中移除,过滤条件是 Pod
12001313
被对应的{{< glossary_tooltip term_id="service" text="服务" >}}以某
12011314
{{< glossary_tooltip text="选择算符" term_id="selector" >}}选定。
12021315
{{< glossary_tooltip text="ReplicaSet" term_id="replica-set" >}}
@@ -1209,7 +1322,7 @@ Pod 终止流程,如下例所示:
12091322
<!--
12101323
Any endpoints that represent the terminating Pods are not immediately removed from
12111324
EndpointSlices, and a status indicating [terminating state](/docs/concepts/services-networking/endpoint-slices/#conditions)
1212-
is exposed from the EndpointSlice API (and the legacy Endpoints API).
1325+
is exposed from the EndpointSlice API.
12131326
Terminating endpoints always have their `ready` status as `false` (for backward compatibility
12141327
with versions before 1.26), so load balancers will not use it for regular traffic.
12151328

@@ -1218,7 +1331,7 @@ Pod 终止流程,如下例所示:
12181331
tutorial [Pods And Endpoints Termination Flow](/docs/tutorials/services/pods-and-endpoint-termination-flow/)
12191332
-->
12201333
任何正在终止的 Pod 所对应的端点都不会立即从 EndpointSlice
1221-
中被删除,EndpointSlice API(以及传统的 Endpoints API)会公开一个状态来指示其处于
1334+
中被删除,EndpointSlice API 会公开一个状态来指示其处于
12221335
[终止状态](/zh-cn/docs/concepts/services-networking/endpoint-slices/#conditions)。
12231336
正在终止的端点始终将其 `ready` 状态设置为 `false`(为了向后兼容 1.26 之前的版本),
12241337
因此负载均衡器不会将其用于常规流量。

0 commit comments

Comments
 (0)