Skip to main content

kubectx + kubens: Power tools for kubectl

Faster way to switch between clusters and namespaces in kubectl.

kubectx

Switch between Kubernetes contexts (clusters) quickly

kubens

Switch between Kubernetes namespaces effortlessly

What are kubectx and kubens?

kubectx is a tool to switch between contexts (clusters) on kubectl faster. kubens is a tool to switch between Kubernetes namespaces (and configure them for kubectl) easily. Both tools support:
  • Tab completion on bash/zsh/fish shells
  • Interactive mode with fzf for fuzzy searching
  • Quick switching back to previous context/namespace with -
  • Color-coded output for current context/namespace

Quick Examples

kubectx Examples

$ kubectx minikube
Switched to context "minikube".

kubens Examples

$ kubens kube-system
Context "test" set.
Active namespace is "kube-system".

Key Features

Interactive Mode

Install fzf for interactive fuzzy search of contexts and namespaces

Shell Completion

Tab completion support for bash, zsh, and fish shells

Previous Selection

Quickly switch back to your previous context or namespace with -

Customizable Colors

Customize output colors with environment variables
Both tools are available as bash scripts and Go binaries. Starting with v0.9.0, the Go implementation is actively developed with new features.

Implementation

kubectx and kubens are available in two implementations:
  • Bash scripts: Stable, lightweight scripts included in the repository
  • Go binaries: Rewritten in Go (v0.9.0+) with new features and improvements
Both implementations work the same way, and the bash-based versions will continue to be maintained.

Next Steps

Installation

Get started with kubectx and kubens on your platform

Usage Guide

Learn all the ways to use kubectx and kubens
Pair kubectx and kubens with kube-ps1 to add context/namespace information to your shell prompt.

Build docs developers (and LLMs) love