Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get all pods except the pods inside kube-system

Tags:

kubernetes

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 ?

like image 526
Juliatzin Avatar asked Oct 08 '19 14:10

Juliatzin


2 Answers

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.

like image 160
Cloud Avatar answered Nov 13 '22 09:11

Cloud


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/

like image 30
Alberto Avatar answered Nov 13 '22 10:11

Alberto