How to distribute pods to all nodes evenly

Viewed 48

I have three nodes and have pod replica 9. When I am trying to deploy, Pods are unevenly scheduled on nodes.

How can I make sure that Pods are evenly scheduled on three nodes?

1 Answers

You should configure topology spread constraints. These control how pods are scheduled across your Kubernetes cluster based on regions, zones, nodes.

For spreading across nodes, you could use maxSkew (maxSkew describes the degree to which Pods may be unevenly distributed)

spec:
  topologySpreadConstraints:
    - maxSkew: 1
      topologyKey: node
      whenUnsatisfiable: DoNotSchedule
Related