A simple command-line tool for managing Kubernetes contexts with a clean table interface. Perfect for servers and bastion hosts where you need to manage many contexts - no need to remember complex context names, just use numbers to switch between them quickly.
- List all available Kubernetes contexts in a formatted table
- Switch between contexts by number
- Check cluster reachability status
- Clean, intuitive interface with emojis
- Perfect for servers and bastion hosts with many contexts
- Number-based switching - no need to remember complex context names
- Go to the Releases page
- Download the appropriate binary for your platform:
cs-linux-amd64- Linux x86_64cs-linux-arm64- Linux ARM64cs-darwin-amd64- macOS Intelcs-darwin-arm64- macOS Apple Siliconcs-windows-amd64.exe- Windows x86_64cs-windows-arm64.exe- Windows ARM64
- Make the binary executable and move it to your PATH:
# For Linux/macOS
chmod +x cs-linux-amd64
sudo mv cs-linux-amd64 /usr/local/bin/cs
# For Windows
# Move cs-windows-amd64.exe to a directory in your PATH# Clone the repository
git clone https://github.com/hlebkanonik/k8s-context-switcher.git
cd k8s-context-switcher
# Build the binary
make build
# Install to /usr/local/bin
make install# Build
go build -o cs .
# Install (requires sudo)
sudo cp cs /usr/local/bin/cs getThis will display a table with the following columns:
#: Context number (1, 2, 3, etc.)NAME: Context name (dynamically sized to fit the longest name)CLUSTER: Cluster name (dynamically sized)AUTHINFO: Authentication info name (dynamically sized)STATUS: Reachability status (✅ for reachable, ❌ for unreachable)
The currently active context is highlighted with a green background.
Dynamic Sizing: The table automatically adjusts column widths based on:
- The longest content in each column
- Your terminal window width
- Optimal space distribution for readability
Perfect for Servers & Bastions: When working on servers or bastion hosts with many Kubernetes contexts, you don't need to remember complex context names like arn:aws:eks:eu-central-1:123456789:cluster/production-cluster. Just use cs 1, cs 2, etc. to switch between them quickly!
cs 1 # Switch to context #1
cs 2 # Switch to context #2
cs 3 # Switch to context #3cs help┌────┬──────────────┬──────────────────────┬──────────────────────┬──────────┐
│ # │ NAME │ CLUSTER │ AUTHINFO │ STATUS │
├────┼──────────────┼──────────────────────┼──────────────────────┼──────────┤
│ 1 │ minikube │ minikube │ minikube │ ✅ │
│ 2 │ docker-desk │ docker-desktop │ docker-desktop │ ❌ │
│ 3 │ production │ prod-cluster │ prod-user │ ✅ │
└────┴──────────────┴──────────────────────┴──────────────────────┴──────────┘
Note: The currently active context is highlighted with a green background.
- Go 1.21 or later
- Valid kubeconfig file (usually at
~/.kube/config) - Access to Kubernetes clusters for reachability testing
The tool reads from the standard kubeconfig location:
~/.kube/config(default)- Or the path specified in the
KUBECONFIGenvironment variable
# Build the binary
make build
# Run tests
make test
# Clean build artifacts
make cleanContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.
