Kubernetes API – gets Pods on specific nodes

kubectlkubernetes

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

Best Answer

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>
Related Topic