From fb9b317e6eb8e8392df7211e09dcc5f1d33b7ce1 Mon Sep 17 00:00:00 2001 From: Sreeram Date: Sat, 22 Feb 2025 00:28:36 +0530 Subject: [PATCH 1/2] Docs PR for KEP 4818: Pod Lifecycle Sleep action allow zero value --- .../en/docs/concepts/containers/container-lifecycle-hooks.md | 2 +- .../feature-gates/PodLifecycleSleepActionAllowZero.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/content/en/docs/concepts/containers/container-lifecycle-hooks.md b/content/en/docs/concepts/containers/container-lifecycle-hooks.md index 1f3dd65bd0300..d03e53c6c6193 100644 --- a/content/en/docs/concepts/containers/container-lifecycle-hooks.md +++ b/content/en/docs/concepts/containers/container-lifecycle-hooks.md @@ -59,7 +59,7 @@ Resources consumed by the command are counted against the Container. 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 allows you to set a sleep duration of zero seconds (effectively a no-op) for your Sleep lifecycle hooks. {{< /note >}} ### Hook handler execution diff --git a/content/en/docs/reference/command-line-tools-reference/feature-gates/PodLifecycleSleepActionAllowZero.md b/content/en/docs/reference/command-line-tools-reference/feature-gates/PodLifecycleSleepActionAllowZero.md index 831f9555c1fc3..9f9e95e32cecb 100644 --- a/content/en/docs/reference/command-line-tools-reference/feature-gates/PodLifecycleSleepActionAllowZero.md +++ b/content/en/docs/reference/command-line-tools-reference/feature-gates/PodLifecycleSleepActionAllowZero.md @@ -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/). From e414aeb818de10d1be9292a6983e49fc571361dd Mon Sep 17 00:00:00 2001 From: Qiming Teng Date: Sat, 5 Apr 2025 14:55:33 +0800 Subject: [PATCH 2/2] Update container-lifecycle-hooks.md --- .../containers/container-lifecycle-hooks.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/content/en/docs/concepts/containers/container-lifecycle-hooks.md b/content/en/docs/concepts/containers/container-lifecycle-hooks.md index d03e53c6c6193..a5274f5476507 100644 --- a/content/en/docs/concepts/containers/container-lifecycle-hooks.md +++ b/content/en/docs/concepts/containers/container-lifecycle-hooks.md @@ -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 >}} -The beta level `PodLifecycleSleepActionAllowZero` feature gate which is enabled by default from v1.33 allows you 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`: ```