CLI tools to quickly switch between Kubernetes contexts and namespaces with fuzzy search support
kubectx and kubens are complementary CLI utilities that simplify Kubernetes cluster and namespace management. kubectx allows users to switch between different Kubernetes contexts (clusters) defined in their kubeconfig, supporting quick context switching, renaming contexts with aliases, and launching isolated or read-only shells for specific contexts. kubens provides similar functionality for Kubernetes namespaces, enabling rapid namespace switching within the current context.
Both tools integrate with fzf to provide interactive fuzzy search menus when selecting contexts or namespaces. They support tab completion across bash, zsh, and fish shells, eliminating the need to remember long context names. kubectx includes a previous context feature using the - flag, similar to cd -, and kubens can switch to namespaces that don't yet exist using the -f flag.
The tools are designed for Kubernetes developers, DevOps engineers, and platform operators who frequently work across multiple clusters or namespaces. Installation is available through system package managers (Homebrew, apt, pacman), Windows package managers (Chocolatey, Scoop, winget), or as kubectl plugins via Krew. The utilities can be customized with environment variables for colors and behavior, including the ability to disable color output entirely.
# via Homebrew
brew install kubectx
# via apt
sudo apt install kubectx
# via Krew
kubectl krew install ctx && kubectl krew install ns


