Every so ofter I get in a situation where I need to see if my configuration is still valid for every cluster in my Kubernetes config. I blogged a while back about managing multiple configs. Then, eventually, your K8s config ends up looking like this:
It gets tedious to go through every config like this:
kubectl config use-context <the next context>
kubectl get pod
<blah blah>
Through a little googling I now use this command to go through each cluster and run a command.
kubectl config get-contexts -o name | xargs -I {} kubectl --context={} get nodes -o wide
Now I can quickly see if a cluster fails to authenticate because I did something like rebuilt it and didn’t update the configuration on my local machine.
Another favorite of mine is:
kubectl config get-contexts -o name | xargs -I {} kubectl --context={} get pvc -A
Since I have to check all the storage on each cluster.
Yes, there is a theme to my cluster names and users.