Control node/pod affinity of individual pods of statefulset in kubernetes cluster

10/11/2020

I want to control the node affinity of individual pods of a same statefulset. Say, I have a cluster on cloud of 3 nodes and each node belongs to a different zone. My statefulset resource has 6 replicas and needs to follow below constraints.

1. Distribute pods such that each node gets 2 replicas always.
2. If one node gets down, the 2 pods running on it should not get rescheduled on other nodes and be in Pending state.
3. When that down node comes up, those 2 pending pods should come back on it.

Is there a way to achieve it?
-- Nish
ibm-cloud
kubernetes
kubernetes-helm
kubernetes-pod
kubernetes-statefulset

0 Answers