Skip to main content

Installation

kubectx and kubens are available through multiple package managers and installation methods. Choose the one that works best for your system.
Starting with v0.9.0, kubectx and kubens are rewritten in Go. Download the latest binaries from the Releases page.

Kubectl Plugins (Krew)

Install as kubectl plugins using the Krew plugin manager.
1

Install with Krew

kubectl krew install ctx
2

Use as kubectl plugins

After installation, the tools are available as kubectl ctx and kubectl ns:
kubectl ctx minikube
kubectl ns kube-system
Krew installation does not include shell completion scripts. For completions, choose another installation method or install the scripts manually.

macOS Installation

Homebrew

The recommended way to install on macOS.
1

Install with Homebrew

brew install kubectx
This installs both kubectx and kubens.
2

Configure shell completion

Homebrew automatically sets up bash/zsh/fish completion scripts. Make sure your shell is configured to load Homebrew completions.

MacPorts

If you use MacPorts:
sudo port install kubectx

Linux Installation

Debian/Ubuntu (apt)

1

Install from apt repository

sudo apt install kubectx
2

Optional: Use testing/unstable repos for newer versions

Newer versions may be available in:See the Debian Wiki for information on enabling these repositories.

Arch Linux (pacman)

Available as an official Arch Linux package:
sudo pacman -S kubectx

Homebrew on Linux

If you use Homebrew on Linux:
brew install kubectx

Windows Installation

Chocolatey

Install using Chocolatey:
choco install kubens kubectx

Scoop

Install using Scoop:
1

Add the main bucket (if not already added)

scoop bucket add main
2

Install kubectx and kubens

scoop install main/kubens main/kubectx

winget

Install using winget:
winget install --id ahmetb.kubectx

Manual Installation (macOS and Linux)

For POSIX environments with Bash installed.
1

Clone the repository

sudo git clone https://github.com/ahmetb/kubectx /opt/kubectx
2

Create symlinks

sudo ln -s /opt/kubectx/kubectx /usr/local/bin/kubectx
sudo ln -s /opt/kubectx/kubens /usr/local/bin/kubens
3

Make scripts executable

sudo chmod +x /opt/kubectx/kubectx /opt/kubectx/kubens

Shell Completion Setup

After manual installation, set up completion scripts for your shell:
mkdir -p ~/.oh-my-zsh/custom/completions
chmod -R 755 ~/.oh-my-zsh/custom/completions
ln -s /opt/kubectx/completion/_kubectx.zsh ~/.oh-my-zsh/custom/completions/_kubectx.zsh
ln -s /opt/kubectx/completion/_kubens.zsh ~/.oh-my-zsh/custom/completions/_kubens.zsh
echo "fpath=($ZSH/custom/completions $fpath)" >> ~/.zshrc
If zsh completion doesn’t work, add autoload -U compinit && compinit to your .zshrc.

Interactive Mode with fzf

For interactive fuzzy search, install fzf:
brew install fzf
To opt out of fzf interactive mode, set the environment variable: KUBECTX_IGNORE_FZF=1

Verify Installation

After installation, verify both tools are available:
kubectx --help
kubens --help

Next Steps

kubectx Usage

Learn how to use kubectx to manage contexts

kubens Usage

Learn how to use kubens to manage namespaces

Build docs developers (and LLMs) love