<p>Is it possible to setup a delay for pod shutdowns after a rolling update on Kubernetes?</p>

<p>For example I roll out a new version and want the old Pods to run for further 15secs after the new instance has been started.</p>

<p>How can I manage that?</p>

Alex Tbk
<p>Yes, you can use <code>PreStop</code> Hook to achieve that.</p>

<p><code>PreStop</code> hooks are executed after a Pod is marked as terminating. See what happen when you delete a pod from <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods" rel="nofollow noreferrer">here</a>.</p>

<p>You just have to run <code>sleep 15</code> on <code>PreStop</code> Hook.</p>

<p>For more details see <a href="https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks" rel="nofollow noreferrer">Container hooks</a>.</p>

<p>See how to add a <code>PreStop</code> hook from here: <a href="https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/#define-poststart-and-prestop-handlers" rel="nofollow noreferrer">Define postStart and preStop handlers</a>.</p>
