
Manage Kubernetes clusters
Introduction
As the popularity of Kubernetes grows, so does its complexity. Amazing open source community and healthy vendor ecosystem rush to provide tools and services around cluster management, development, testing, security and many more.
In this article, we are going to focus on command-line based tools and plugins to help you with cluster management, observability, administration and regular day to day activities.
The requirement is that all tools and plugins must be:
- open-source
- command-line based
- easy to install
- bring tangible benefits to your Kubernetes workflow
#1 Kubectl krew plugin manager
Kubernetes plugin manager
Source & Installation:
Krew can be installed using git/curl. Just copy and paste the install command
How it works:
Krew integrates with kubectl CLI and provides a mechanism to install additional command-line tools as plugins. As of the time, this article was written, there are 149 plugins available.
How to use it:
To get the best of krew plugin manager, you need to discover what plugins are useful for you and install them via krew. Then it’s just a simple matter of running kubectl plugin-name -options
Here is a list of plugins I use often:

Benefits:
Krew provides a one-stop-shop for discovering and managing plugins, making it much easier to add new tools to improve your Kubernetes workflow.
#2 Kubectx and Kubens
Those are actually two separate tools, but they are used in a single workflow most of the time, so I’m listing them together.
Source & Installation:
Install via krew kubectl krew install ns
& kubectl krew install ctx
or standalone/package installs:
How it works:
Both plugins are written in Go and modify kubeconfig switching to a new context or namespace.
How to use it:
For the best experience, use both plugins in an interactive mode. This mode requires installing fzf and enables selecting contexts with cursors instead of copy/paste.
Here is how it works with my contexts:
Benefits:
The biggest benefit of having those tools it by not having to type out commands. Those tools are a must-have!
#3 Kube-ps1
This plugin works great in combination with kubectx and kubens. Once you swap to a different context/namespace, how do you know where you are?
Well, kube-ps1 does exactly that.
Source & Installation:
Standalone & package install. This plugin is not available on Windows.
How it works:
Kube-ps1 changes your prompt to contain information about the current context and namespace.
How to use it:
After installing kube-ps1, add the code snippet to your shell (bash/zsh/fish). Kube-ps1 can be switched off by kubeoff
command and back on using kubeon.
Here is a flow with kubectx, kubens and kube-ps1:
Benefits:
With kube-ps1, it is easier to avoid confusion and possible mistakes, as we always know what context and namespace we are in.
#4 Stream logs with kail
It is possible to stream logs of all pods belonging to deployment, but it’s is much harder to stream all logs or stream logs based on query criteria. Kail solves this problem
Source & Installation:
Install via krew kubectl krew install tail
or standalone/package installs:
How it works:
Kail can stream logs of pods based on different matching criteria, for example, all pods that are selected by a service or all pods matching arbitrary labels.
How to use it:
It’s good to have a dedicated window/panel open with kail logs matching your criteria. Here is a flow with 2 windows split:
Benefits:
With kail, it is much easier to stream logs and see in real-time logs depending on your selection criteria.
#5 K9s — Kubernetes CLI To Manage Your Clusters In Style!
Last, but certainly not least, my favourite tool, k9s. It is a fully-fledged command-line based CLI to manage and observe your Kubernetes clusters
Source & Installation:
K9s has a lot of installation options and is also available on Windows. Get it from the git repo:
How it works:
K9s is a CLI tool that uses your terminal to display information about a cluster you are currently on, it also enables other more advanced features like port forwarding, viewing YAML of Kubernetes objects and much more.
How to use it:
Simply type k9s and you will see the UI in action.
Here is a workflow involving all the tools and plugins mentioned so far. Here I’m using WSL2 on Windows 10, splitting my terminal window into 3 panes using a keyboard shortcut. I use kail to show logs of the nginx pod I created on a right lower pane. After a while, I use k9s to port forward my local port 8080 into an nginx container port 80 and interact with it using curl from my bottom left panel. All while kail displays logs.
Benefits:
K9s empowers me to quickly move through a cluster, use all kubectl features and much more. One thing to mention is that although k9s provides features that enable you to change resources on your cluster, this should only be done on a test/dev cluster.
The best way to interact with a production cluster(s) is by using GitOps principles and tools. Check out my recent blog GitOps with Kubernetes if you would like to learn more.
Conclusion
We have seen how a typical Kubernetes workflow can be significantly improved by using just 5 plugins and tools. As you noticed, the tools are geared towards cluster administration, there is another set of tools aimed at developers. More on this in the next blog!
You could install all those tools easily on your local machine, but it is also possible to run kubectl with all those tools (and a few more) using Docker. I have created a highly customized docker image with all those tools, so no need to install those locally.
Are there any other CLI tools I haven’t mentioned that you are using daily? Let us know in the comments.