<p>I'm new with GKE and I'm testing some scaling features.
I started with a simple example, 1 pod inside 1 pool with 1 node.</p>

<p>When I scaled the pool to have 2 nodes and the pod to replica=2, for my surprise the 2 pods were allocated inside the same node.</p>

<p>Is it a problem for redundancy?
Can I assure that my replicas are spread to all nodes?</p>

<p>The place where Pods are scheduled is decided by the <a href="https://kubernetes.io/docs/concepts/scheduling/kube-scheduler/" rel="nofollow noreferrer">Kubernetes scheduler</a>. As mentioned in the documentation, the scheduler first finds eligible nodes in a filtering phase. Following that, the scheduler finds the most adequate node using scoring criteria mentioned in <a href="https://kubernetes.io/docs/concepts/scheduling/kube-scheduler/#scoring" rel="nofollow noreferrer">this section</a>. Among other factors, image locality and fitting Pods into as few nodes as possible could be the reason both Pods were allocated on the same node.</p>

<blockquote>
  <p>Is it a problem for redundancy? Can I assure that my replicas are
  spread to all nodes?</p>
</blockquote>

<p>This can be an issue for redundancy. If one Node, goes out, then your entire service becomes unavailable (if you use resources like Deployments and such, they will eventually be scheduled on the other node though).</p>

<p>In order to favor Pod spread among nodes, you can customize the scheduler or use mechanisms such as <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity" rel="nofollow noreferrer">affinity and anti-affinity</a>.</p>
