kubectx
Command-line tools for switching kubectl contexts (clusters) and Kubernetes namespaces, with optional isolated or read-only shells.
Tested on Linux
Use it
Linux x86_64
You need first
- System packages:
kubectl,fzf (optional, for interactive mode)
Download v0.11.0 kubectx and kubens release binaries into ~/.local/bin
cd /tmp && curl -fsSLO https://github.com/ahmetb/kubectx/releases/download/v0.11.0/kubectx_v0.11.0_linux_x86_64.tar.gz && curl -fsSLO https://github.com/ahmetb/kubectx/releases/download/v0.11.0/kubens_v0.11.0_linux_x86_64.tar.gz && tar xzf kubectx_v0.11.0_linux_x86_64.tar.gz kubectx && tar xzf kubens_v0.11.0_linux_x86_64.tar.gz kubens && install -m755 kubectx kubens ~/.local/bin/Install kubectl v1.37.2 (README prerequisite, needed for kubectx -s)
curl -fsSLo /tmp/kubectl https://dl.k8s.io/release/v1.37.2/bin/linux/amd64/kubectl && install -m755 /tmp/kubectl ~/.local/bin/kubectl
Check that it works
kubectx --versionThe output should contain “0.11.0”.
First thing to try
mkdir -p ~/.kube && cat > ~/.kube/config <<'EOF'
apiVersion: v1
kind: Config
clusters:
- name: c1
cluster:
server: https://127.0.0.1:6443
- name: c2
cluster:
server: https://127.0.0.1:6444
users:
- name: u1
user:
token: dummy
contexts:
- name: minikube
context:
cluster: c1
user: u1
- name: oregon
context:
cluster: c2
user: u1
- name: test
context:
cluster: c1
user: u1
current-context: oregon
EOFkubectx minikube && kubectx - && KUBECTX_IGNORE_FZF=1 kubectxRun kubectx to list your kubectl contexts, or kubens to work with namespaces.
What it does
- Switch between kubectl contextsTested
How to use it
- Run
kubectx <context>to switch to another context. - Run
kubectx -to go back to the previous context. - Run
KUBECTX_IGNORE_FZF=1 kubectxto list all contexts.
- Run
- Switch Kubernetes namespacesTested
How to use it
- Run
kubens <namespace> -fto set the active namespace, even if it does not exist yet.
- Run
- Open read-only or isolated shellsTested
How to use it
- Run
kubectx -s <context>to open a shell where only that context is active. - Type
exitto leave the isolated shell.
- Run
- Search contexts interactively with fzfNot tested
How far pickfit got
Linux x86_64
- Installs
- Starts
- 3 of 4 features work
- Works offline
macOS and Windows: the project says it runs there; pickfit hasn’t tried it.
Good for
- switch kubectl to another cluster context
- change the active Kubernetes namespace
- open a read-only shell that blocks cluster writes
- rename a kubeconfig context
How pickfit tested it
Each run starts from a clean machine and follows the steps above. How pickfit verifies
Linux x86_64
Its main function works
- Replayed from scratch
- Works offline
- Checked on 15 Nov 2026
- Version 0.11.0
Differences the test machine hit
- README: sudo apt install kubectx / sudo pacman -S kubectx / kubectl krew install ctx
In the test: No sudo or krew in this box; used the README's alternative: release binaries from GitHub Releases put on PATH - README: kubectx -s minikube (kubectl listed as a prerequisite)
In the test: kubectl must be on PATH for -s; without it: 'error: kubectl is required for --shell but was not found in PATH'. Context/namespace switching with -f works without kubectl - README: $ kubectx -s minikube starts an interactive shell
In the test: With no TTY, SHELL was pointed at a small script so the isolated shell ran non-interactively