An interactive command-line tool for switching between Kubernetes contexts and namespaces.
- 🎨 Colorful Interface - Easy-to-read, color-coded output using ANSI colors
- ⚡ Fast & Lightweight - Minimal dependencies, single binary
- 📋 Detailed View - See cluster and user information for each context
- 🎯 Current Context Highlight - Clearly shows your active context
- 🔄 Interactive Selection - Number-based selection for quick switching
- 🚫 Zero Dependencies - Only uses standard Go libraries and YAML parser
# Install from source
git clone https://github.com/yourusername/kc.git
cd kc
make installThen simply run:
kcDownload the latest release for your platform:
Linux (AMD64):
curl -LO https://github.com/debelio/kc/releases/latest/download/kc-linux-amd64
chmod +x kc-linux-amd64
sudo mv kc-linux-amd64 /usr/local/bin/kcLinux (ARM64):
curl -LO https://github.com/debelio/kc/releases/latest/download/kc-linux-arm64
chmod +x kc-darwin-arm64
sudo mv kc-darwin-arm64 /usr/local/bin/kcmacOS (Apple Silicon):
curl -LO https://github.com/debelio/kc/releases/latest/download/kc-darwin-arm64
chmod +x kc-darwin-arm64
sudo mv kc-darwin-arm64 /usr/local/bin/kcmacOS (Intel):
curl -LO https://github.com/debelio/kc/releases/latest/download/kc-darwin-amd64
chmod +x kc-darwin-amd64
sudo mv kc-darwin-amd64 /usr/local/bin/kc- Go 1.19 or higher (for building from source)
git clone https://github.com/debelio/kc.git
cd kc
go build -o bin/kc main.go# Build standard binary
make build
# Build optimized binary (smaller size)
make build-small
# Install to /usr/local/bin (requires sudo)
make install
# Uninstall from /usr/local/bin
make uninstallThe tool reads from your kubeconfig:
- Default location:
~/.kube/config - Custom location: Set
KUBECONFIGenvironment variable
# Use custom kubeconfig
export KUBECONFIG=/path/to/your/kubeconfig
kcSimply run kc without arguments to enter interactive mode:
kcYou can also pass arguments directly for quick context/namespace switching:
# Switch to a context
kc prod-cluster
# Switch to a context and set namespace
kc prod-cluster my-namespace
# Using flags (alternative syntax)
kc -c prod-cluster
kc -c prod-cluster -n my-namespace
# Partial context name matching
kc prod # Matches "prod-cluster" if it's the only match-c string
Context name to switch to
-n string
Namespace to set (requires -c)
# Standard build
go build -o bin/kc main.go
# Optimized build (smaller binary, ~30-50% size reduction)
go build -ldflags="-s -w" -o bin/kc main.gomake build # Build the binary
make build-small # Build optimized binary (smaller size)
make clean # Remove build artifacts
make install # Install to /usr/local/bin
make uninstall # Remove from /usr/local/bin
make run # Build and run the application
make help # Show available commands- Read kubeconfig from
~/.kube/configor$KUBECONFIG - Parse YAML to extract contexts, clusters, and users
- Display all contexts with highlighting for the current one
- Prompt user for selection via numbered input
- Update
current-contextfield in kubeconfig - Write updated configuration back to file
- gopkg.in/yaml.v3 - YAML parsing
Note: Uses built-in ANSI color codes for styling—no additional color libraries needed!
This project is licensed under the MIT License - see the LICENSE file for details.
- kubectx - The original Kubernetes context switcher (bash/shell)
- kubie - An alternative context manager (Rust)
- kubens - Namespace switcher companion to kubectx
- Inspired by kubectx
