Get all pods except the pods inside kube-system

10/8/2019

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 ?

-- Juliatzin
kubernetes

2 Answers

10/8/2019

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.

-- Cloud
Source: StackOverflow

10/8/2019

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/

-- Alberto
Source: StackOverflow