How to list Kubernetes in different namespaces by its kind?

10/6/2021

I've a task list to Kubernetes pods by its kind. For Eg List kubernetes pods that are in different namespace using Jsonpath. I'm using the below command which is not working.

kubectl get pods -o jsonpath='{.items[?(@.items.kind=="Elasticsearch")]}'
-- P Nisanth Reddy
json
jsonpath
kubernetes
kubernetes-pod
linux

2 Answers

10/22/2021

To see the pods in different namespace:

kubectl get pods -o jsonpath='{.items[?(@.kind=="Pod")]}' -n <namespace-name>
-- Vallabha Vamaravelli
Source: StackOverflow

10/6/2021

You can try to use the following command.

kubectl get pods -o jsonpath='{.items[?(@.kind=="Pod")]}' --all-namespaces
-- Lejdi Prifti
Source: StackOverflow