In K8s find what nodes do pods exist in

10/20/2021

I want to know what nodes correspond to pods in a K8s cluster. I am working with a 3 node K8s cluster which has 2 specific pods among other pods.

How can I see which pod exists in which node using kubectl?

When I use kubectl get pods, I get the following:

NAME                                  READY   STATUS    RESTARTS   AGE
pod1-7485f58945-zq8tg                 1/1     Running   2          2d
pod2-64c4564b5c-8rh5x                 1/1     Running   0          2d1h

Following is the version of K8s (kubectl version) that I am using

Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.0", GitCommit:"af46c47ce925f4c4ad5cc8d1fca46c7b77d13b38", GitTreeState:"clean", BuildDate:"2020-12-08T17:59:43Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.13", GitCommit:"53c7b65d4531a749cd3a7004c5212d23daa044a9", GitTreeState:"clean", BuildDate:"2021-07-15T20:53:19Z", GoVersion:"go1.15.14", Compiler:"gc", Platform:"linux/amd64"}
-- Arctic Wolf
kubernetes
kubernetes-helm
kubernetes-pod

1 Answer

10/20/2021

Try kubectl get pods -o wide.

You can get more details in this very detailed Kubernetes cheatsheet.

-- Ji Won Song
Source: StackOverflow