search by tags

for the user

adventures into the land of the command line

kns & ktx

so i’ve recently been introduced to something called kns. it’s pretty cool in that it allows you to not have to type

$ kubectl get pods -n my-groovy-namespace

you can just do a

$ kns
(use the up/down arrows to choose the namespace)
$ kubectl get pods

et voila. but that in itself is not really that interesting. the thing i actually really like about it is something else that it also does called:

$ ktx

it’s a kubernetes context switcher. say you have multiple kubernetes clusters, you can switch between them using the same up/down arrow selection as with kns.

maybe in the past you would have different config files in your ~/.kube directory and then do something like

$ export KUBECONFIG=~/.kube/cluster-1
$ export KUBECONFIG=~/.kube/cluster-2

with ktx, you need to make sure your ~/.kube/config file is correctly formatted to contain all the different k8s clusters that you are managing. after that, switching between clusters becomes as easy as typing ktx and using the up/down arrow keys.

on top of this groovy tool, if you are also using this kubernetic desktop client, rather than the normal angular dashboard gui per cluster, when you switch clusters with ktx, the kubernetic client auto refreshes with the new cluster information.

i like it!