Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 735
shiv455 Avatar asked Nov 08 '22 06:11

shiv455


1 Answers

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
                         ^^^^^^^
like image 127
VonC Avatar answered Nov 14 '22 23:11

VonC