<p>I have an EKS node group with 2 nodes for compute workloads. I use a taint on these nodes and tolerations in the deployment. I have a deployment with 2 replicas I want these two pods to be spread on these two nodes like one pod on each node.</p>
<p>I tried using:</p>
<pre><code>affinity:
    podAntiAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
      - weight: 1
        podAffinityTerm:
          labelSelector:
            matchExpressions:
            - key: app
              operator: In
              values:
              - appname
</code></pre>
<p>Each pod is put on each node but if I updated the deployment file like changing its image name, it fails to schedule a new pod.</p>
<p>I also tried:</p>
<pre><code>      topologySpreadConstraints:
        - maxSkew: 1
          topologyKey: type
          whenUnsatisfiable: DoNotSchedule
          labelSelector:
            matchLabels:
              type: compute
</code></pre>
<p>but they aren't spread evenly like 2 pods on a node.</p>

Icarus
<p>Try adding:</p>
<pre><code>spec:
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1
</code></pre>
<p>By default K8s is trying to scale the new replicaset up first before it starts downscaling the old replicas. Since it cannot schedule new replicas (because antiaffinity) they are stuck in pending state.</p>
<p>Once you set the deployment's maxSurge=0, you tell k8s that you don't want the deployment to scale up first during update, and thus in result it can only scale down making place for new replicas to be scheduled.</p>
<p>Setting maxUnavailable=1 tells k8s to replace only one pod at a time.</p>
