kubernetes

Kubernetes: list all pods and its nodes


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?


Solution

  • 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