Switching contexts in Kubectl

Visakh Vijayan
1 min readNov 22, 2024

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!

--

--

Visakh Vijayan
Visakh Vijayan

Written by Visakh Vijayan

Techie from Kerala, India. Days are for coding, nights for weaving tales of tech, travel, and finance. Join me in exploring this multifaceted journey

No responses yet