How to use kail to view logs in Kubernetes

Man working at night coding and pointing on a screen with a pen
Reading Time: 3 minutes

Hello Readers!! In this blog, we are going to see a new tool i.e Kail. We will see how we can use kail to view logs in Kubernetes. Frequently we use the kubectl command for looking at the logs of pods in Kubernetes. But it is not resilient to use when we want to see the logs from multiple pods. So, here is a very simple tool for you that we can use to view logs from multiple pods in Kubernetes at the same time and in a single window.How to use kail to view logs in Kubernetes

So, let’s get started!

Installation:

Following is the GitHub repository for kail we can download it from here.

https://github.com/boz/kail

Run these commands for installing kail on your local:

$  wget https://github.com/boz/kail/releases/download/v0.15.0/kail_0.15.0_linux_amd64.tar.gz 
install kail
$ tar zxf kail_0.15.0_linux_amd64.tar.gz
$ sudo mv kail /usr/local/bin
which kail

My kail is all set and ready to play.

How to use Kail:

Let’s start playing with it. I will type only a single word in my terminal and it will show me the logs of all the pods that are running in my cluster.

$ kail

You can see below its showing the logs of all running pods:

kail command

We can see all the kail commands that we will use further:

$ kail –help
kail --help

If we want to see the log of any particular pod inside my container we can do this by running the following command:

$ kail -p <pod_name>
kail cmd

When we want to see the logs of all the pods that are running in a particular namespace then we have to use:

$ kail -n <namespace>
kail ns

What if we want to see the logs of the last 10 minutes? Kail also provides this option let’s see:

$ kail -p <pod_name> –since <time>
kail cmd
$ kail -n <namespace> –since <time>
kail ns

If you want to see the logs of the container that has a particular label then use this command:

$  kail -l <label> --since <time>

If you want to see the logs of all the pods running inside a node then run the following command:

$ kail –node <node_name>
kail node

If you want to see the logs of any particular deployment you can use this command:

$  kail --deploy <deployment_name> --since <time>
kail deploy

For service:

$ kail –svc <service_name>

Similarly for containers, you can see it by:

$ kail –containers <container_name>

So, if you want to use more commands, then you can easily do it. It is really so simple to use. It’s a very easy way to visualize all your kubernetes objects. 

Conclusion:

Thank you for sticking to the end. In this blog, we have seen how to use kail to view logs in Kubernetes. If you like this blog, please show your appreciation by giving thumbs-ups and share this blog and give me suggestions on how I can improve my future posts to suit your needs.

HAPPY LEARNING!

Written by 

Naincy Kumari is a DevOps Consultant at Knoldus Inc. She is always ready to learn new technologies and tools. She loves painting and dancing.