Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes: list all pods and its nodes

Tags:

kubernetes

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

NODE1 POD1 NODE1 POD2 NODE2 POD3 NODE3 POD4 

How can this please be achieved?

Thanks.

like image 498
testTester Avatar asked Feb 26 '18 07:02

testTester


People also ask

How do you check node pods?

To find the cluster IP address of a Kubernetes pod, use the kubectl get pod command on your local machine, with the option -o wide . This option will list more information, including the node the pod resides on, and the pod's cluster IP. The IP column will contain the internal cluster IP address for each pod.

What node is a pod running on?

Pods always run on Nodes. A Node is a worker machine in Kubernetes and may be a VM or a physical machine, depending on the cluster. Each Node runs Pods and is managed by the Master. On a Node you can have multiple pods.


Video Answer


1 Answers

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 
like image 116
nickgryg Avatar answered Nov 07 '22 12:11

nickgryg