Switch Context in Kubernetes with Kubectl
In Kubernetes Context is used to group all access parameters for a specific cluster under a convenient name in a kube config file. You can have multiple config files, but right now will focus on the case when you are using just one and all the contexts are in there.
Location of the default config file is
Linux: “~/.kube/config”
Windows: “$HOME\.kube\config”
The Context has three parameters: Cluster, Namespace and User.
When you use the kubectl it is using the current Context to know with which cluster and with what parameters to communicate with it.
Get the information for the current context:
kubectl config current-context
Get all the contexts in this config file:
kubectl config get-contexts
Switch to another context:
kubectl config use-context <context_name>