How can I use multiple parameter on kubernetes CLI?

5/22/2019

I am seeking to how to be able to use multiple parameter on kubernetes. For example:

kubectl get pods -n default || kube-system

(but the results of this query come out only the result of default namespace).

How can I use multiple params?

-- strangedeveloper
kubernetes

2 Answers

5/22/2019

try this

kubectl get po --all-namespaces | grep kube-system

or even better

kubectl get po --all-namespaces | grep -iE 'dns|api'
-- P Ekambaram
Source: StackOverflow

5/22/2019

You can't query for multiple namespaces resources in one command. As there is explanation why it is not worth to do that on this github issue

But you can query for multiple resources across one or --all-namespaces. For example got get services and pods for namespace kube-dns and default(this will include workaround as @PEkambaram suggested)

kubectl get svc,pods --all-namespaces |egrep -e 'kube-dns|default'
-- coolinuxoid
Source: StackOverflow