Skip to content

Commit

Permalink
Merge branch '3.4.x'
Browse files Browse the repository at this point in the history
Closes gh-44023
  • Loading branch information
mhalbritter committed Jan 30, 2025
2 parents c09c454 + dcd4b7c commit 7ab89d1
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,22 @@ Because this shutdown processing happens in parallel (and due to the nature of d

You can configure a sleep execution in a preStop handler to avoid requests being routed to a pod that has already begun shutting down.
This sleep should be long enough for new requests to stop being routed to the pod and its duration will vary from deployment to deployment.
The preStop handler can be configured by using the PodSpec in the pod's configuration file as follows:

If you're using Kubernetes 1.32 or up, the preStop handler can be configured by using the PodSpec in the pod's configuration file as follows:

[source,yaml]
----
spec:
containers:
- name: "example-container"
image: "example-image"
lifecycle:
preStop:
sleep:
seconds: 10
----

If you're not on Kubernetes 1.32 yet, you can use an `exec` command to invoke `sleep`.

[source,yaml]
----
Expand All @@ -138,6 +153,8 @@ spec:
command: ["sh", "-c", "sleep 10"]
----

NOTE: The container needs to have a shell for this to work.

Once the pre-stop hook has completed, SIGTERM will be sent to the container and xref:reference:web/graceful-shutdown.adoc[graceful shutdown] will begin, allowing any remaining in-flight requests to complete.

NOTE: When Kubernetes sends a SIGTERM signal to the pod, it waits for a specified time called the termination grace period (the default for which is 30 seconds).
Expand Down

0 comments on commit 7ab89d1

Please sign in to comment.