<p>Currently it takes quite a long time before the pod can be terminated after a kubectl delete command. I have the feeling that it could be because of the sleep command.</p>
<p>How can I make the container stop faster?
What best practices should I use here?</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
...
spec:
  template:
    spec:
      containers:
        - image: alpine
          ..
          command:
            - /bin/sh
            - -c
            - |
              trap : TERM INT 
              while true; do
                # some code to check something
                sleep 10
              done
</code></pre>
<p>Is my approach with &quot;trap: TERM INT&quot; correct? At the moment I don't see any positive effect...</p>
<p>When I terminate the pod it takes several seconds for the command to come back.</p>
<pre><code>kubectl delete pod my-pod
</code></pre>

<p>Add <code>terminationGracePeriodSeconds</code> to your spec will do:</p>
<pre><code>...
spec:
  template:
    spec:
      terminationGracePeriodSeconds: 10  # &lt;-- default is 30, can go as low as 0 to send SIGTERM immediately.
      containers:
        - image: alpine
</code></pre>
