I need to get the list of pods running in a worker node by executing a command from master node. I can achieve if i moved into the worker node and execute kubectl get pods -n ns. But i need to execute this from the master node and get pods in worker.
How to list all the pods running in a particular worker node by executing a command from master?
17.2k Views Asked by AkshayBadri At
2
Running
kubectl get pods -n nsin a specific node does not give the pods running in that node, rather it will give all pods in namespacensregardless of which nodes they run.kubectl get pods -n ns -o wide --field-selector spec.nodeName=<nodename>gives the pods innsnamespace deployed in a particular node. This command can be executed from any nodes or from a system which has access to the cluster.To get pods from all namespaces running in a particular node use command
You can also use
kubectl describe nodes nodenameand checkNon-terminated Podssection to view which pods are currently running in that particular node.