I have two different deployments that I need to have their pods be scheduled in different nodes in the cluster. For this I am adding this podAntiAffinity configuration:
template:
metadata:
labels:
run: docker
dind: iprd-net
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: dind
operator: Exists
topologyKey: kubernetes.io/hostname
But it is not working. I get pods from both deployments be scheduled to the same node. As I understand it, I am adding the label "dind" (with a value). And my podAntiAffinity label selector should not choose any node (in the hostname topology, which effectly should bean any node as each node has a different hostname) that does NOT have that label (dind).
What am I missing?
dind
. Since these pods have labeldind
, this will ensure that pods created by this deployment are spread across multiple hosts.