Set kubectl context per shell or terminal - Kubernetes

When I started to work with Kubernetes, It was a bit annoying to deal with multi clusters from CLI at the same time.

First suggestion was always kubectx. It's a nice tool that helps you to switch between clusters back and forth. But my main problem with it was that kubectx switches kubectl context globally. In other words, it changes the cluster context for all shells and terminals.

I've tried to find if someone fixed this problem before, but unfortunately I couldn't find a good enough solution for that purpose. So last year I decided to write my own simple solution for that!

No aliases, no extra custom changes, autocomplete out-of-the-box, and it doesn't matter if you work with 1 or 100 K8s clusters! If your liked kubectx/kubens probably you will like kubech!

Kubech is a tool similar to kubectx, but allows you to set kubectl contexts/namespaces per shell/terminal to manage multi Kubernetes cluster at the same time. i.e. same as kubectx but per shell/terminal.

Here are some of its features:

  • Each shell/terminal will have its own context (K8s cluster) or namespace!
  • Easy to use! Just source it in your favorite shell.
  • No aliases, no extra customizations, it doesn't matter if you work with 1 or 100 K8s clusters!
  • It still can be used along with other tools like kubectx/kubens.
  • It doesn't change anything in ~/.kube/config file. So it works perfectly with static and dynamic kube config files.
  • It supports autocomplete for contexts and namespaces.

That's it! Enjoy! ⎈

Powered by Blogger.

Hello, my name is Ahmed AbouZaid and this is my "lite" technical blog!

I'm a passionate DevOps engineer, Cloud/Kubernetes specialist, Free/Open source geek, and an author.

I believe in self CI/CD (Continuous Improvements/Development), also that "the whole is greater than the sum of its parts".

DevOps transformation, automation, data, and metrics are my preferred areas. And I like to help both businesses and people to grow.

Contact Me


Email *

Message *

Latest Post

DevOps is not only a culture - Discussion Panel

Today is my second session JobStack 2023 after my previous one yesterday titled " Platform Engineering: Manage your infrastructure u...

Popular Posts

Blog Archive