explaingit

ahmetb/kubectx

Analysis updated 2026-06-21

19,732GoAudience · ops devopsComplexity · 1/5Setup · easy

TLDR

Two tiny command-line tools that let you switch between Kubernetes clusters and namespaces with a single short command, instead of typing long kubectl configuration strings each time.

Mindmap

mindmap
  root((repo))
    What It Does
      Cluster switcher
      Namespace switcher
      Context renaming
    Tools Included
      kubectx
      kubens
    Features
      Tab completion
      fzf fuzzy menu
      Back button jump
    Install Methods
      Homebrew
      apt and pacman
      Krew plugin manager
    Audience
      DevOps engineers
      Platform engineers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Switch between dev, staging, and production Kubernetes clusters with a single kubectx command instead of long kubectl flags.

USE CASE 2

Jump back to the previously active cluster or namespace instantly with kubectx - or kubens -.

USE CASE 3

Use the interactive fzf menu to fuzzy-search and select from a long list of clusters or namespaces by typing a few characters.

USE CASE 4

Rename long auto-generated Kubernetes context names to short friendly aliases for faster daily use.

What is it built with?

Gofzf

How does it compare?

ahmetb/kubectxtwpayne/chezmoinats-io/nats-server
Stars19,73219,70119,781
LanguageGoGoGo
Setup difficultyeasyeasymoderate
Complexity1/52/54/5
Audienceops devopsdeveloperops devops

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

In plain English

kubectx and kubens are two small command-line tools that make it faster and less error-prone to work with Kubernetes, a platform for running containerized applications. Kubernetes organizes workloads into clusters (a group of machines running together) and namespaces (logical subdivisions within a cluster used to separate environments or teams). When managing multiple clusters or environments, for example, a development cluster, a staging cluster, and a production cluster, switching between them with the default kubectl tool involves typing long commands with full configuration details. kubectx simplifies cluster switching to a single short command. Running kubectx minikube switches to a local development cluster. Running kubectx - switches back to whichever cluster you were in before, like pressing the back button. You can also rename contexts to short friendly names, and spawn isolated read-only shells scoped to a single cluster to avoid accidentally making changes to the wrong environment. kubens does the same thing for namespaces within a cluster, switching the active namespace with a single command and allowing you to jump back to the previous one with kubens -. Both tools support Tab completion on bash, zsh, and fish shells so you never have to remember exact names. If you install fzf (a fuzzy-finder tool), both commands also gain an interactive menu where you can type a few characters to filter and select from your list of clusters or namespaces. They are written in Go and available via Homebrew, apt, pacman, Chocolatey, and other package managers, as well as through the Kubernetes plugin manager Krew.

Copy-paste prompts

Prompt 1
I manage 5 Kubernetes clusters named dev, staging, prod-us, prod-eu, and demo. Show me how to use kubectx to rename them to short aliases and switch between them.
Prompt 2
Set up Tab completion for kubectx and kubens in my zsh shell so cluster and namespace names autocomplete when I press Tab.
Prompt 3
Show me how to install kubectx and kubens on macOS with Homebrew and enable the fzf integration for interactive cluster selection.
Prompt 4
I accidentally ran a kubectl command on production instead of staging. How do I use kubectx to spawn an isolated read-only shell scoped to staging only?
Prompt 5
Install kubectx via the Krew Kubernetes plugin manager and configure it so I can switch namespaces with a single command.

Frequently asked questions

What is kubectx?

Two tiny command-line tools that let you switch between Kubernetes clusters and namespaces with a single short command, instead of typing long kubectl configuration strings each time.

What language is kubectx written in?

Mainly Go. The stack also includes Go, fzf.

How hard is kubectx to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is kubectx for?

Mainly ops devops.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub ahmetb on gitmyhub

Verify against the repo before relying on details.