<p>I'm having a pipeline that has the following structure:</p>
<pre class="lang-sh prettyprint-override"><code>Step 1: kubernetes-deployment
Step 2: kubectl rollout restart deploy -n NAMESPACE
Step 3: http-calls to deployment A and B
</code></pre>
<p>In the same Namespace, there's a database pod and Pod <strong>A</strong> and <strong>B</strong> are connected to this database.</p>
<h1>The problem</h1>
<p>The problem now is caused by rolling updates - when applying a rolling update, kubernetes starts new pods as the deployment got updated. The old pod is not terminated until the corresponding new pod starts, though.</p>
<p>As <code>kubectl rollout restart deploy</code> is a non-blocking call, it will not wait for the update to finish. And afaik, there is no builtin way of kubectl to force such behavior.</p>
<p>As I'm executing some HTTP Requests after this was called, i now got the problem that <strong>sometimes</strong>, when the update is not fast enough, the HTTP Calls are received and answered by the old pods from deployment <strong>A</strong> and <strong>B</strong>. Shortly after this, the old pods will be terminated, as the new ones are up and running.</p>
<p>This leads to the problem that the effects of those HTTP requests are no longer visible, as they were received by the old pods, saving the corresponding data in a database located in the &quot;old&quot; database pod. As database pod is restarted, the data will be lost.</p>
<p>Note that I am not using a <code>persistent Volume</code> in this case, as this comes from a nightly build scenario and i want to restart those deployments every day and the database state should always contain only the data from the current day's build.</p>
<br>
<br>
<p>Do you see any way of solving this?
Including a simple <code>wait</code> step would probably work, but I am curious if there is a fancier solution.</p>
<p>Thanks in Advance!</p>

Manu
<p><code>kubectl rollout status deployment &lt;deploymentname&gt;</code> together with <code>startupProbe</code> and <code>livenessProbe</code> solved my problem.</p>
