Which fields can you use with Kubernetes field selectors?
Field selectors are a handy filter you can provide
kubectl get via the
--field-selector option to pare down the list of resources you get back from the server. The docs mention that supported fields vary from resource to resource, but sadly don't mention which resources support which fields. I did a little bit of poking around, and - as far as I can tell - this isn't documented anywhere! So, seeing as reading source code is one of my Maslow's hammers, I broke out that particular hammer and got to reading.
After a little bit of time and effort I managed to find the code that determines which fields are valid for field selectors - you can find it by looking for
**/strategy.go in the Kubernetes repository. So now once this post becomes outdated, you can refresh the list for yourself :)
Here's the list of which resources support which fields (in addition to
metadata.name, which all resources support) as of Kubernetes 1.20:
|source (appears to resolve to metadata.source.component, falls back to reportingComponent)|