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:
![](http://54.88.246.86/wp-content/uploads/2020/06/image-6-1024x171.png)
![](http://54.88.246.86/wp-content/uploads/2020/06/image-8-1024x451.png)
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.
![](http://54.88.246.86/wp-content/uploads/2020/06/image-7-1024x94.png)
Yes, there is a theme to my cluster names and users.