Skip to content

kubectx

image

Kubectx is a tool to switch between contexts (clusters) on kubectl faster.

How to install

Mac

brew install kubectx

In addition, fzf provides an interactive way to switch between the options, no need to write or remember contexts or namespaces.

brew install fzf

image

Linux

sudo git clone https://github.com/ahmetb/kubectx /opt/kubectx
sudo ln -s /opt/kubectx/kubectx /usr/local/bin/kubectx

From source

You can also install this tool manually from the GitHub

How to use

Switch to another cluster that's in kubeconfig

$ kubectx minikube
Switched to context "minikube".

Switch back to previous cluster

$ kubectx -
Switched to context "oregon".

Create an alias for the context

$ kubectx dublin=gke_ahmetb_europe-west1-b_dublin
Context "dublin" set.
Aliased "gke_ahmetb_europe-west1-b_dublin" as "dublin".