Kubernetes API - gets Pods on specific nodes

Regnoult picture Regnoult · Aug 30, 2016 · Viewed 68.8k times · Source

Looking at http://kubernetes.io/docs/user-guide/labels/#selecting-sets-of-nodes it looks to be possible to select a certain range of pods based on labels. But in my case I want to select all the pods on one node but I don't want to label each pod on their corresponding node.

Am I missing something from the documentation or is it just not possible to select by node? If I do:

kubectl --server="<SERVER>" --namespace=<NS> get pods -o wide | head
    NAME   READY     STATUS             RESTARTS   AGE       NODE

Can any of these header be used as selector? If yes how to do it with kubectl bust most importantly, how to do it with the API?

Thanks in advance

Answer

Kristofer picture Kristofer · Jun 12, 2018

As mentioned in the accepted answer the PR is now merged and you can get pods by node as follows:

kubectl get pods --all-namespaces -o wide --field-selector spec.nodeName=<node>