How kubernetes podAffinity priority score is computed?

6/10/2018

If I use a preferredDuringSchedulingIgnoredDuringExecution rule within a podAffinity, is the score of each node computed based on the number of pods on that node that match my rule? That is, would a node that has two pods that match my rule be preferred to another node which has only one pod matching my rule?

The podAffinity's design proposal algorithm suggests that it does not depend on the number of pods: Repeat Step 1a except replace the last line with "foreach node W of {N} having label [key=H.TopologyKey, value=any K such that M[K]>0], Y[W]++"

Is there a way to make a podAffinity rule that DOES depend on the number of pods in each node matching my rule?

-- Pro.Hessam
cluster-computing
kubernetes
kubernetes-pod

1 Answer

6/11/2018

Kubernetes mechanism tries to run as many pods as possible on one node. It hasn't a mechanism to calculate the number of pods with the same labels, it relies on resources.

-- Nick Rak
Source: StackOverflow