<p>I'm trying to understand how traffic can be routed to a pod that has begun shutdown process.</p>
<p>In Spring Boot docs it is mentioned that</p>
<blockquote>
<p>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.</p>
</blockquote>
<p><a href="https://docs.spring.io/spring-boot/docs/2.3.0.RELEASE/reference/html/deployment.html#cloud-deployment-kubernetes-container-lifecycle" rel="nofollow noreferrer">Kubernetes Container Lifecycle</a></p>
<p>But in Kubernetes docs we have</p>
<blockquote>
<p>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.</p>
</blockquote>
<p><a href="https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks" rel="nofollow noreferrer">Container hooks</a></p>
<p>In Kubernetes docs it say <code>The Pod's termination grace period countdown begins before the PreStop hook is executed</code> which means SIGTERM was send before the hook is called. Isn't this in contradiction to Spring Boot which says <code>Once the pre-stop hook has completed, SIGTERM will be sent to the container</code>?</p>

<p>It happens in the following order:</p>
<ol>
<li>Count down for termination grace period starts</li>
<li>Pre stop hook starts executing</li>
<li>Pre stop hooks finished</li>
<li>SIGTERM is issued to the container, Spring Boot starts shutting down (possible waiting if graceful shutdown is configured)</li>
</ol>
<p>If at any point in time the grace period is exceeded SIGKILL is issued and all processes are terminated.</p>
