How to search by arbitrary fields using field selector with kubectl?
You can select the serviceAccount
using following query:
kubectl get pods --field-selector=spec.serviceAccountName="default"
The --field-selector
currently selects only equality based values and in that too it has very limited support to select the pod based on fields. The following fields are supported by --field-selector
:
metadata.namemetadata.namespacespec.nodeNamespec.restartPolicyspec.schedulerNamespec.serviceAccountNamestatus.phasestatus.podIPstatus.nominatedNodeName
As you already know, you need to rely on the jsonpath to select any other field other than above fields.
You can visit following link to find out more:
https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/core/v1/conversion.go#L160-L167]1