What happens if topologyKey is missing?

11/22/2021

According to https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/

Note: Pod anti-affinity requires nodes to be consistently labelled, in other words every node in the cluster must have an appropriate label matching topologyKey. If some or all nodes are missing the specified topologyKey label, it can lead to unintended behavior.

What exactly will happen when there is no topologyKey label? Pods will be placed anywhere and everything will be working or I should expect some errors.

-- Porok12
kubernetes

2 Answers

11/22/2021

There are currently two types of node affinity, called requiredDuringSchedulingIgnoredDuringExecution

and

preferredDuringSchedulingIgnoredDuringExecution.

You can think of them as "hard" and "soft" respectively, in the sense that the former specifies rules that must be met for a pod to be scheduled onto a node (pod will be in pending state ), while the latter specifies preferences that the scheduler will try to enforce but will not guarantee(Pod will be scheduled to any available node).

I Think same rules aplly for nodeantiaffinity as well.

-- confused genius
Source: StackOverflow

11/22/2021

After testing, it seems to ignore podAntiAffinity when topologyKey is missing.

-- Porok12
Source: StackOverflow