How to Switch AKS Clusters
Posted on:April 9, 2022
· 1 min read The following recipe shows how to change the active Kubernetes context using the Azure CLI.
Step 1. Login to Azure.
az login
Step 2. Get the list of AKS clusters to find the cluster name and its resource group.
az aks list -o table
Step 3. Fetch the credentials for the cluster you want to switch to. This adds the context to your kubeconfig and sets it as active.
az aks get-credentials --resource-group <resource-group> --name <cluster-name>
If you already have credentials for the cluster and just want to switch between existing contexts, skip Step 3 and use:
kubectl config use-context <cluster-name>
To see all contexts currently configured in your kubeconfig:
kubectl config get-contexts