Kubernetes: list all pods and its nodes

testTester picture testTester · Feb 26, 2018 · Viewed 73k times · Source

I have 3 nodes, running all kinds of pods. I would like to jave a list of nodes and pods, for an example:

NODE1 POD1
NODE1 POD2
NODE2 POD3
NODE3 POD4

How can this please be achieved?

Thanks.

Answer

nickgryg picture nickgryg · Feb 26, 2018

You can do that with custom columns:

kubectl get pod -o=custom-columns=NAME:.metadata.name,STATUS:.status.phase,NODE:.spec.nodeName --all-namespaces

or just:

kubectl get pod -o=custom-columns=NODE:.spec.nodeName,NAME:.metadata.name --all-namespaces