explaingit

ahmetb/kubectx

📈 Trending19,747GoAudience · ops devopsComplexity · 2/5ActiveLicenseSetup · easy

TLDR

Fast command-line tools to switch between Kubernetes clusters and namespaces without typing long commands.

Mindmap

mindmap
  root((kubectx))
    What it does
      Switch clusters instantly
      Switch namespaces instantly
      Jump back to previous
      Rename contexts
    Features
      Tab completion
      Interactive fuzzy menu
      Read-only shells
      Multiple package managers
    Use cases
      Manage dev staging prod
      Avoid wrong environment
      Speed up daily workflow
      Team environment access
    Tech stack
      Go
      Bash Zsh Fish
      fzf optional

Things people build with this

USE CASE 1

Switch between development, staging, and production Kubernetes clusters without typing long configuration commands.

USE CASE 2

Jump to a different namespace within a cluster and back with a single short command.

USE CASE 3

Use interactive fuzzy-finder menu to quickly select from dozens of clusters or namespaces by typing a few characters.

USE CASE 4

Spawn isolated read-only shells scoped to a single cluster to prevent accidental changes to the wrong environment.

Tech stack

GoBashZshFish

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

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
How do I install kubectx and kubens on my Mac, and what's the quickest way to switch between my Kubernetes clusters?
Prompt 2
Show me how to set up tab completion for kubectx in my zsh shell so I can autocomplete cluster names.
Prompt 3
How do I use kubectx with fzf to get an interactive menu for selecting clusters instead of typing names?
Prompt 4
What's the command to switch back to my previous Kubernetes cluster, and how do I rename a context to something shorter?
Prompt 5
How do I use kubens to switch namespaces and what does the kubens - command do?
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.