Switching contexts in Kubectl
I have been working with Azure Kubernetes Cluster on Azure for some time now. And I have realized it is a pain managing a lot of contexts. I have to run the Connect
commands by going into each Azure AKS cluster every time I want to switch.
Luckily there is an easy way to connect to an AKS cluster locally.
Open your terminal and write this into it
kubectl config get-contexts --no-headers
This gets all the saved contexts in your local machine. The one that is currently active is marked using an asterisk (*)
Once done you can switch between them using the below command
kubectl config use-context <context-name>
And there you go. Next time you don’t have to go to Azure to change your cluster context. Wallah!
Also, if you are looking for a cool editor that allows you to do all of this seamlessly, try out Warp!