Kubectl: Switch Context – Kubernetes

A Context in Kubernetes is used to group access parameters under convenient names in a kubeconfig file.

Each Context has three parameters: Cluster, Namespace and User.

In this note i will show how to display and how to change Context in Kubernetes using the kubectl command.

Cool Tip: List Namespaces in Kubernetes cluster! Read more →

Switch Context in Kubernetes

By default, the kubectl command uses parameters from the current Context to communicate with the cluster.

Display the current Context:

$ kubectl config current-context

List all the Contexts in a kubeconfig file:

$ kubectl config get-contexts

Switch Context:

$ kubectl config use-context <context_name>

Cool Tip: List Pods in Kubernetes cluster! Read more →