Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Get node that a specific pod is running on

I have 2 nodes that I’m running development pods on. I’d like to be able to echo only the node that a pod is running on based on the name.

I can use kubectl get pod -o=custom-columns=NAME:.metadata.name,NODE:spec.nodeName -n my-namespace to pull back all the names and nodes for all pods in that namespace, but I’d like to filter just the nodename for specific pods. Using grep on the pod name works, but I’m not sure if its possible to only show the node when filtering based off a single pod name.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Option-1: Using custom-columns

kubectl get pod mypod -o custom-columns=":.spec.nodeName" --no-headers 

Option-2: Using jsonpath

kubectl get pod mypod -o jsonpath='{.spec.nodeName}'
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

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

Continue reading