kubectx and kubens are two command-line tools that can help to manage Kubernetes clusters and namespaces more efficiently.
kubectx is used for switching between Kubernetes contexts (clusters) faster, while kubens is used for switching between Kubernetes namespaces more easily.
This post shows how to install kubectx and kubens on Windows so they can be used from PowerShell or Command Prompt (CMD).
Cool Tip: How to connect to K8s cluster using kubectl from Windows! Read more →
Install Kubectx & Kubens on Windows
To install kubectx and kubens on Windows it is required to download the binaries from GitHub repository and save them to a directory in user’s %PATH%.
Depending on your architecture, download and unzip archives with the latest versions of kubectx and kubens for Windows from the official release page on GitHub:

Open a user’s home folder by typing %USERPROFILE% in the address bar of a “File Explorer”:

In the user’s home create a bin folder and move the kubectx.exe and kubens.exe there:

Start the environment variables editor – press the ⊞ Win keybutton to open the “Start” menu, type in envi and click on “Edit environment variables for your account”.
Cool Tip: How to install a kubectl command on Windows! Read more →
The environment variables editor can also be launched with the following command from CMD or PowerShell:
C:\> rundll32 sysdm.cpl,EditEnvironmentVariables
Add the bin folder to a Path environment variable:

After adding the bin folder to %PATH%, the kubectx and kubens commands can be executed from PowerShell or CMD:
C:\> kubens --help - sample output - USAGE: kubens : list the namespaces in the current context kubens <NAME> : change the active namespace of current context kubens - : switch to the previous namespace in this context kubens -c, --current : show the current namespace kubens -h,--help : show this message kubens -V,--version : show version C:\> kubectx --help - sample output - USAGE: kubectx : list the contexts kubectx <NAME> : switch to contextkubectx - : switch to the previous context kubectx -c, --current : show the current context name kubectx <NEW_NAME>=<NAME> : rename context to kubectx <NEW_NAME>=. : rename current-context to kubectx -u, --unset : unset the current context kubectx -d <NAME> [<NAME...>>] : delete context ('.' for current-context) (this command won't delete the user/cluster entry referenced by the context entry) kubectx -h,--help : show this message kubectx -V,--version : show version
Once installed, kubectx and kubens should accelerate Kubernetes management experience for Windows users by making it quicker and more convenient to switch between cluster environments.
Cool Tip: How to enable kubectl auto-completion in PowerShell! Read more →
Thanks for this.