Tuesday, 5 May 2020

Kubectx and Kubens, two tools you can't live without.


Kubectx and kubens are two tools to be added to kubectl to manage multiple clusters/contexts and namespaces.

Installation on MacOS:

brew install kubectx

For other OS, please refer to: https://kubectx.dev


Kubectx.
Helps you switch between clusters in a fast way:

Show the list of contexts of your .kube/config:

kubectx
k8s-context1
k8s-context2
k8s-context3


Set the context for all subsequent commands:

kubectx k8s-context2



Switch to the previous context

kubectx -


Show the current context name:

kubectx -c


Rename context k8s-context2 to k8s2:

kubectx k8s2=k8s-context2


Rename current-context to k8s2:

kubectx k8s2=.


Delete context k8s-context3:

kubectx -d k8s-context3




Kubens.
Allows you to easily switch between Kubernetes namespaces.

List the namespaces in the current context:

kubens

application-system-prod
application-system-dev
ci-cd
concourse-cicd-main
default


Change the active namespace of current context:

kubens ci-cd


Switch to the previous namespace in this context:

kubens -


Show the current namespace:

kubens -c



No comments:

Post a Comment