Press "Enter" to skip to content

Tail logs from multiple pods simultaneously in Kubernetes

I’ve recently started working quite extensively with Kubernetes on Google Container Engine. But one thing that bugged me was that I couldn’t get logs from multiple pods simultaneously using the Google Cloud SDK (kubectl). This is something that you often want to do, at least if you run multiple instances of a pod behind a replication controller. This is especially true when experimenting with Kubernetes and you don’t have Kibana or similar setup (with Kubernetes 1.0 it’s not easy to get logs from multiple pods using the Google Cloud Logging interface either although this should improve in version 1.1, see here). So before the tooling catches up I decided to write a little bash script that allows you to tail multiple pods simultaneously in an easy manner. The script is called kubetail and is available at github.


First find the names of all your pods:

This will return a list looking something like this:

To tail the logs of the two “app2” pods in one go simply do:

You’ll now get the logs streamed for all pods containing “app2”.

Known issues

When you press “ctrl+c” to end the log session you may end up with errors like this:

I’m not quite sure why this happens, pull requests are welcome 🙂


  1. builder builder November 9, 2016

    very handy.. thx!

  2. sambit sambit May 28, 2017

    thank you!

  3. Prageeth warnak Prageeth warnak January 1, 2019

    I don’t see below with ctrl+c, which is great 🙂 OS=MACOS
    error: write /dev/stdout: broken pipe

  4. Taras Taras March 4, 2019

    It just tries to tail all pods in the namespace.
    Any thought what went wrong?
    kubetail -n kube-system pod1,pod2

Leave a Reply to sambit Cancel reply

Your email address will not be published. Required fields are marked *