Are you tired of typing the namespace in every kubectl command? Do you keep forgetting the command for switching the kubectl context? Speed up your kubectl process with these kubectl tools! I am refering to the tools that come with kubectx.

Installation

On macOS I used brew to do the installation. The code for kubectx can be found on github here and the documentation is perfect. Please check it out for installation on another OS.

brew install kubectx

The installation unlocks a command for navigating between contexts (kubectx) and a command for navigation around namespaces (kubens).

Context

The command for switching context is not always on the top of my mind. Now I just use this intuitive command to list all my contexts (and the current):

Screenshot 2020 04 08 at 10.55.00 - KUBECTL TOOLS

To switch do this

Screenshot 2020 04 08 at 10.56.20 - KUBECTL TOOLS

And you can even go to the previous context

Screenshot 2020 04 08 at 10.57.24 - KUBECTL TOOLS

This way navigating between contexts becomes fast and easy.

Namespace

We can navigate between namespaces in pretty much the same way. We only use the command kubens instead. Here is a summary of the possibilities.

Screenshot 2020 04 08 at 10.59.32 - KUBECTL TOOLS

When switched to a specific namespace, you can omit the namespace from your kubectl command! All commands become shorter and they stay the same for all namespaces. This way the commands become much easier to reuse.

Hopefully you will install these awesome kubectl tools and speed up your kubectl process. Happy kubectling!