Tired of repeating kubectl command lines? Simplify your life and increase your efficiency on Kubernetes
Kubernetes is a great technology to orchestrate containers and microservices. It offers a rich ecosystem with plenty of different objects and concepts to have up and running applications. kubectl
is the number 1 you learn to interact with a cluster through the command line.
Although knowing kubectl
is important you might find yourself repeating the same actions and losing time. Here, we will review 7 tools that are tenfold your efficiency when working with Kubernetes. The goal is to make you discover them and I hope after that you will adopt them. In each tool section, you will find references to the official resources to go further.
The Toolbox
1/ Kube-shell
A little help would be nice when typing kubectl commands to reduce errors and boost up your speed. kube-shell
is an integrated shell for Kubernetes CLI. It provides easy-of-user kubectl
to be more productive:
A simple line to install it:
$ pip install kube-shell
2/ Kubectx - Kubens
Are you managing multiple Kubernetes clusters? kubectx
helps you switch between clusters back and forth:
At each kubectl
command we indicate the namespace to interact with the desired resources. kubens
allows avoiding having to specify it each time:
3/ Kubetail
kubetail
aggregates logs from multiple pods into one stream. It is the as running kubectl logs -f
but for multiple pods.
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
app1-v1-aba8y 1/1 Running 0 1d
app1-v1-gc4st 1/1 Running 0 1d
app1-v1-m8acl 1/1 Running 0 6d
app1-v1-s20d0 1/1 Running 0 1d
app2-v31-9pbpn 1/1 Running 0 1d
app2-v31-q74wg 1/1 Running 0 1d
my-demo-v5-0fa8o 1/1 Running 0 3h
my-demo-v5-yhren 1/1 Running 0 2h
$ kubetail app2
You can specify the containers in the pod:
$ kubetail app2 -c container1
$ kubectail app2 -c container1 -c container2
4/ Kubetree
An application can have a lot of different resources and it is always obvious to map them. kubetree
is a kubectl
plugin to explore ownership relationships between Kubernetes objects:
$ kubectl krew install tree
5/ K9S
k9s
provides a terminal UI to interact with your Kubernetes cluster. It can be compared to the top
command for processes. You can easily navigate, observe and manage your applications with it.
What's great is that changes in Kubernetes resources appear live. It's very useful to debug what's going on. Here is a video presenting what can be done with k9s
:
6/ Kube-Capacity
kube-capacity
is a simple CLI providing an overview of the resource requests, limits, and usage in a Kubernetes cluster.
Inspect the cluster nodes:
$ kube-capacity
NODE CPU REQUESTS CPU LIMITS MEMORY REQUESTS MEMORY LIMITS
* 560m (28%) 130m (7%) 572Mi (9%) 770Mi (13%)
example-node-1 220m (22%) 10m (1%) 192Mi (6%) 360Mi (12%)
example-node-2 340m (34%) 120m (12%) 380Mi (13%) 410Mi (14%)
Now includes the pods:
$ kube-capacity --pods
NODE NAMESPACE POD CPU REQUESTS CPU LIMITS MEMORY REQUESTS MEMORY LIMITS
* * * 560m (28%) 780m (38%) 572Mi (9%) 770Mi (13%)
example-node-1 * * 220m (22%) 320m (32%) 192Mi (6%) 360Mi (12%)
example-node-1 kube-system metrics-server-lwc6z 100m (10%) 200m (20%) 100Mi (3%) 200Mi (7%)
example-node-1 kube-system coredns-7b5bcb98f8 120m (12%) 120m (12%) 92Mi (3%) 160Mi (5%)
example-node-2 * * 340m (34%) 460m (46%) 380Mi (13%) 410Mi (14%)
example-node-2 kube-system kube-proxy-3ki7 200m (20%) 280m (28%) 210Mi (7%) 210Mi (7%)
example-node-2 tiller tiller-deploy 140m (14%) 180m (18%) 170Mi (5%) 200Mi (7%)
7/ Lens
Lens is the Kubernetes IDE for monitoring and debugging. It is an application that runs on your desktop (Windows, Linux, and Mac). Perfect if you want to develop comfortably on Kubernetes:
Conclusion
These 7 tools are not exhaustive. I have presented the ones I use the most on a daily basis. I advise you to go to the link below to explore and discover others.
You will find your happiness for sure!