Follow

INFO: Install Kubectx and Kubens Powertools for Kubectl

Applies To:

Any Kubernetes environment

Summary:

kubectx is a power tool to switch between kubernetes clusters with ease as well as a utility to manage and switch between kubectl contexts

Kubens is a power tool that allows for ease of switching between namespaces

These power tools come in handy when navigating your clusters and namespaces. 

 

More Information:

You can find download instructions for kubectx and kubens here:

https://github.com/ahmetb/kubectx

Kubens

When working within kubernetes, there are a few tools that can assist you in your overall navigation of your clusters and namespaces.

For example, you can create as many namespaces as you would like within a cluster. Kubens allows you to change from the default namespace as your active namespace, to your desired namespace.

Example:

You can see on first startup of my kubernetes environment, that I'm configured to use the "minikube" cluster and "default" namespace by default.

Screen_Shot_2021-11-11_at_11.43.19_AM.png

I have many different namespaces to work within. In this example, I have created my certificate resources and TPP issuer in the "cert-manager" namespace:

Screen_Shot_2021-11-11_at_11.46.04_AM.png

Above you can see my default namespace is selected. I can use Kubens to switch to my cert-manager namespace:

Screen_Shot_2021-11-11_at_11.47.21_AM.png

This acts as a shortcut to allow me to not have to specify my namespace in each of my commands. Instead, kubernetes knows I am now choosing to work within my cert-manager namespace

 

Example: Difference between looking at resources from the active namespace using kubens vs. not switching the namespace and having to specify namespace in every command:

Screen_Shot_2021-11-11_at_11.49.35_AM.png

Screen_Shot_2021-11-11_at_11.50.18_AM.png

The difference between these two are in the commands

kubectl get pods
kubectl get pods -n kube-system

As the complexity of your environment grows and the commands become more involved, you can see how specifying the namespace can become a very cumbersome affair.

 

Kubectx

The same general functionality exists with kubectx for switching between clusters.

please refer to their github for usage and download instructions

 

 

Was this article helpful?
0 out of 0 found this helpful

Comments