I have 3 nodes, each of them labeled like following:
- node-0 -> mongo-volume=volume-0
- node-1 -> mongo-volume=volume-1
- node-2 -> mongo-volume=volume-2
I'm looking for a way to schedule the replicas of a statefulset on a special node.
I first used the hard way with requiredDuringSchedulingIgnoredDuringExecution and everything works well.
Then I wanted to test the soft way by using preferredDuringSchedulingIgnoredDuringExecution.
I first tell to my statefulset to have a preference for the node having the label volume-0, no problems the pods were all deployed on the node-0.
Then I changed the preference for the node having the label volume-1. And there is my problem, the pods were deployed on the node-0 and node-2 but node on the node-1.
I did the same with the label volume-2 and it works well again, the pods were all deployed on the node-2.
Node Affinity configuration:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
preference:
matchExpressions:
- key: mongo-volume
operator: In
values:
- volume-1
When I looked for the resource usage of the nodes, I noticed that the node-1 had a bit more load than the others. Could it explain why the sheduler refuses to deploy the pods on this node ?
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
node-0 63m 6% 795Mi 41%
node-1 116m 11% 978Mi 51%
node-2 78m 7% 752Mi 39%
I'm wondering why it works for the node-0 and the node-2 but not for the node-1. And if there is a possible way to fix it.