Switching Contexts with Kubectx
Posted: 12 Jun 2022
Updated: 10 Jun 2022
Verified: 10 Apr 2022
Kubectx is a tiny cli shortcut to aid in k8s management and switching between contexts and namespaces.
Normally you would control this sort of thing with a more complicated command. To set the default namespace for the current context, you would use:
kubectl config set-context --current --namespace=<namespace>
To return to the default:
kubectl config set-context --current --namespace=""
The easier-to-remember version is:
brew install kubectx
kubens # list namespaces
kubens <namespace> # set default namespace
kubectx # list contexts
kubectx <context} # set context