<p>I have set of pods belonging to different deployments. All are configured to run as single replicas. Further, i have 2 nodes in my cluster. Now, when i try to schedule my pods, all pods get deployed to same node. its very rare that i see my pods are going to another node.</p>
<p>Due to this, my one node is always under memory pressure with utilization near 90% and other node with utilization near 30%. Due to this, if my pods try to consume more than 80% of their limits, they are killed by k8s by saying node does not have enough resources.</p>
<p>How can i spread my pods equally across the nodes? or what could be possibly wrong with my cluster? I have read through topology spread constraints but they only talk about spreading pods belonging to one deployment.</p>

<p>You are right <strong>topology spread constraints</strong> is good for one deployment. There could be many reasons behind that behavior of Kubernetes.</p>
<p>One could be like you have set the <strong>Resource</strong> <strong>request</strong> &amp; <strong>limit</strong> which K8s think is fine to Run both on <strong>Single Node</strong> so it's scheduling both pods on the <strong>same</strong> Node. Or you have not at all set anything which could be another reason too.</p>
<p>Try increasing the <strong>request &amp; limit</strong> of <strong>Deployment</strong> you will the scheduling diff.</p>
<p>Meanwhile, you can also use <strong>Affinity</strong> <strong>(Node/POD affinity)</strong> or <strong>Taints</strong> &amp; <strong>Toleration</strong> is also a good option to separate out the PODs on different available <strong>nodes</strong>. Affinity will work across deployment also.</p>
<p>Ref : <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/</a></p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: with-node-affinity
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: topology.kubernetes.io/zone
            operator: In
            values:
            - zone-east1
  containers:
  - name: with-node-affinity
    image: registry.k8s.io/pause:2.0
</code></pre>
