@@ -33,7 +33,7 @@ Kubernetes 将发送一个 preStop 事件。容器可以为每个事件指定一
33
33
In this exercise, you create a Pod that has one Container. The Container has handlers
34
34
for the postStart and preStop events.
35
35
-->
36
- ## 定义 postStart 和 preStop 处理函数
36
+ ## 定义 postStart 和 preStop 处理函数 {#define-poststart-and-prestop-handlers}
37
37
38
38
在本练习中,你将创建一个包含一个容器的 Pod,该容器为 postStart 和 preStop 事件提供对应的处理函数。
39
39
@@ -75,7 +75,7 @@ Get a shell into the Container running in your Pod:
75
75
-->
76
76
使用 shell 连接到你的 Pod 里的容器:
77
77
78
- ```
78
+ ``` shell
79
79
kubectl exec -it lifecycle-demo -- /bin/bash
80
80
```
81
81
@@ -91,7 +91,7 @@ root@lifecycle-demo:/# cat /usr/share/message
91
91
<!--
92
92
The output shows the text written by the postStart handler:
93
93
-->
94
- 命令行输出的是 ` postStart ` 处理函数所写入的文本
94
+ 命令行输出的是 ` postStart ` 处理函数所写入的文本:
95
95
96
96
```
97
97
Hello from the postStart handler
@@ -109,7 +109,7 @@ relative to the Container's code, but Kubernetes' management of the container
109
109
blocks until the postStart handler completes. The Container's status is not
110
110
set to RUNNING until the postStart handler completes.
111
111
-->
112
- ## 讨论
112
+ ## 讨论 {#discussion}
113
113
114
114
Kubernetes 在容器创建后立即发送 postStart 事件。
115
115
然而,postStart 处理函数的调用不保证早于容器的入口点(entrypoint)
@@ -122,22 +122,22 @@ RUNNING。
122
122
Kubernetes sends the preStop event immediately before the Container is terminated.
123
123
Kubernetes' management of the Container blocks until the preStop handler completes,
124
124
unless the Pod's grace period expires. For more details, see
125
- [Termination of Pods ](/docs/user-guide/ pods/#termination-of-pods ).
125
+ [Pod Lifecycle ](/docs/concepts/workloads/ pods/pod-lifecycle/ ).
126
126
-->
127
- Kubernetes 在容器结束前立即发送 preStop 事件。除非 Pod 宽限期限超时,Kubernetes 的容器管理逻辑
128
- 会一直阻塞等待 preStop 处理函数执行完毕。更多的相关细节,可以参阅
129
- [ Pods 的结束 ] ( /zh-cn/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination ) 。
127
+ Kubernetes 在容器结束前立即发送 preStop 事件。除非 Pod 宽限期限超时,
128
+ Kubernetes 的容器管理逻辑会一直阻塞等待 preStop 处理函数执行完毕。
129
+ 更多细节请参阅 [ Pod 的生命周期 ] ( /zh-cn/docs/concepts/workloads/pods/pod-lifecycle/ ) 。
130
130
131
+ {{< note >}}
131
132
<!--
132
- Kubernetes only sends the preStop event when a Pod is *terminated*.
133
+ Kubernetes only sends the preStop event when a Pod or a container in the Pod is *terminated*.
133
134
This means that the preStop hook is not invoked when the Pod is *completed*.
134
- This limitation is tracked in [issue #55087](https://github.com/kubernetes/kubernetes/issues/55807) .
135
+ About this limitation, please see [Container hooks](/docs/concepts/containers/container-lifecycle-hooks/#container-hooks) for the detail .
135
136
-->
136
- {{< note >}}
137
- Kubernetes 只有在 Pod * 结束(Terminated)* 的时候才会发送 preStop 事件,
138
- 这意味着在 Pod * 完成(Completed)* 时
139
- preStop 的事件处理逻辑不会被触发。这个限制在
140
- [ issue #55087 ] ( https://github.com/kubernetes/kubernetes/issues/55807 ) 中被追踪。
137
+ Kubernetes 只有在一个 Pod 或该 Pod 中的容器** 结束(Terminated)** 的时候才会发送 preStop 事件,
138
+ 这意味着在 Pod ** 完成(Completed)** 时
139
+ preStop 的事件处理逻辑不会被触发。有关这个限制,
140
+ 请参阅[ 容器回调] ( /zh-cn/docs/concepts/containers/container-lifecycle-hooks/#container-hooks ) 了解详情。
141
141
{{< /note >}}
142
142
143
143
## {{% heading "whatsnext" %}}
@@ -147,7 +147,7 @@ preStop 的事件处理逻辑不会被触发。这个限制在
147
147
* Learn more about the [lifecycle of a Pod](/docs/concepts/workloads/pods/pod-lifecycle/).
148
148
-->
149
149
* 进一步了解[ 容器生命周期回调] ( /zh-cn/docs/concepts/containers/container-lifecycle-hooks/ ) 。
150
- * 进一步了解[ Pod 的生命周期] ( /zh-cn/docs/concepts/workloads/pods/pod-lifecycle/ ) 。
150
+ * 进一步了解 [ Pod 的生命周期] ( /zh-cn/docs/concepts/workloads/pods/pod-lifecycle/ ) 。
151
151
152
152
<!--
153
153
### Reference
@@ -160,5 +160,5 @@ preStop 的事件处理逻辑不会被触发。这个限制在
160
160
161
161
* [ Lifecycle] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#lifecycle-v1-core)
162
162
* [ Container] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#container-v1-core)
163
- * 参阅 [ PodSpec] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podspec-v1-core) 中关于` terminationGracePeriodSeconds ` 的部分
163
+ * 参阅 [ PodSpec] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podspec-v1-core) 中关于 ` terminationGracePeriodSeconds ` 的部分
164
164
0 commit comments