How to search all namespaces in Kubernetes

I wasn’t expecting to get so in-depth into namespaces but I had another question come up.  What if you have multiple namespaces in your environment and you wanted to see them all.  Also, what if you were trying to find a particular pod in an unknown namespace.

My previous namespace articles:
How to switch between namespaces in Kubernetes
Create a Kubernetes namespace with default quotas
Create a new Kubernetes namespace with quotas

How to see all namespaces

Screenshot from the Search All Kubernetes Namespaces walkthrough at step 1; the adjacent article text explains that how to see all namespaces.

$ kubectl get namespaces

Pretty easy one here and as you can see I have a lot of namespaces created.

Finding a particular pod in an unknown namespace – for this example we are looking for the pod named mysql

Screenshot from the Search All Kubernetes Namespaces walkthrough at step 2; the adjacent article text explains that finding a particular pod in an unknown namespace - for this example we are looking for the pod named mysql.

$ kubectl get pods –all-namespaces | findstr <pod>

$ kubectl get pods –all-namespaces | grep -I <pod>

Summary:
Once again, really that easy.  As always, I hope y’all found this helpful.

Keep exploring

Choose your next step

Continue with the path that best matches the architecture or operating challenge in front of you.

Leave a Reply

Discover more from Digital Thought Disruption

Subscribe now to keep reading and get access to the full archive.

Continue reading