I'm trying to understand how traffic can be routed to a pod that has begun shutdown process.
In Spring Boot docs it is mentioned that
Once the pre-stop hook has completed, SIGTERM will be sent to the container and graceful shutdown will begin, allowing any remaining in-flight requests to complete.
Kubernetes Container Lifecycle
But in Kubernetes docs we have
The Pod's termination grace period countdown begins before the PreStop hook is executed, so regardless of the outcome of the handler, the container will eventually terminate within the Pod's termination grace period. No parameters are passed to the handler.
In Kubernetes docs it say The Pod's termination grace period countdown begins before the PreStop hook is executed
which means SIGTERM was send before the hook is called. Isn't this in contradiction to Spring Boot which says Once the pre-stop hook has completed, SIGTERM will be sent to the container
?
CodePudding user response:
It happens in the following order:
- Count down for termination grace period starts
- Pre stop hook starts executing
- Pre stop hooks finished
- SIGTERM is issued to the container, Spring Boot starts shutting down (possible waiting if graceful shutdown is configured)
If at any point in time the grace period is exceeded SIGKILL is issued and all processes are terminated.