ETOOBUSY 🚀 minimal blogging for the impatient
K9s - Kubernetes CLI To Manage Your Clusters In Style!
K9s is an amazing software to keep in mind if you have to look around a K8s cluster (e.g. for troubleshooting reasons). From their website:
K9s provides a curses based terminal UI to interact with your Kubernetes clusters. The aim of this project is to make it easier to navigate, observe and manage your applications in the wild. K9s continually watches Kubernetes for changes and offers subsequent commands to interact with observed Kubernetes resources.
The releases page contains the latest and greatest, refer to the repository for installation instructions.
It helps that the executable is compiled as a static binary, which means that it’s a good candidate for a portable #toolbox.
When you start it, by default you see a list of Pods. Using arrows you can select one for further interactions. There are three commands that I find particularly useful:
dfor describe: if anything, this is probably the thing I like best and makes it worth installing. My usual routine for getting the description of a Pod is figure out its exact name with a
kubectl get pod, copy/paste it into
kubectl describe pod $PODand eventually realize that I got the namespace wrong. Here it’s just select the Pod and hit
d. You can move around with arrows and page-up/page-down, you can also use a few
vikeybindings (e.g. I noticed that
Ggoes to the end of the description page, which is where events are shown);
lfor logs: nothing more to say about this, logs are often invaluable for troubleshooting and quick access to them lets you keep focus;
sfor shell: it tries to
/bin/bash(if present) or
/bin/shin the Pod (letting you choose the container if you put more than one).
Pods live in different namespaces though, and you might not be looking
at the right one. K9s keeps a small key of quick-selections for the
namespace in the top part of the screen, and usually
0 means showing
all Pods in all namespaces.
If you don’t see the namespace you’re after, it’s possible to select it explicitly:
:nsand hit ENTER
- select the right namespace in the list
pto go back one step (i.e. to the Pod list)
Now you should also have a shortcut digit to select this namespace once again the future. This additional shortcut will be available from now on in the specific installation of K9s.
You can get a list of the nodes typing
:no and hit enter. No, typing
:node will not work! Which brings us to…
Using K9s I hit some edges that I would personally consider… rough:
to get a view of a specific resource type, the general way is to type
:(to enter command mode, I guess), type the name of the resource and then hit ENTER. Fact is that several times the resource names are not what you would expect, e.g. for nodes neither
nodeswill work, only
no. Hence, until your memory muscles are properly trained, you will find
when you get a new view of a resource type, a new tab appears on the bottom, showing the alias of the resource. These tabs, though, do not work as I would normally expect, i.e. there is no navigation among them. They are a stack and you can hit
pto pop to the previous, letting the current view go for good. So, don’t waste time looking for “moving across tabs” commands, there are none!
… we just scratched the surface. K9s is a very handy tool to keep around and I always keep it in my toolbox of programs I always “carry around”.