@@ -41,7 +41,7 @@ and run code implemented in a handler when the corresponding lifecycle hook is e
41
41
42
42
There are two hooks that are exposed to Containers:
43
43
-->
44
- ## 容器回调
44
+ ## 容器回调 {#container-hooks}
45
45
46
46
有两个回调暴露给容器:
47
47
@@ -80,7 +80,7 @@ A more detailed description of the termination behavior can be found in
80
80
[Termination of Pods](/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination).
81
81
-->
82
82
有关终止行为的更详细描述,请参见
83
- [ 终止 Pod] ( /zh-cn/docs/concepts/workloads/pods/pod-lifecycle/#termination-of-pods ) 。
83
+ [ 终止 Pod] ( /zh-cn/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination ) 。
84
84
85
85
<!--
86
86
### Hook handler implementations
@@ -99,7 +99,7 @@ Resources consumed by the command are counted against the Container.
99
99
* HTTP - Executes an HTTP request against a specific endpoint on the Container.
100
100
-->
101
101
102
- * Exec - 在容器的 cgroups 和名称空间中执行特定的命令 (例如 ` pre-stop.sh ` )。
102
+ * Exec - 在容器的 cgroups 和名字空间中执行特定的命令 (例如 ` pre-stop.sh ` )。
103
103
命令所消耗的资源计入容器的资源消耗。
104
104
* HTTP - 对容器上的特定端点执行 HTTP 请求。
105
105
@@ -140,31 +140,14 @@ takes 55 seconds to complete, and the Container takes 10 seconds to stop
140
140
normally after receiving the signal, then the Container will be killed
141
141
before it can stop normally, since `terminationGracePeriodSeconds` is
142
142
less than the total time (55+10) it takes for these two things to happen.
143
-
144
- `PreStop` hooks are not executed asynchronously from the signal
145
- to stop the Container; the hook must complete its execution before
146
- the signal can be sent.
147
- If a `PreStop` hook hangs during execution,
148
- the Pod's phase will be `Terminating` and remain there until the Pod is
149
- killed after its `terminationGracePeriodSeconds` expires.
150
- This grace period applies to the total time it takes for both
151
- the `PreStop` hook to execute and for the Container to stop normally.
152
- If, for example, `terminationGracePeriodSeconds` is 60, and the hook
153
- takes 55 seconds to complete, and the Container takes 10 seconds to stop
154
- normally after receiving the signal, then the Container will be killed
155
- before it can stop normally, since `terminationGracePeriodSeconds` is
156
- less than the total time (55+10) it takes for these two things to happen.
157
143
-->
158
- ` PreStop ` 回调并不会与停止容器的信号处理程序异步执行;回调必须在
159
- 可以发送信号之前完成执行。
160
- 如果 ` PreStop ` 回调在执行期间停滞不前,Pod 的阶段会变成 ` Terminating `
161
- 并且一直处于该状态,直到其 ` terminationGracePeriodSeconds ` 耗尽为止,
162
- 这时 Pod 会被杀死。
144
+ ` PreStop ` 回调并不会与停止容器的信号处理程序异步执行;回调必须在可以发送信号之前完成执行。
145
+ 如果 ` PreStop ` 回调在执行期间停滞不前,Pod 的阶段会变成 ` Terminating ` 并且一直处于该状态,
146
+ 直到其 ` terminationGracePeriodSeconds ` 耗尽为止,这时 Pod 会被杀死。
163
147
这一宽限期是针对 ` PreStop ` 回调的执行时间及容器正常停止时间的总和而言的。
164
- 例如,如果 ` terminationGracePeriodSeconds ` 是 60,回调函数花了 55 秒钟
165
- 完成执行,而容器在收到信号之后花了 10 秒钟来正常结束,那么容器会在其
166
- 能够正常结束之前即被杀死,因为 ` terminationGracePeriodSeconds ` 的值
167
- 小于后面两件事情所花费的总时间(55+10)。
148
+ 例如,如果 ` terminationGracePeriodSeconds ` 是 60,回调函数花了 55 秒钟完成执行,
149
+ 而容器在收到信号之后花了 10 秒钟来正常结束,那么容器会在其能够正常结束之前即被杀死,
150
+ 因为 ` terminationGracePeriodSeconds ` 的值小于后面两件事情所花费的总时间(55+10)。
168
151
169
152
<!--
170
153
If either a `PostStart` or `PreStop` hook fails,
@@ -224,7 +207,7 @@ Here is some example output of the resulting events you see from running `kubect
224
207
对于 ` PostStart ` ,这是 ` FailedPostStartHook ` 事件,对于 ` PreStop ` ,这是 ` FailedPreStopHook ` 事件。
225
208
要自己生成失败的 ` FailedPreStopHook ` 事件,请修改
226
209
[ lifecycle-events.yaml] ( https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/pods/lifecycle-events.yaml )
227
- 文件将 postStart 命令更改为 ”badcommand“ 并应用它。
210
+ 文件将 postStart 命令更改为 “badcommand” 并应用它。
228
211
以下是通过运行 ` kubectl describe pod lifecycle-demo ` 后你看到的一些结果事件的示例输出:
229
212
230
213
```
@@ -250,6 +233,6 @@ Events:
250
233
[attaching handlers to Container lifecycle events](/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/).
251
234
-->
252
235
253
- * 进一步了解[ 容器环境] ( /zh-cn/docs/concepts/containers/container-environment/ )
254
- * 动手实践, [ 为容器生命周期事件添加处理程序 ] ( /zh-cn/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/ )
236
+ * 进一步了解[ 容器环境] ( /zh-cn/docs/concepts/containers/container-environment/ ) 。
237
+ * 动手 [ 为容器的生命周期事件设置处理函数 ] ( /zh-cn/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/ ) 。
255
238
0 commit comments