Quantcast
Channel: A Portal to a Portal
Viewing all articles
Browse latest Browse all 1850

More Kubernetes goodness ....

$
0
0

My uber-smart colleague has continued to post really rather useful kubectl tips and tricks, including this most recent one: -

Get all the pods that are on specific node. Change the node name accordingly

kubectl get pods -o jsonpath='{range $.items[?(@.spec.nodeName=="kubenode01")]}{.metadata.name}{"\t"}{.spec.nodeName}{"\n"}{end}'

Initially, this didn't appear to work for me - in that it didn't return anything ... that, of course, was a PEBCAK

Initially, I thought that was because my node names included the host AND domain names

Of course, it wasn't that - it was just that I didn't actually have any pods deployed to the default namespace.

Once I amended the command to include ALL namespaces, all was well: -

kubectl get pods --all-namespaces -o jsonpath='{range $.items[?(@.spec.nodeName=="sideling1.example.com")]}{.metadata.name}{"\t"}{.spec.nodeName}{"\n"}{end}'

calico-kube-controllers-cc8959d7f-9qhh4sideling1.example.com
calico-node-kwj42sideling1.example.com
coredns-558bd4d5db-dmnncsideling1.example.com
coredns-558bd4d5db-t8xnmsideling1.example.com
etcd-sideling1.example.comsideling1.example.com
kube-apiserver-sideling1.example.comsideling1.example.com
kube-controller-manager-sideling1.example.comsideling1.example.com
kube-proxy-kz2cmsideling1.example.com
kube-scheduler-sideling1.example.comsideling1.example.com

kubectl get pods --all-namespaces -o jsonpath='{range $.items[?(@.spec.nodeName=="sideling2.example.com")]}{.metadata.name}{"\t"}{.spec.nodeName}{"\n"}{end}'

calico-node-jd867sideling2.example.com
kube-proxy-bc897sideling2.example.com


Viewing all articles
Browse latest Browse all 1850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>