Fast k8s Context and Namespace Switching With Kubectx Kubens

kubectx and kubens are both great tools which speeds up working with multiple Kubernetes clusters. kubectx allows quickly changing context. kubens allows changing namespace in given context.

kubectx

With kubectl you need to type

kubectl config use-context my-context

With kubectx

kubectx my-context

If you have fzf installed, you can interactively select cluster by just writing kubectx.

kubens

Kubens is similar but it allows setting namespace. Instead of doing

kubectl config set-context --current --namespace=my-namespace

You can do

kubens my-namespace

Fzf selection works here as well.

Installation

For Mac, if you are using Homebrew, it is as simple as doing

brew install kubectx

For other platforms, you can referer here.