<p>while i was reading <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#pausing-and-resuming-a-deployment" rel="nofollow noreferrer">Pausing and Resuming a Deployment</a> from kubernetes official docs, here i found that i can apply multiple fixes in between pausing and resuming without triggering unnecessary rollouts.<br />
Now, when i only changed the image of the deployment then it works fine, but when i changed the number of replicas in the deployment manifest and applied that then the pod created/deleted immediately according to the replicas number even the deployment was in paused state.</p>
<p>Now, my question is, why it is happening? doesn't it allowed to change the replicas during paused deployment? or only image changing is allowed? the doc did not specify it.</p>
<p>Another thing is if i change number of replicas and also the image then only the replicas get applied during paused deployments and created pods with the previous image not the current one.</p>
<p>the manifest file of the deployment that is used is:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.16.1
        ports:
        - containerPort: 80
</code></pre>
<h1>Updated Question (Gave full details)</h1>

<p><strong>What happened</strong>:
While I was reading <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#pausing-and-resuming-a-deployment" rel="nofollow noreferrer">Pausing and Resuming a Deployment</a> portion of kubernetes official docs. I paused a deployment and during deployment I changed the number of replicas in the deployment manifest file. After that when I applied that changes using <code>kubectl apply -f deployment.yaml</code> then according to the new number of replicas the pods immediately created/deleted even during the paused deployment state, those pods came with the previous image.</p>
<p>First I created the deployment with this manifest using the command <code>kubectl apply -f deployment.yaml</code></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.1
        ports:
        - containerPort: 80
</code></pre>
<p>after that I opened two terminal for monitoring the pods and replicaset by using the commands:</p>
<pre><code>kubectl get pods -w
kubectl get rs -w
</code></pre>
<p>after that I paused the deployment using <code>kubectl rollout pause deployment/nginx-deployment</code> command.</p>
<p>then I change the manifest and it like below:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 5 # &lt;------ here changed the number of replicas
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.16.1 # &lt;---- here changed the image
        ports:
        - containerPort: 80
</code></pre>
<p>after applying this manifest using <code>kubectl apply -f deployment.yaml</code> the things that I saw is: two new pods get created with the previous image <code>image: nginx:1.14.1</code></p>
<p><strong>What I expected to happen</strong>:
According to the pausing concepts, any changes into the PodTemplateSpec of the paused Deployment will not trigger new rollouts as long as it is paused. Now why did the changing replicas implemented during the paused deployment.</p>
<p><strong>Anything else?</strong>:
Also if I use horizontalautoscaler the same thing happens.</p>
<p><strong>Environment</strong>:</p>
<ul>
<li>Kubernetes version (use <code>kubectl version</code>):</li>
</ul>
<pre><code>Client Version: v1.20.1
Server Version: v1.19.1
</code></pre>

<p>I don't think this is an issue. I belive this is expected behaviuor and
I will try to explain why I think so.</p>
<p>Pause functionality is part of <code>kubectl rollout</code> command.</p>
<pre><code>kubectl rollout pause ...
</code></pre>
<p>and it is used to pause a specific deployment from rolling update.</p>
<p>But what does rolling update actuall is? Let's try to define it.
In <a href="https://kubernetes.io/docs/tutorials/kubernetes-basics/update/update-intro/" rel="nofollow noreferrer">k8s docs</a> we can read:</p>
<blockquote>
<p>Rolling updates allow Deployments' update to take place with zero
downtime by incrementally updating Pods instances with new ones</p>
</blockquote>
<p>So we can see that rolling update is being used to apply changes with zero downtime.
This includes changes to image version, container limits etc. Basically anything related to how application runs and behaves.</p>
<p>Now, does changing number of replicas impact the running application? Does it change the way it behaves? No! It only adds/deletes replicas of the same application. Users still can use the same version that was available before pausing the deployment. No changes are applied.</p>
<p>After you resume the deployment, all the changes submited after the pause will be applied.</p>
<p>So to summarize, I belive this is expected behaviour, since the change of number of replicas does not change the actual application and in the meanwhile the actuall update is indeed paused.</p>
<p>If you are still not convinced, I'd recommend you to open an issue on <a href="https://github.com/kubernetes/kubernetes/issues" rel="nofollow noreferrer">k8s github repo</a> and ask developers directly.</p>
