Field Selectors
status.phase=Pending
This kubectl
command selects all Pods for which the value of the status.phase field is Running
:
Supported field selectors vary by Kubernetes resource type. All resource types support the metadata.name
and fields. Using unsupported field selectors produces an error. For example:
kubectl get ingress --field-selector foo.bar=baz
As with label and other selectors, field selectors can be chained together as a comma-separated list. This kubectl
command selects all Pods for which the status.phase
does not equal Running
and the spec.restartPolicy
field equals Always
:
kubectl get statefulsets,services --all-namespaces --field-selector metadata.namespace!=default