KEP 4818: PodLifecycleSleepActionAllowZero beta graduation (#49858)

* Docs PR for KEP 4818: Pod Lifecycle Sleep action allow zero value

* Update container-lifecycle-hooks.md

---------

Co-authored-by: Qiming Teng <tengqm@outlook.com>
pull/50420/head
Sreeram Venkitesh 2025-04-05 14:00:37 +05:30 committed by GitHub
parent afd8051fb3
commit cf40ef0bf8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View File

@ -56,17 +56,20 @@ There are three types of hook handlers that can be implemented for Containers:
Resources consumed by the command are counted against the Container.
* HTTP - Executes an HTTP request against a specific endpoint on the Container.
* Sleep - Pauses the container for a specified duration.
This is a beta-level feature default enabled by the `PodLifecycleSleepAction` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/).
This is a beta-level feature default enabled by the `PodLifecycleSleepAction`
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/).
{{< note >}}
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.
The beta level `PodLifecycleSleepActionAllowZero` feature gate which is enabled by default from v1.33.
It allows you to set a sleep duration of zero seconds (effectively a no-op) for your Sleep lifecycle hooks.
{{< /note >}}
### Hook handler execution
When a Container lifecycle management hook is called,
the Kubernetes management system executes the handler according to the hook action,
`httpGet`, `tcpSocket` ([deprecated](/docs/reference/generated/kubernetes-api/v1.31/#lifecyclehandler-v1-core)) and `sleep` are executed by the kubelet process, and `exec` is executed in the container.
`httpGet`, `tcpSocket` ([deprecated](/docs/reference/generated/kubernetes-api/v1.31/#lifecyclehandler-v1-core))
and `sleep` are executed by the kubelet process, and `exec` is executed in the container.
The `PostStart` hook handler call is initiated when a container is created,
meaning the container ENTRYPOINT and the `PostStart` hook are triggered simultaneously.
@ -110,7 +113,9 @@ The logs for a Hook handler are not exposed in Pod events.
If a handler fails for some reason, it broadcasts an event.
For `PostStart`, this is the `FailedPostStartHook` event,
and for `PreStop`, this is the `FailedPreStopHook` event.
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.
To generate a failed `FailedPostStartHook` event yourself, modify the
[lifecycle-events.yaml](https://k8s.io/examples/pods/lifecycle-events.yaml)
file to change the postStart command to "badcommand" and apply it.
Here is some example output of the resulting events you see from running `kubectl describe pod lifecycle-demo`:
```

View File

@ -9,5 +9,9 @@ stages:
- stage: alpha
defaultValue: false
fromVersion: "1.32"
toVersion: "1.32"
- stage: beta
defaultValue: true
fromVersion: "1.33"
---
Enables setting zero value for the `sleep` action in [container lifecycle hooks](/docs/concepts/containers/container-lifecycle-hooks/).