<p>How to upgrade an existing running deployment with yaml deployment file without changing the number of running replicas of that deployment?
So, I need to set the number of replicas on the fly without changing the yaml file.</p>
<p>It is like running kubectl apply -f deployment.yaml along with kubectl scale --replicas=3 both together, or in another wards to apply deployment yaml changes with keeping the numebr of running replicas the same as it is.</p>
<p>For example: I have a running deployment which already scaled its pods to 5 replicas, need to change deployment parameters within CD (like upgrade container image, change environment variabls, .. etc) without manualy check the #running pods and update the yaml with it, how can achieve this?</p>

<p>Use the kubectl edit command</p>
<pre><code>kubectl edit (RESOURCE/NAME | -f FILENAME)
E.g. kubectl edit deployment.apps/webapp-deployment
</code></pre>
<p>It will open an editor. You can update the value for number of replicas in the editor and save.</p>
<p>Refer the documentation section - Editing resources
<a href="https://kubernetes.io/docs/reference/kubectl/cheatsheet/#editing-resources" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/kubectl/cheatsheet/#editing-resources</a></p>
