Switching Contexts with Kubectx

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
Tagged: | kubernetes |
Cover Image: Firmbee.com, via Unsplash