<p>I have a situation where my process (pid 1) in a pod sometimes is not responding to the SIGTERM signal due to it has entered a really bad state. This means that it will not be killed by k8s after the prestop hook is run until the grace period is over (which has to be long in my case for other reasons).</p>
<p>In the prestop I'm able to detect this state fairly accurate but the problem is then how to initiate a forceful kill of the process. I cannot for instance <code>kill -9 1</code> because that is not allowed on pid 1.</p>
<p>So the question is if there are other options to do that. If I have read documentation correctly, k8s does not care about the exit code from the prestop hook (otherwise that could have been an option to indicate back to k8s that it should force kill the process directly without waiting for the grace period).
Changing the grace period dynamically for this specific pod when this happens does not possible either.
Any ideas?</p>

Magnus Håkansson
<p>You can package your image with <a href="https://github.com/krallin/tini" rel="nofollow noreferrer">tini</a> and let tini spawn your application. <code>tini</code> will not miss SIGTERM and it ensure stale child process is removed during termination. <code>tini</code> is incorporated in <code>docker</code>  with <code>--init</code> flag, too. There is no need of <code>preStop</code> hook to manually terminate process in this case.</p>
