<p>I have to changed the <code>terminationGracePeriodSeconds</code> from 30 to 120 in Kubernetes deployment manifest file but when I am deploying using helm:</p>
<pre><code>helm upgrade --install &lt;chartname&gt; --values &lt;valuesfilename&gt;
</code></pre>
<p>The old pods getting terminated immediately and new pods started running.</p>
<p>But the expected behavior is to keep the old pods in terminating state and continue its current processes for 120 seconds as defined.</p>
<p>What else could be missing here?</p>
<p>Does this solve my issue here?</p>
<pre><code>containers:
  - name: containername
    lifecycle:
      preStop:
        exec:
          command: [ &quot;/bin/sleep&quot;, &quot;20&quot; ]
</code></pre>
<p>One question I had is does adding sleep command stops execution of current processes of the pod and just sleeps while it is in terminating state?</p>

<p>Basically, it is expected behavior for <code>terminationGracePeriodSeconds</code>, as it is <em>optional</em> duration in seconds the pod needs to terminate gracefully.</p>
<p>On pod termination - the lifecycle is described <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination" rel="nofollow noreferrer">here</a> -  pod receives <code>terminating</code> state and it is removed from the endpoints list of all services and stops getting new traffic. <code>SIGTERM</code> signal is immediately sent to the processes running in pod, and Kubernetes is waiting for the pod to stop normally on its own
during the grace period specified in <code>terminationGracePeriodSeconds</code> option. As soon as <code>terminationGracePeriodSeconds</code> expires, the Pod is forcefully killed by <code>SIGKILL</code> signal. In your case, the processes in the pod were just shutdown normally before 120 seconds of grace period have passed.</p>
<p>In its turn, <code>preStop</code>  hook is called immediately before a pod is terminated, which means that the hook will be executed prior to <code>kubectl</code> sends <code>SIGTERM</code> to the pod. As stated in <a href="https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks" rel="nofollow noreferrer">documentation</a>, the hook <strong>must</strong> complete before the <code>TERM</code> signal to stop the container is sent. <code>terminationGracePeriodSeconds</code> is happening in parallel with the preStop hook and the <code>SIGTERM</code> signal and its countdown begins before the <code>preStop</code> hook is executed. The pod will eventually terminate within the pod's termination grace period, regardless of the hook completion.</p>
<p>Therefore, on receiving <code>sleep</code> command for <code>preStop</code>  hook, pod already marked as <code>Terminating</code> but the processes inside of it are not yet terminated - so the container can complete all the active requests during this period.</p>
