<h1>Context</h1>
<p>Say we have <code>d.yaml</code> in which a deployment, whose strategy is <code>RollingUpdate</code>, is defined.</p>
<p>We first create a deployment:</p>
<pre class="lang-sh prettyprint-override"><code>kubectl apply -f d.yaml
</code></pre>
<p>After some time, we modify <code>d.yaml</code> and re-apply it to update the deployment.</p>
<pre class="lang-sh prettyprint-override"><code>vi d.yaml
kubectl apply -f d.yaml
</code></pre>
<p>This starts rolling out a new replicaset <code>R_new</code>.</p>
<p>Normally, the old (previous) replicaset <code>R_old</code> is <em>killed</em> only after <code>R_new</code> has successfully been rolled out.</p>
<h1>Question (tl;dr)</h1>
<p>Is it possible to kill <code>R_old</code> without waiting for rolling out <code>R_new</code> to complete?</p>
<p>By &quot;kill&quot;, I mean completely stopping a replicaset; it should never restart. (So <code>kubectl delete replicaset</code> didn't help.)</p>
<h1>Question (long)</h1>
<p>In my specific situation, my containers connect to an external database. This single database is also connected from many containers managed by other teams.</p>
<p>If <a href="https://stackoverflow.com/questions/30778015/how-to-increase-the-max-connections-in-postgres">the maximum number of connections allowed</a> is already reached, new containers associated with <code>R_new</code> fail to start (i.e. <code>CrashLoopBackOff</code>).</p>
<p>If I could forcefully kill <code>R_old</code>, the number of connections would be lowered by <code>N</code> where <code>N</code> is the number of replicas, and thus <code>R_new</code>'s containers would successfully start.</p>
<p><strong>FAQ:</strong></p>
<p>Q. Why not temporarily stop using <code>RollingUpdate</code> strategy?</p>
<p>A. Actually I have no permission to edit <code>d.yaml</code>. It is edited by CI/CD.</p>
<p>Q. Why not just make the maximum number of connections larger?</p>
<p>A. I have no permission for the database either...</p>

ynn
<blockquote>
<blockquote>
<p>Is it possible to kill R_old without waiting for rolling out R_new to complete?By &quot;kill&quot;, I mean completely stopping a replicaset; it should never restart. (So kubectl delete replicaset didn't help.)</p>
</blockquote>
</blockquote>
<ol>
<li>Make Changes to deployment</li>
<li>Scale down deployment to <code>replicas=0</code> so that it is as good as stopping the old replicaset</li>
<li>scale up deployment to desired number of <code>replicas</code>, new <code>replicasets</code> will be created with new configuration changes in deployment.</li>
</ol>
<p><em>steps number 1 &amp; 2 can be interchanged based on the requirement</em></p>
