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 →

Was it useful? Share this post with the world!

One Reply to “Kubectl: Switch Context – Kubernetes”

  1. As a newbie to kubernetes, allow me to say that this saved me a lot of time grappling numerous searches. Thanks

Leave a Reply