Skip to content

Commit 9080ee0

Browse files
committed
[zh] sync attach-handler-lifecycle-event.md
1 parent a5c101f commit 9080ee0

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

content/zh-cn/docs/tasks/configure-pod-container/attach-handler-lifecycle-event.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Kubernetes 将发送一个 preStop 事件。容器可以为每个事件指定一
3333
In this exercise, you create a Pod that has one Container. The Container has handlers
3434
for the postStart and preStop events.
3535
-->
36-
## 定义 postStart 和 preStop 处理函数
36+
## 定义 postStart 和 preStop 处理函数 {#define-poststart-and-prestop-handlers}
3737

3838
在本练习中,你将创建一个包含一个容器的 Pod,该容器为 postStart 和 preStop 事件提供对应的处理函数。
3939

@@ -75,7 +75,7 @@ Get a shell into the Container running in your Pod:
7575
-->
7676
使用 shell 连接到你的 Pod 里的容器:
7777

78-
```
78+
```shell
7979
kubectl exec -it lifecycle-demo -- /bin/bash
8080
```
8181

@@ -91,7 +91,7 @@ root@lifecycle-demo:/# cat /usr/share/message
9191
<!--
9292
The output shows the text written by the postStart handler:
9393
-->
94-
命令行输出的是 `postStart` 处理函数所写入的文本
94+
命令行输出的是 `postStart` 处理函数所写入的文本
9595

9696
```
9797
Hello from the postStart handler
@@ -109,7 +109,7 @@ relative to the Container's code, but Kubernetes' management of the container
109109
blocks until the postStart handler completes. The Container's status is not
110110
set to RUNNING until the postStart handler completes.
111111
-->
112-
## 讨论
112+
## 讨论 {#discussion}
113113

114114
Kubernetes 在容器创建后立即发送 postStart 事件。
115115
然而,postStart 处理函数的调用不保证早于容器的入口点(entrypoint)
@@ -122,22 +122,22 @@ RUNNING。
122122
Kubernetes sends the preStop event immediately before the Container is terminated.
123123
Kubernetes' management of the Container blocks until the preStop handler completes,
124124
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/).
126126
-->
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/)
130130

131+
{{< note >}}
131132
<!--
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*.
133134
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.
135136
-->
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)了解详情。
141141
{{< /note >}}
142142

143143
## {{% heading "whatsnext" %}}
@@ -147,7 +147,7 @@ preStop 的事件处理逻辑不会被触发。这个限制在
147147
* Learn more about the [lifecycle of a Pod](/docs/concepts/workloads/pods/pod-lifecycle/).
148148
-->
149149
* 进一步了解[容器生命周期回调](/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/)
151151

152152
<!--
153153
### Reference
@@ -160,5 +160,5 @@ preStop 的事件处理逻辑不会被触发。这个限制在
160160

161161
* [Lifecycle](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#lifecycle-v1-core)
162162
* [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` 的部分
164164

0 commit comments

Comments
 (0)