Faster way to switch between Kubernetes contexts and namespaces
kubectx and kubens are power tools that enhance kubectl workflow efficiency by simplifying context and namespace switching. kubectx enables fast switching between Kubernetes clusters (contexts) configured in your kubeconfig, while kubens allows easy switching between namespaces within those clusters. Both tools eliminate the need to remember and type long context or namespace names, significantly speeding up daily Kubernetes operations.
The tools support both command-line operations and interactive mode with fuzzy searching when paired with fzf. They provide convenient features like switching back to the previous context/namespace with a simple dash (-), renaming contexts for better organization, and comprehensive tab completion for bash, zsh, and fish shells. Originally written in Bash, the tools have been rewritten in Go while maintaining backward compatibility with the original implementations.
kubectx and kubens are essential for DevOps engineers, platform engineers, and developers who frequently work with multiple Kubernetes clusters or need to switch between different namespaces. The tools integrate seamlessly into existing kubectl workflows and can be installed as kubectl plugins, making them feel like native kubectl functionality.
# via Homebrew
brew install kubectx
# via apt
sudo apt install kubectx
# via kubectl krew
kubectl krew install ctx && kubectl krew install ns


