Reputation: 745
I would like to use podAffinity with matchFields. On the web I only found examples with field metadata.name :
- matchFields:
- key: metadata.name
operator: NotIn
values:
- worker-1
I would like to know if there are any other valid node fields I can use and how/where I can find them?
Thx in advance
Upvotes: 2
Views: 1431
Reputation: 6853
I did some digging and I found out that Matchfields
was introduced because of the issue with scheduling DaemonSets
. The Controller that creates pod was depending the kubernetes.io/hostname
label on a Node. This whole setup was assuming that this label is being equal to the node name which turned out wrong one becuase node name and hostname
are distinct in some cases. See #61410 for more reading. This also explains why there example of using this is only related to DaemonSet in the docs.
Because of that PR #62002 was merged which added MatchFields
to NodeSelectorTerm
with the release note that explains that only metadata.name
is being supported:
Added `MatchFields` to `NodeSelectorTerm`; in 1.11, it only support `metadata.name`.
So at the time of this writing the only supported field is metadata.name
. I've check also tests code and it appears that this behavior has not changed till now.
PS. Please note that this can only be used in NodeSelector
and not applicable in PodAffinity/PodAntiAffinity
Upvotes: 5