I've got an on-premise cluster with 1 master and 3 workers. Now there's a deployment with 3 replica's and they MUST be evenly distributed over all the nodes.
Now we can use "topologySpreadConstraints" on kubernetes/hostName label for that but it doesn't always work.
apiVersion: apps/v1 kind: Deployment metadata: name: revproxy labels: app: proxy spec: replicas: 3 selector: matchLabels: role: proxy template: metadata: labels: role: proxy spec: topologySpreadConstraints: - maxSkew: 1 topologyKey: kubernetes.io/hostname whenUnsatisfiable: ScheduleAnyway labelSelector: matchLabels: app: revproxy
There's many times 2 pods running on the same node and 1 pod on another and zero pods on the 3rd. But when manually deleting a second pod then it ALWAYS gets scheduled on the empty node.
How can I use topologySpreadConstraints to have pods evenly distributed over the nodes?