Debugging with Kubetail


Note

For more background information, make sure to check out the demos overview page.

Kubetail is great, check out the official project page1. One of the most tedious aspects kubectl is that wildcards are not supported, and so you end up awkwardly using a lot of filtering and labels, and kubetail fixes this. Besides bundling kubetail in the toolbox, the k8s-tools suite provides some additional helpers for automation.

Source Code


For this demo, we'll just extend the FaaS demo and show how to use the logging helpers after the main setup is done. This makes the demo implementation pretty short:

Summary
#!/usr/bin/env -S make -f
#░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
# Demonstrates using kubetail directly, starting the log browser in the 
# foreground or the background, or calling kubetail programmatically.
#
# See here[1] for more discussion, here[2] for official kubetail CLI docs.
# This demo ships with the `k8s-tools` repo and runs as part of the test-suite.
#
# REF:
#   [1] https://robot-wranglers.github.io/k8s-tools/demos/kubetail
#   [2] https://www.kubetail.com/docs/cli/commands/logs
#░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

include demos/fission.mk

# Display various logs.  Usage: kubetail/<namespace>/<kind>/filter
logs.basic: kubetail/fission/deployments/* \
    kubetail/fission/jobs/* kubetail/fission/pods/*

# Faster version of the above, pass all log requests at once.
logs.alt: kubetail/fission/deployments/*,fission/jobs/*,fission/pods/*

# Directly interact with kubetail
logs.custom: k8s.dispatch/self.logs.custom 
self.logs.custom:
    kubetail --help

# Two ways to launch the kubetail web-UI for this cluster context.
serve: kubetail.serve
    @# By default, `kubetail.serve` is blocking.
    @# If you use it from `__main__`, use it at the end!

serve.bg: kubetail.serve.bg
    @# A non-blocking version is also available, but remember to 
    @# stop it, because it won't be handled by cluster shutdown.

Basic Usage


For starters just run the main functions-as-a-service demo:

$ ./demos/kubetail.mk clean create deploy
...

There's a few targets already set up. Below you can see an example of output

$ ./demos/kubetail.mk logs.basic
 kubetail.logs // fission // kind=deployments filter=* 
{
  "level": "info",
  "ts": "2025-06-04T02:15:28.227Z",
  "logger": "generic_pool_manager.pool_pod_controller",
  "caller": "poolmgr/poolpodcontroller.go:132",
  "msg": "pool pod controller handlers registered"
}

Interactive Workflows


The demo source shows how to use kubetail programmatically as task prerequisites, and how to use it directly from tasks dispatched to containers.

You can also use kubetail in tool-mode:

# show 
$ KUBECONFIG=.. ./k8s.mk kubetail/fission/deployments/*
$ KUBECONFIG=.. ./k8s.mk kubetail.serve.bg
$ KUBECONFIG=.. ./k8s.mk kubetail.serve