<p>I have a use case to gracefully terminate the container where i have a script to kill the process gracefully from within the container by using the command "kill PID".( Which will send the TERM signal )
But I have liveness probe configured as well.
Currently liveness probe is configured to probe at 60 second interval. So if the liveness probe take place shortly after the graceful termination signal is sent, the overall health of the container might become CRITICAL when the termination is still in progress.
In this case the liveness probe will fail and container will be terminated immediately.</p>

<p>So i wanted to know whether kubelet kills the container with TERM or KILL.</p>

<p>Appreciate your support 
Thanks in advance</p>

<p>In Kubernetes, Liveness Probe checks for the health state of a container.</p>

<p>To answer your question on whether it uses SIGKILL or SIGTERM, the answer is both are used but in order. So here is what happens under the hood.</p>

<ol>
<li>Liveness probe check fails</li>
<li>Kubernetes stops routing of traffic to the container</li>
<li>Kubernetes restarts the container</li>
<li>Kubernetes starts routing traffic to the container again</li>
</ol>

<p>For container restart, SIGTERM is first sent with  waits for a parameterized grace period, and then Kubernetes sends SIGKILL.</p>

<p>A hack around your issue is to use the attribute:</p>

<pre><code>timeoutSeconds
</code></pre>

<p>This specifies how long a request can take to respond before it’s considered a failure. You can add and adjust this parameter if the time taken for your application to come online is predictable.</p>

<p>Also, you can play with <code>readinessProbe</code>  before <code>livenessProbe</code> with an adequate delay for the container to come into service after restarting the process. Check <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/" rel="noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/</a> for more details on which parameters to use.</p>
