How to list the actual kubernetes nodes a specific resouce is running on

7/29/2016

When listing resources such as POD running on a cluster, how to know which physical node are they on?

kubectl get {resource-type} command returns the following columns.

NAMESPACE NAME READY STATUS RESTARTS AGE

Could not find a way to list the actual nodes (could be more than one for a resource) side by side.

-- Santanu Dey
kubernetes

2 Answers

7/29/2016

The -o flag seems to work

[root@kubernetes1 temp]# kubectl get pod  --namespace=kube-system -o wide
NAME                                READY     STATUS    RESTARTS   AGE       IP          NODE
k8s-master-127.0.0.1                4/4       Running   0          33m       127.0.0.1   127.0.0.1
k8s-proxy-127.0.0.1                 1/1       Running   0          32m       127.0.0.1   127.0.0.1
kube-addon-manager-127.0.0.1        2/2       Running   0          33m       127.0.0.1   127.0.0.1
kube-dns-v18-z9igq                  3/3       Running   0          33m       10.1.49.2   127.0.0.1
-- Santanu Dey
Source: StackOverflow

7/30/2016

You can use kubectl describe po to get the specific pod details.

kubectl describe po nginx-abcde

The output would look as below

Name: nginx-abcde Namespace: default ...

You could use a json parser like "jq" to parse kubectl get po -o json output to get specific fields as node ,hostIP etc.

Refer to http://kubernetes.io/docs/user-guide/kubectl-cheatsheet/ for examples.

-- jkantihub
Source: StackOverflow