<p>I deployed a K8s <strong>StatefulSet</strong> with 30 replicas (or N replicas, where N is multiple of 3) in EKS Cluster.</p>
<p>EKS cluster is with 3 nodes, one node for one AZ, and I want to <em>guarantee</em> with Kubernetes Affinity/AntiAffinity the <strong>equal</strong> distribution of pods across different AZ.</p>
<pre><code>us-west-2a (n nodes) -&gt; N/3 pods
us-west-2b (m nodes) -&gt; N/3 pods
us-west-2c (o nodes) -&gt; N/3 pods
</code></pre>
<p>Thanks</p>

falberto
<p>You can always use selectors and default labels which you get from AWS. A simple pod spec example is here</p>
<pre><code>topologySpreadConstraints:
  - maxSkew: 1
    topologyKey: &quot;topology.kubernetes.io/zone&quot;
    whenUnsatisfiable: DoNotSchedule
    labelSelector:
      matchLabels:
        app: myapp
</code></pre>
<p>You can include skew and other options based on the need as described here: <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/</a></p>
