Switch Between Contexts in Kubernetes

Today, I will show you how to switch between contexts in Kubernetes and manage multiple environments from a single machine.

What is Context ?

Context in Kubernetes is like a connection to a server that tells Kubernetes which Cluster to connect to.

When we set the context, Kubernetes will send all the command to the cluster that is set in the context.

View Current

To view the current context Kubernetes is using I will use the command below.

kubectl.exe config view

In the screen shot below, you can see the my context is set to use Docker (docker-for-desktop)

Switch Context

To switch to another context, I will use the command below which will switch me to my Minikube cluster

kubectl.exe config use-conext minikube

To view my cluster information, I will run the command below

kubectl.exe cluster-info

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.