When I do
kubectl get pods -A
I get all pods, and I always have 17 pods that are not "apps", they belong to namespace kube-system
. I would like to have an alias not to print them.
Is there a way to print all pods, excluding a namespace ?
You can accomplish this via field selectors:
kubectl get pods -A --field-selector=metadata.namespace!=kube-system
Additionally, the field selector list can have multiple parameters, separated by ,
(comma literals), and use ==
or !=
to specify additional criteria.
Use --field-selector
kubectl get pods --all-namespaces --field-selector metadata.namespace!=kube-system
more about field selectors here: https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/