You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/zh/docs/concepts/containers/container-lifecycle-hooks.md
+30-11Lines changed: 30 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,16 +59,21 @@ No parameters are passed to the handler.
59
59
`PreStop`
60
60
61
61
<!--
62
-
This hook is called immediately before a container is terminated due to an API request or management event such as liveness probe failure, preemption, resource contention and others. A call to the preStop hook fails if the container is already in terminated or completed state.
63
-
It is blocking, meaning it is synchronous,
64
-
so it must complete before the signal to stop the container can be sent.
65
-
No parameters are passed to the handler.
66
-
-->
67
-
在容器因 API 请求或者管理事件(诸如存活态探针失败、资源抢占、资源竞争等)而被终止之前,
68
-
此回调会被调用。
69
-
如果容器已经处于终止或者完成状态,则对 preStop 回调的调用将失败。
70
-
此调用是阻塞的,也是同步调用,因此必须在发出删除容器的信号之前完成。
71
-
没有参数传递给处理程序。
62
+
This hook is called immediately before a container is terminated due to an API request or management
63
+
event such as a liveness/startup probe failure, preemption, resource contention and others. A call
64
+
to the `PreStop` hook fails if the container is already in a terminated or completed state and the
65
+
hook must complete before the TERM signal to stop the container can be sent. The Pod's termination
66
+
grace period countdown begins before the `PreStop` hook is executed, so regardless of the outcome of
67
+
the handler, the container will eventually terminate within the Pod's termination grace period. No
68
+
parameters are passed to the handler.
69
+
-->
70
+
在容器因 API 请求或者管理事件(诸如存活态探针、启动探针失败、资源抢占、资源竞争等)
71
+
而被终止之前,此回调会被调用。
72
+
如果容器已经处于已终止或者已完成状态,则对 preStop 回调的调用将失败。
73
+
在用来停止容器的 TERM 信号被发出之前,回调必须执行结束。
74
+
Pod 的终止宽限周期在 `PreStop` 回调被执行之前即开始计数,所以无论
75
+
回调函数的执行结果如何,容器最终都会在 Pod 的终止宽限期内被终止。
76
+
没有参数会被传递给处理程序。
72
77
73
78
<!--
74
79
A more detailed description of the termination behavior can be found in
@@ -122,6 +127,20 @@ the Container cannot reach a `running` state.
122
127
但是,如果回调运行或挂起的时间太长,则容器无法达到 `running` 状态。
123
128
124
129
<!--
130
+
`PreStop` hooks are not executed asynchronously from the signal
131
+
to stop the Container; the hook must complete its execution before
132
+
the TERM signal can be sent.
133
+
If a `PreStop` hook hangs during execution,
134
+
the Pod's phase will be `Terminating` and remain there until the Pod is
135
+
killed after its `terminationGracePeriodSeconds` expires.
136
+
This grace period applies to the total time it takes for both
137
+
the `PreStop` hook to execute and for the Container to stop normally.
138
+
If, for example, `terminationGracePeriodSeconds` is 60, and the hook
139
+
takes 55 seconds to complete, and the Container takes 10 seconds to stop
140
+
normally after receiving the signal, then the Container will be killed
141
+
before it can stop normally, since `terminationGracePeriodSeconds` is
142
+
less than the total time (55+10) it takes for these two things to happen.
143
+
125
144
`PreStop` hooks are not executed asynchronously from the signal
126
145
to stop the Container; the hook must complete its execution before
127
146
the signal can be sent.
@@ -145,7 +164,7 @@ less than the total time (55+10) it takes for these two things to happen.
When `imagePullPolicy` is defined without a specific value, it is also set to `Always`.
147
+
-->
116
148
如果 `imagePullPolicy` 未被定义为特定的值,也会被设置为 `Always`。
117
149
118
150
<!--
@@ -245,7 +277,7 @@ example, run these on your desktop/laptop:
245
277
246
278
<!--
247
279
1. Run `docker login [server]` for each set of credentials you want to use. This updates `$HOME/.docker/config.json` on your PC.
248
-
1. View `$HOME/.docker/config.json` in an editor to ensure it contains just the credentials you want to use.
280
+
1. View `$HOME/.docker/config.json` in an editor to ensure it contains only the credentials you want to use.
249
281
1. Get a list of your nodes; for example:
250
282
- if you want the names: `nodes=$( kubectl get nodes -o jsonpath='{range.items[*].metadata}{.name} {end}' )`
251
283
- if you want to get the IP addresses: `nodes=$( kubectl get nodes -o jsonpath='{range .items[*].status.addresses[?(@.type=="ExternalIP")]}{.address} {end}' )`
0 commit comments