<p>I am new to k8s. I would like to test the deletionGracePeriodSeconds feature.
Documentation says :</p>
<blockquote>
<p>deletionGracePeriodSeconds (integer) : Number of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set.</p>
</blockquote>
<p>I guess that if the pod terminates nicely, the feature does not apply.</p>
<p>So, How can I make the pod &quot;reject&quot; deletion in order to see how this feature works? Does it work for deletion by command :</p>
<pre><code>kubectl delete pod mypod 
</code></pre>
<p>or only with scheduled deletion with &quot;deletionTimestamp&quot;</p>
<p>Here is how I tried to do it (via the trap command) but it does not seem to work :</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  deletionGracePeriodSeconds: 10
  deletionTimestamp: 2020-08-05T14:40:00Z
  name: mypod
spec:
  containers:
  - name: mycontainer
    image: nginx
    command: [&quot;/bin/sh&quot;, &quot;-c&quot;]
    args:
    - trap &quot;&quot; 2 3 15 20 | sleep 600
</code></pre>
<p>Thanks in advance
Abdelghani</p>

<p>I assume you are asking about <code>terminationGracePeriodSeconds</code>, please correct me if I'm mistaken and I'll edit accrodingly.</p>
<p>The <code>terminationGracePeriodSeconds</code> is the time between Kubernetes sends the <code>SIGTERM</code> signal to the pod main process (<code>PID 1</code>) until it sends the <code>SIGKILL</code> signal, which abruptly kills the process (and subsequently, the pod itself).</p>
<p><code>SIGTERM</code> signal is meant to be interpreted by the process, and it should start a &quot;Graceful Shutdown&quot; - stop receiving new tasks and finish the work on existing ones. If the process in your pod needs more than 30 seconds for this procedure (let's say you're running a worker which process each task in 2 minutes), you'd want to extend the <code>terminationGracePeriodSeconds</code> accordingly.</p>
<p>So you can't make the pod &quot;reject&quot; the deletion, but your process can either ignore the <code>SIGTERM</code> signal, and then after the period configured in <code>terminationGracePeriodSeconds</code> it'll be killed abruptly, or it may be that your process needs more time to gracefully shutdown (and in that case, you'd want to increase `</p>
