A simple, production-ready CLI tool to easily switch Kubernetes contexts.
- Features
- Quick Start
- Supported Platforms
- Installation
- Usage
- Configuration
- Troubleshooting
- FAQ
- Contributing
- License
- 🟢 Simple: Easy to install, use, and understand. The codebase is straightforward and beginner-friendly.
- 🚀 Interactive context switching: Quickly list and switch between Kubernetes contexts in your kubeconfig.
- 🛠️ Cross-platform: Supports Linux, macOS, and Windows.
- ⚡ Fast and lightweight: Built with Go, Cobra, Viper, and Survey for a seamless CLI experience.
- 🔒 No telemetry: Your data and kubeconfig never leave your machine.
# Download and install (Linux/macOS)
wget https://github.com/itzzjb/kubernetes-context-changer-cli/releases/latest/download/ktx-<os>-<arch>
chmod +x ./ktx-<os>-<arch>
sudo mv ./ktx-<os>-<arch> /usr/local/bin
ktx- Linux (amd64, arm64)
- macOS (amd64, arm64)
- Windows (amd64)
- Download the binary for your OS from the Releases page.
- Make it executable and move to your PATH:
chmod +x ./ktx-<os>-<arch> mv ./ktx-<os>-<arch> ktx sudo mv ./ktx /usr/local/bin
- Or build from source (requires Go 1.18+):
git clone https://github.com/itzzjb/kubernetes-context-changer-cli.git cd kubernetes-context-changer-cli go build -o ktx sudo mv ./ktx /usr/local/bin - Run
ktxto verify installation:ktx
- Download
ktx-windows-amd64.exefrom Releases. - Rename to
ktx.exe. - Add the folder containing
ktx.exeto your systemPATH. - Run from Command Prompt or PowerShell:
ktx
Note
- You can also run the tool by double-clicking
ktx.exe, but it is designed for interactive use in a terminal. - Make sure your
KUBECONFIGenvironment variable is set if your kubeconfig is not in the default location (%USERPROFILE%\.kube\config).
Switch context interactively:
ktxList all available contexts:
ktx listSwitch to a specific context:
ktx <context-name>- By default,
ktxuses the kubeconfig at$KUBECONFIGor~/.kube/config. - To use a different kubeconfig:
ktx --kubeconfig <path-to-kubeconfig>
- macOS Security Warning:
When running
ktxfor the first time on macOS, you may see a security warning.
Caution
Apple cannot verify this app for malicious software
This is standard for open source CLI tools not distributed via the Mac App Store.
Solution:
- Right-click the
ktxbinary and choose Open. Click OK in the dialog. You only need to do this once per version. - Or, if you see a quarantine error, run:
xattr -d com.apple.quarantine ./ktx
-
Command not found: Ensure the binary is in your
PATHand is executable. -
Permission denied: Use
chmod +x ./ktxto make it executable.
Q: Does ktx modify my kubeconfig?
A: ktx only switches the current context; it does not modify or delete clusters, users, or contexts.
Q: Can I use ktx with multiple kubeconfig files?
A: Yes, set the KUBECONFIG environment variable before running ktx.
Q: Is telemetry or analytics collected?
A: No, ktx does not collect or send any telemetry data.
Pull requests and issues are welcome! Please open an issue to discuss your ideas or report bugs. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/my-feature) - Open a pull request
This project is licensed under the MIT License. See LICENSE for details.