Expert GuideHow you can monitor a Kubernetes cluster from the command line with k9s

Claus Küthe — 30. April 2025
Reading time:58 minutes

Wie Sie mit k9s einen Kubernetes- Cluster aus der Kommandozeile überblicken können

With k9s, a tool is available with which pods of a
Kubernetes cluster interactively from the command line.
can be monitored from the command line.

Anyone who works with Kubernetes and microservices will be familiar with the problem: Troubleshooting from the command line is difficult and often has to be carried out across several pods and involves a lot of typing. In turn, the dashboard or alternatives may not always be available and represent a media break that means you have to switch between the console and browser more often.

To simplify things, there is a helpful little tool called k9s, which shows a simple overview of all pods and uses a similar display to top:

Zur Vereinfachung gibt es ein hilfreiches kleines Werkzeug namens k9s, das eine einfache Übersicht aller Pods zeigt und eine ähnliche Darstellung wie top nutzt
Screenshot of a terminal with k9s

As an example, a freshly started minikube is shown here in the classic 24*80 view, some of whose services have not yet been started.

Installation

k9s is available at https://k9scli.io/.

Downloads for various package managers can be found at https://github.com/derailed/k9s/releases finden. Here we have favoured a simple installation via tarball. There are also packages for all common distributions (rpm, deb). Just don't confuse arm64 and amd64 ;-)!

Usage

k9s can be started directly and without further configuration, provided that a working kubectl installation and configuration is available. If not, this must first be provided, an endeavour that would go too far at this point.

The pure start as k9s uses the namespace that is set as standard in the kubeconfig, usually default. The -n flag is used for a specific namespace: k9s -n wordpress. Alternatively, -A can also be used for all namespaces.

You then find yourself in a standard top overview, in which running containers are displayed, possibly with error messages and current status as well as other information. This is definitely helpful to get a quick overview.

Logfiles

Individual deployments/pods can be selected using the cursor keys and called up using the Enter key. There you can view the logfiles of an individual pod, again using the Enter key. If you don't want to do this, you can also select them directly from the central overview using l. If several pods are running under one deployment, all pods are summarised in one logfile.

This is one of the system's strengths: It is easy to browse using the cursor keys. By default, k9s follows the logfile. However, this behaviour can be changed with s (Toggle Autoscroll).

With "/" the output can also be searched and the lines that do not apply are directly and interactively removed.

Shell

From the overview page, you can use s to switch to the shell of a container, if it has one. This can then be exited again with exit (depending on the system).

delete & kill

Pods can be terminated ‘normally’ with CTRL+d and with CTRL+k via kill. In both cases, the pod is restarted.

Please note that in both cases the deployment is not deleted. Only the running pod is terminated and restarted.

describe

With d we get a description of a pod, just like kubectl describe does. Here too, the output is easier to handle.

forward

A function that we rarely use is the option of setting up port forwarding with SHIFT+f (i.e. the counterpart to kubectl port-forward). It is practical that k9s already suggests which port could be forwarded. An existing forwarding is displayed with Ⓕ in the PF column.

Be careful, it will be cancelled as soon as you leave k9s!

In addition to the functions discussed here, k9s offers a lot more that can be displayed with ?

Conclusion

k9s is one of those tools that is simply a joy to use and positions itself in a niche between kubectl and the dashboard (or even considerably more complex solutions such as Grafana et al). From our own experience, we can say that it has made access and troubleshooting much easier in an environment with minikube and we wouldn't want to be without it.

Andreas Wagener

Do you have questions about Kubernetes? Feel free to contact me by e-mail.

Andreas Wagener, Head of Data Protection Consulting
Phone +49 172 7619415

You were interested in this, then you may also be interested in...