kubectx
Table of contents
This package provides both kubectx and kubens binaries.
kubectxis a tool to switch between contexts (clusters) on kubectl faster.kubensis a tool to switch between Kubernetes namespaces (and configure them for kubectl) easily.
Information
Source | Tracker | VCS | QA | Bugs
- Version: 0.9.5-2
- Architecture: any
- Standards-Version: 4.6.2
- Maintainer: Debian Kubernetes Packaging Team (DMD)
Releases
- 0.6.2-1 (buster )
- 0.9.3-1 (bookworm )
- 0.9.5-2 (sid | unstable )
If you are using an unlisted debian version probably that means this package it’s not available.
Installation
apt install kubectx
Completion
Both kubectx and kubens support Tab completion on bash/zsh/fish shells to help with long context names. You don’t have to remember full context names anymore.
Completions will be installed for bash, zsh and fish shells.
Usage
Here’s a kubectx demo:

And here’s a kubens demo:

Examples
# switch to another cluster that's in kubeconfig
$ kubectx minikube
Switched to context "minikube".
# switch back to previous cluster
$ kubectx -
Switched to context "oregon".
# rename context
$ kubectx dublin=gke_ahmetb_europe-west1-b_dublin
Context "gke_ahmetb_europe-west1-b_dublin" renamed to "dublin".
# change the active namespace on kubectl
$ kubens kube-system
Context "test" set.
Active namespace is "kube-system".
# go back to the previous namespace
$ kubens -
Context "test" set.
Active namespace is "default".
If you have fzf installed, you can also interactively select a context or cluster, or fuzzy-search by typing a few characters. To learn more, read interactive mode →