Kubech is a convenient tool for developers, DevOps engineers, and Kubernetes administrators that allows you to manage kubectl contexts and namespaces separately for each terminal or tab.
It works similarly to kubectx and kubens, but adds an essential improvement - contexts are isolated between shell sessions, making multi-cluster operations safer and more transparent.
GitHub: DevOpsHiveHQ/kubech
Why You Need Kubech
When working with multiple Kubernetes clusters (for example, prod, staging, and dev), it’s easy to lose track of which one you’re currently connected to. The default kubectl uses a global context, so if you switch it in one terminal, it changes everywhere.
Kubech solves this problem by assigning its own context and namespace to each terminal session. This allows you to work with multiple clusters simultaneously without risking accidental operations in the wrong environment.
Main Features
- Per-terminal context isolation - each shell session has its own context and namespace.
- Fast context and namespace switching - uses familiar kubectx and kubens-style commands.
- Integration with bash/zsh/fish - supports the most popular shells.
- Color indicators - display current context and namespace in the prompt to prevent mistakes.
- Security - isolated sessions make it safer to work with multiple environments in parallel without touching global configuration.
Usage Examples
1. Switching between clusters
Switch to the staging context:
In another terminal, work with production:
Now, the first tab interacts with the staging cluster, while the second one is connected to production - both are independent.
2. Working with namespaces
Set the namespace for the current session:
Check the current configuration:
You can execute kubectl commands, and Kubech will automatically apply the correct namespace only for this shell session.
3. Shell integration
Kubech adds visual indicators to your prompt so you always know where you are:
Installation
1. Via Homebrew (macOS/Linux)
2. From source
cd kubech
make install
3. Shell integration setup
Add to your ~/.bashrc or ~/.zshrc:
After restarting your terminal, Kubech will automatically track context and namespace for each session.
When Kubech Is Especially Useful
- When managing multiple clusters at the same time (e.g., staging and production).
- For DevOps engineers, administrators, and SREs who frequently switch between environments.
- To avoid accidental mistakes caused by the global kubectl context.
- When working in multi-window environments such as tmux, iTerm, VS Code Terminal, etc.
Why You Should Try Kubech
- Safety: reduces the risk of performing operations in the wrong cluster.
- Flexibility: allows you to work with multiple environments simultaneously.
- Compatibility: supports all popular shells and plugins.
- Simplicity: easy installation and familiar commands.
Frequently Asked Questions (FAQ)
- Can I use Kubech together with kubectx and kubens?
Yes, Kubech doesn’t conflict with them. It simply adds per-terminal context isolation. - Where does Kubech store its settings?
In the ~/.kubech directory - it stores session and context data. - Does Kubech work with tmux and screen?
Yes, each tmux pane or screen window has its own context. - Does Kubech support fish or PowerShell?
Yes, integration is available for those shells as well. - Does Kubech modify the global kubeconfig?
No, Kubech does not change your ~/.kube/config. All changes apply only within the current terminal session. - Can I use Kubech on servers?
Yes, it’s cross-platform and works on Linux, macOS, and WSL.
Conclusion
Kubech is a lightweight and reliable way to manage multiple Kubernetes clusters simultaneously. It enhances safety, prevents context-related mistakes, and improves efficiency in complex infrastructures. If you often switch between environments, Kubech will become your essential helper.