Kubernetes API - gets Pods on specific nodes

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>

Example sorting pods by nodeName:

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

Example of getting pods on nodes using label filter:

for n in $(kubectl get nodes -l your_label_key=your_label_value --no-headers | cut -d " " -f1); do 
    kubectl get pods --all-namespaces  --no-headers --field-selector spec.nodeName=${n} 
done

or by number of restarts

kubectl get pods --sort-by="{.status.containerStatuses[:1].restartCount}"

Example filtering by nodeName using --template flag:

$ kubectl get nodes

NAME                         STATUS                     AGE
ip-10-0-90-30.ec2.internal   Ready                      2d
ip-10-0-90-35.ec2.internal   Ready                      2d
ip-10-0-90-50.ec2.internal   Ready,SchedulingDisabled   2d
ip-10-0-91-60.ec2.internal   Ready                      2d
ip-10-0-91-65.ec2.internal   Ready                      2d


$kubectl get pods --template '{{range .items}}{{if eq .spec.nodeName "ip-10-0-90-30.ec2.internal"}}{{.metadata.name}}{{"\n"}}{{end}}}{{end}}'

filebeat-pezch
app-5xole
node-exporter-6kfs8
prometheus-0
sso-359976856-wu8zt

You also can query for all pods an a node with the following command

kubectl get pods -o wide --all-namespaces | grep <YOUR-NODE>