<p>When I do <code>kubectl delete pod</code> or <code>kubectl patch</code>, how can I ensure that the old pod doesn't actually delete itself until the replacement pod has been running for 2 minutes? (And if the replacement pod dies before the 2 minute mark, then don't even delete the old pod)</p>

<p>The reason is that my initiation takes about 2 minutes to pull some latest data and run calculations; after 2 minutes it'll reach a point where it'll either error out or continue running with the updated calculations.</p>

<p>I want to be able to occasionally delete the pod so that it'll restart and get new versions of stuff (because getting new versions is only done at the beginning of the code).</p>

<p>Is there a way I can do this without an init container? Because I'm concerned that it would be difficult to pass the calculated results from the init container to the main container</p>

<p>We need to tweak <strong>two</strong> parameters.</p>

<ul>
<li>We have set the <code>minReadySeconds</code> as 2 min. Or we can use <code>readiness probe</code> instead of hardcoded 2min.</li>
<li>We have to do <strong>rolling update</strong> with <code>maxSurge &gt; 0 (default: 1) and maxUnavailable: 0</code>. This will bring the new pod(s) and <strong>only if it becomes ready</strong>, old pod(s) will be killed. This process continues for rest of the pods.</li>
</ul>

<blockquote>
  <p>Note: 0 &lt;= maxSurge &lt;= replicaCount</p>
</blockquote>
