snippetkubernetesMinor
How can I set up Deployment to run at least one pod on each node?
Viewed 0 times
caneachnodeoneleasthowpoddeploymentsetrun
Problem
I need to set my deployment to have at least one pod on each node so that the system will continue uninterrupted in case the node goes down. I can set this to run one pod per node with daemonset or podAntiAffinity. But what I really want is that there is at least one pod in each node and all pods can be scheduled if there are more replicas than the number of nodes.
How can I do that?
Thank you for your answers
How can I do that?
Thank you for your answers
Solution
You can use
The
topologySpreadConstaints for spreading Deployment pods evenly across nodes, regardless of the number of pods. Kubernetes documentation contains multiple examples, as well as following article - Kubernetes: Evenly Distribution of Pods Across Cluster Nodes.The
.spec.teplate.spec would look something like:spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
type: dummyCode Snippets
spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
type: dummyContext
StackExchange DevOps Q#15705, answer score: 2
Revisions (0)
No revisions yet.