Juliatzin
Juliatzin

Reputation: 19705

Get all pods except the pods inside kube-system

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 ?

Upvotes: 8

Views: 3711

Answers (2)

Alberto
Alberto

Reputation: 15951

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/

Upvotes: 5

Cloud
Cloud

Reputation: 19333

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.

Upvotes: 17

Related Questions