<p>We have a pod in kubernetes and it is processing some jobs in there regularly. Some of these jobs take more than 2 or 3 minutes. When deploying this pod, we don't want to kill current processes on this pod. How to keep wait this pod's termination until all processes completed? I read some topics about 'terminationGracePeriodSeconds'. But is there any upper seconds limit about that property or how it works?</p>

tembelmuhendis
<p>You can use <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#wait" rel="nofollow noreferrer">wait command</a>, which takes multiple resources and waits until the specified condition.</p>

<p>For example, assume you create a job called worker that print the word 'printsth' and pause for 3 seconds ten times.</p>

<pre><code>$ kubectl create ns waitplayground
$ kubectl -n waitplayground \
             create job worker \ 
             --image centos:7 -- \
             sh -c \
             'for i in {1..10} ; do echo printsth ; sleep 3; done'
</code></pre>

<p>Kubectl wait command returns something similar to that:</p>

<pre><code>$ kubectl -n waitplayground \
             wait --for=condition=complete --timeout=40s \     
             job/worker
job.batch/worker condition met
</code></pre>

<p>I hope it will helps you.</p>
