Switch Between Context in Kubernetes

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

What is Context?

The 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 config view

In the screenshot below, you can see 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 config use-conext minikube

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

kubectl cluster-info

Posted

in

,

by