Friday, 13 November 2020

Inspecting Kubernetes Worker nodes - a Work-in-Progress

I have a need to query a list of Kubernetes Worker Nodes, and ignore the Master Node.

This is definitely a W-I-P, but here's what I've got thus far

So we have a list of nodes: -

kubectl get nodes

68bc83cf0d09   Ready    <none>   51d   v1.19.2
b23976de6423   Ready    master   51d   v1.19.2

of which I want the one that is NOT the Master.

So I do this: -

kubectl get nodes | awk 'NR>1' | grep -v master | awk '{print $1}'

which gives me this: -


so that I can do this: -

kubectl describe node 68bc83cf0d09 | grep -i internal

which gives me this: -


If I combine the two commands together: -

kubectl describe node `kubectl get nodes | awk 'NR>1' | grep -v master | awk '{print $1}'` | grep -I internal

I get what I need: -


Obviously, there are fifty-seven other ways to achieve the same, including using JSON and JQ: -

kubectl get node `kubectl get nodes | awk 'NR>1' | grep -v master | awk '{print $1}'` --output json | jq

so that I could then use JQ's select statement to find the internal IP .... but that's for another day.....

No comments:

TIL - read-only variables in Linux

 A co-worker was seeing an exception: -  line 8: TMOUT: readonly variable when trying to SCP a file from a remote Linux box. I did some digg...