kubernetes : What are valid node fields kubernetes : What are valid node fields kubernetes kubernetes

kubernetes : What are valid node fields


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