Faster way to switch between clusters and namespaces in kubectl
open sourceApache-2.0self-hostablefree
kubectx and kubens are two small command-line tools from one repository: kubectx switches the current kubectl context (the cluster you talk to), and kubens switches the active namespace, each with a dash to go back to the previous one. With fzf installed both open an interactive fuzzy menu, and both have tab completion for bash, zsh and fish. They're written in Go, installable from Homebrew, apt, pacman, Chocolatey, Scoop, winget or as the krew plugins ctx and ns, under Apache-2.0.
Problems it solves
- typing kubectl config use-context with long cluster names every time I switch clusters
- I keep running commands against the production cluster by mistake because I forgot which context I'm in
- change the default namespace without adding -n to every kubectl command
- jump back to the cluster I was on a minute ago
- pick a cluster from a fuzzy-search list instead of remembering its exact name
- rename long EKS and GKE context names to something short
- switch between a dozen Kubernetes clusters quickly from the terminal
Features
- kubectx switches kubeconfig contexts; kubens switches namespaces
- '-' switches back to the previous context or namespace
- interactive selection with fzf
- rename and delete contexts
- tab completion for bash, zsh and fish
- available as krew plugins ctx and ns
Capabilities
| Has a command line tool | plan not known |
|---|
Alternatives
The same job
These do what kubectx does.
- K9s Kubernetes CLI to manage your clusters in style
- kubectl The Kubernetes command-line tool
- Headlamp An easy-to-use and extensible Kubernetes web UI
- Lens The IDE for everything but code
- MCP Server Kubernetes MCP server that lets AI assistants manage a Kubernetes cluster through kubectl and Helm
