<p>This is more of cost estimation question than how to use features like node affinity.</p>
<p>So basically there are <code>m</code> pods with some constraints like:</p>
<ul>
<li>each pod of specific <code>Deployments</code> / <code>StatefulSets</code> should be on a different kubernetes node</li>
<li>pods of specific <code>Deployments</code> / <code>StatefulSets</code> should be balanced over 3 availability zones</li>
</ul>
<p>Now, I want to find how many nodes (all same types) I will need to host given set of <code>Deployments</code> / <code>StatefulSets</code>.</p>
<p>I first thought this of more like an assignment problem to be solved using Hungarian Algorithim but this seems much more complex in term like multi dimensional constraints.</p>

codersofthedark
<p>Kubernetes assigns the pods based on the many constraints like</p>
<ul>
<li>Resource requirement</li>
<li>Resource existence (Node capacity)</li>
<li>Node selectors if any or Affinity rules</li>
<li>Weight of Affinity rules</li>
</ul>
<p>This is good article for same : <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/</a></p>
<p>Also : <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>
<p>i would suggest to read the : <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/scheduling-eviction/</a></p>
