Skip to content

Commit d9d139c

Browse files
committed
[zh-cn] sync container-lifecycle-hooks.md
1 parent 0825aae commit d9d139c

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

content/zh-cn/docs/concepts/containers/container-lifecycle-hooks.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,23 @@ A more detailed description of the termination behavior can be found in
8282
有关终止行为的更详细描述,
8383
请参见[终止 Pod](/zh-cn/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination)
8484

85+
<!--
86+
`StopSignal`
87+
88+
The StopSignal lifecycle can be used to define a stop signal which would be sent to the container when it is
89+
stopped. If you set this, it overrides any `STOPSIGNAL` instruction defined within the container image.
90+
91+
A more detailed description of termination behaviour with custom stop signals can be found in
92+
[Stop Signals](/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination-stop-signals).
93+
-->
94+
`StopSignal`
95+
96+
StopSignal 生命周期可用于定义停止信号,该信号将在容器停止时发送给容器。
97+
如果设置了该字段,将会覆盖容器镜像中定义的 `STOPSIGNAL` 指令。
98+
99+
关于自定义停止信号的终止行为的更为详细的描述,请参阅
100+
[停止信号](/zh-cn/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination-stop-signals)
101+
85102
<!--
86103
### Hook handler implementations
87104
@@ -98,7 +115,8 @@ There are three types of hook handlers that can be implemented for Containers:
98115
Resources consumed by the command are counted against the Container.
99116
* HTTP - Executes an HTTP request against a specific endpoint on the Container.
100117
* Sleep - Pauses the container for a specified duration.
101-
This is a beta-level feature default enabled by the `PodLifecycleSleepAction` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/).
118+
This is a beta-level feature default enabled by the `PodLifecycleSleepAction`
119+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/).
102120
-->
103121

104122
* Exec - 在容器的 cgroups 和名字空间中执行特定的命令(例如 `pre-stop.sh`)。
@@ -110,18 +128,18 @@ Resources consumed by the command are counted against the Container.
110128

111129
{{< note >}}
112130
<!--
113-
Enable the `PodLifecycleSleepActionAllowZero` feature gate if you want to set a sleep duration of zero seconds (effectively a no-op) for your Sleep lifecycle hooks.
131+
The beta level `PodLifecycleSleepActionAllowZero` feature gate which is enabled by default from v1.33.
132+
It allows you to set a sleep duration of zero seconds (effectively a no-op) for your Sleep lifecycle hooks.
114133
-->
115-
如果你想为 Sleep 生命周期回调设置零秒的睡眠持续时间(实际上是一个 no-op),
116-
可以启用 `PodLifecycleSleepActionAllowZero` 特性门控
134+
从 v1.33 开始,Beta 阶段的特性门控 `PodLifecycleSleepActionAllowZero` 默认启用。
135+
它允许你为 Sleep 生命周期钩子设置零秒的睡眠时间(实际上是一个空操作)
117136
{{< /note >}}
118137

119138
<!--
120139
### Hook handler execution
121140
122141
When a Container lifecycle management hook is called,
123142
the Kubernetes management system executes the handler according to the hook action,
124-
`httpGet`, `tcpSocket` ([deprecated](/docs/reference/generated/kubernetes-api/v1.31/#lifecyclehandler-v1-core))
125143
and `sleep` are executed by the kubelet process, and `exec` is executed in the container.
126144
-->
127145
### 回调处理程序执行 {#hook-handler-execution}
@@ -211,16 +229,19 @@ The logs for a Hook handler are not exposed in Pod events.
211229
If a handler fails for some reason, it broadcasts an event.
212230
For `PostStart`, this is the `FailedPostStartHook` event,
213231
and for `PreStop`, this is the `FailedPreStopHook` event.
214-
To generate a failed `FailedPostStartHook` event yourself, modify the [lifecycle-events.yaml](https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/pods/lifecycle-events.yaml) file to change the postStart command to "badcommand" and apply it.
215-
Here is some example output of the resulting events you see from running `kubectl describe pod lifecycle-demo`:
232+
To generate a failed `FailedPostStartHook` event yourself, modify the
233+
[lifecycle-events.yaml](https://k8s.io/examples/pods/lifecycle-events.yaml)
234+
file to change the postStart command to "badcommand" and apply it.
235+
Here is some example output of the resulting events you see from running `kubectl describe
236+
pod lifecycle-demo`:
216237
-->
217238
### 调试回调处理程序 {#debugging-hook-handlers}
218239

219240
回调处理程序的日志不会在 Pod 事件中公开。
220241
如果处理程序由于某种原因失败,它将播放一个事件。
221242
对于 `PostStart`,这是 `FailedPostStartHook` 事件,对于 `PreStop`,这是 `FailedPreStopHook` 事件。
222243
要自己生成失败的 `FailedPostStartHook` 事件,请修改
223-
[lifecycle-events.yaml](https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/pods/lifecycle-events.yaml)
244+
[lifecycle-events.yaml](https://k8s.io/examples/pods/lifecycle-events.yaml)
224245
文件将 postStart 命令更改为 “badcommand” 并应用它。
225246
以下是通过运行 `kubectl describe pod lifecycle-demo` 后你看到的一些结果事件的示例输出:
226247

0 commit comments

Comments
 (0)