How to switch from an AKS cluster to another

A good friend of mine asked me about Azure Kubernetes, the famous AKS. The question was, how can I easily switch from one cluster to another?

So, there are quite a few ways to do that task, I going to show you two of them that I usually use.

Via Azure cli, that one it’s the one that I use very rarely, sometimes just once to connect to cluster, but let me show you:

➜  ~ az login
➜  ~ az aks list -o table
➜  ~ az aks get-credentials -n <AKS_name> -g <Resource_Group>

Cool, now you are connect to the AKS cluster, and you can easily check running:

➜  ~ kubectl get pods -A

Now you want to connect to another cluster, it’s fine just repeat the commands above with the proper information.
Fantastic, but now you want to go back to the first cluster, no worries but instead run the Azure cli commands you can do it via Docker desktop.
Once you are working or playing around with Kubernetes, it’s very handy to install Docker desktop which is a software that creates a single node K8S cluster in your desktop.

To download it click here
After installation you should see a new docker icon in your menu bar, click on it and then dashboard:

You might notice another section called “Kubernetes”, there you can see all the clusters you have connected, just select the one you want and start to work with ????

Local Kubernetes config file:

➜  ~ cat ~/.kube/config

You can check via command as well:

➜  ~ kubectl config view

Related Post