shiv455
shiv455

Reputation: 7784

kubectl command to get list of pods running on k8s master node

Is it possible to get a list of pods that are Running on matser from kubectl?

i have tried this

kubectl get pods -o wide --sort-by="{.spec.nodeName}"

but this doesnt say whether the node is master or worker

Upvotes: 5

Views: 4520

Answers (1)

VonC
VonC

Reputation: 1329672

As mentioned in the overview:

A Pod always runs on a Node.
A Node is a worker machine in Kubernetes and may be either a virtual or a physical machine, depending on the cluster. Each Node is managed by the Master

So by definition (even if it runs on the same physical machine than the master), any node is on a "worker machine"

https://d33wubrfki0l68.cloudfront.net/5cb72d407cbe2755e581b6de757e0d81760d5b86/a9df9/docs/tutorials/kubernetes-basics/public/images/module_03_nodes.svg

Only kubectl get node does display a ROLE:

vonc@voncvb:~/.kube$ kubectl get node -o wide
NAME           STATUS    ROLES     AGE       VERSION   EXTERNAL-IP   OS-IMAGE                 KERNEL-VERSION
serv0.server   Ready     <none>    18d       v1.9.7    <none>        SUSE CaaS Platform 3.0  docker://x.y.z.z
serv1.server   Ready     <none>    18d       v1.9.7    <none>        SUSE CaaS Platform 3.0   docker://x.y.z.z
serv2.server   Ready     <none>    18d       v1.9.7    <none>        SUSE CaaS Platform 3.0   docker://x.y.z.z
servm.server   Ready     master    18d       v1.9.7    <none>        SUSE CaaS Platform 3.0   docker://x.y.z.z
                         ^^^^^^^

Upvotes: 1

Related Questions