<p>I have having 2 pool in my GKE cluster default-pool (2 nodes), temp-pool (3 nodes). I am having pod replicas as 4 now my requirment is atleast <strong><strong>minimum one
pod it has to schedule on default-pool its mandatory</strong> (not all the pod should schedule on default pool)</strong> and other pods can schedule on temp pool</p>
<p>I tried using nodeaffinity, topologySpreadConstraints specification but sometimes pod is not scheduling on default-pool</p>
<p>Is there a way to achieve this in kubernetes</p>

iamarunk
<p>Node affinity allows you to constrain which nodes your pod is eligible to be scheduled on, based on labels on the node.</p>
<p>As you need that they won't end up on the same node, you can use <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity" rel="nofollow noreferrer">AntiAffinity</a> along with the weighted  node pool preferences using <code>preferredDuringSchedulingIgnoredDuringExecution</code>.</p>
<p>or try this spec on <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/" rel="nofollow noreferrer">topologySpreadConstraints</a></p>
<pre><code>spec:
  topologySpreadConstraints:
  - maxSkew: 1
    topologyKey: zone
    whenUnsatisfiable: DoNotSchedule
    labelSelector:
      matchLabels:
        node: temp-pool
</code></pre>
