I'm trying to get some pods to co-locate with their data stores, but the affinity rules don't seem to be playing ball.
The rules I have in place for search-one, are:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- solr
namespaces:
- search-one
- search-solr
topologyKey: kubernetes.io/hostname
weight: 75
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- search-one
topologyKey: failure-domain.beta.kubernetes.io/zone
weight: 50
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- search-one
topologyKey: kubernetes.io/hostname
What this is trying to express is "Prefer to run on the same node as search-solr, ideally in different zones, and never run two instances of search-one on the same node"
But as you can see, only one of the search-one
instances co-locater with a solr.
❯ k get pods --all-namespaces -o wide -l app=search-one
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE
search-one search-one-76f6cdbc6b-dwjjq 2/2 Running 0 1h 10.202.3.19 gke-delivery-platform-custom-pool-698c2edf-jdrp
search-one search-one-76f6cdbc6b-xg89n 2/2 Running 0 1h 10.202.5.42 gke-delivery-platform-custom-pool-705aff48-phhr
❯ k get pods --all-namespaces -o wide -l app=solr
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE
search-solr solr-0 2/2 Running 0 13h 10.202.1.11 gke-delivery-platform-custom-pool-705aff48-g73b
search-solr solr-1 2/2 Running 0 11h 10.202.9.6 gke-delivery-platform-custom-pool-ef7d431d-gwxz
search-solr solr-2 2/2 Running 1 20h 10.202.3.10 gke-delivery-platform-custom-pool-698c2edf-jdrp
Any ideas?