MCPcopy Index your code
hub / github.com/boz/kail

github.com/boz/kail @v0.17.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.17.4 ↗ · + Follow
152 symbols 370 edges 14 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

kail: kubernetes tail Build Status

Kubernetes tail. Streams logs from all containers of all matched pods. Match pods by service, replicaset, deployment, and others. Adjusts to a changing cluster - pods are added and removed from logging as they fall in or out of the selection.

asciicast

Usage

With no arguments, kail matches all pods in the cluster. You can control the matching pods with arguments which select pods based on various criteria.

All flags can be set by an environment variable - KAIL_POD=foo kail is the same as kail --pod foo.

Selectors

Flag Selection
-l, --label LABEL-SELECTOR match pods based on a standard label selector
-p, --pod NAME match pods by name
-n, --ns NAMESPACE-NAME match pods in the given namespace
--svc NAME match pods belonging to the given service
--rc NAME match pods belonging to the given replication controller
--rs NAME match pods belonging to the given replica set
-d, --deploy NAME match pods belonging to the given deployment
--sts NAME match pods belonging to the given statefulset
-j, --job NAME match pods belonging to the given job
--node NODE-NAME match pods running on the given node
--ing NAME match pods belonging to services targeted by the given ingress
-c, --containers CONTAINER-NAME restrict which containers logs are shown for
--ignore LABEL-SELECTOR Ignore pods that the selector matches. (default: kail.ignore=true)
--current-ns Match pods in the namespace specified in Kubernetes' "current context"
--ignore-ns NAME Ignore pods in the given namespaces. Overridden by --ns, --current-ns. (default: kube-system)

Name Selection

When selecting objects by NAME (--svc, --pod, etc...), you can either qualify it with a namespace to restrict the selection to the given namespace, or select across all namespaces by giving just the object name.

Example:

# match pods belonging to a replicaset named 'workers' in any namespace.
$ kail --rs workers

# match pods belonging to the replicaset named 'workers' only in the 'staging' namespace
$ kail --rs staging/workers

Combining Selectors

If the same flag is used more than once, the selectors for that flag are "OR"ed together.

# match pods belonging to a replicaset named "workers" or "db"
$ kail --rs workers --rs db

Different flags are "AND"ed together:

# match pods belonging to both the service "frontend" and the deployment "webapp"
$ kail --svc frontend --deploy webapp

Other Flags

Flag Description
-h, --help Display help and usage
--context CONTEXT-NAME Use the given Kubernetes context
--dry-run Print initial matched pods and exit
--log-level LEVEL Set the logging level (default: error)
--log-file PATH Write output to PATH (default: /dev/stderr)
--since DURATION Display logs as old as given duration. Ex: 5s, 2m, 1.5h or 2h45m (defaults: 1s). See here for more information on the duration format.
-o, --output You can choose to display logs in default, raw (without prefix), json, pretty json and zerolog formats.

Installing

Homebrew

$ brew tap boz/repo
$ brew install boz/repo/kail

Krew

$ kubectl krew install tail
$ kubectl tail -h

Downloading

Kail binaries for Linux and OSX can be found on the latest release page. Download and install into your $GOPATH/bin.

Running in a cluster with kubectl

The docker image abozanich/kail is available for running kail from within a kubernetes pod via kubectl.

Note: be sure to include the kail.ignore=true label, otherwise... it's logging all the way down.

Example:

# match all pods - synonymous with 'kail' from the command line
$ kubectl run -it --rm -l kail.ignore=true --restart=Never --image=abozanich/kail kail

# match pods belonging to service 'api' in any namespace - synonymous with 'kail --svc api'
$ kubectl run -it --rm -l kail.ignore=true --restart=Never --image=abozanich/kail kail -- --svc api

Building

Install build and dev dependencies

Install source code and golang dependencies

$ go get -d github.com/boz/kail
$ cd $GOPATH/src/github.com/boz/kail
$ make install-deps

Build binary

$ make

Install run against a demo cluster

$ minikube start
$ ./_example/demo.sh start
$ ./kail

# install image into minikube and run via kubectl
$ make image-minikube
$ kubectl run -it --rm -l kail.ignore=true --restart=Never --image=kail kail

Stress testing

Start minikube with a fair amount of CPU and memory.

$ minikube start --cpus 4 --memory 8192

Start stress.yml resources.

$ kubectl create -f _example/stress.yml

Wait a while for the pods to run

$ kubectl get pods --namespace stress | grep Running | wc -l
100

Run kail

./kail --ns stress

Extension points exported contracts — how you extend this code

Writer (Interface)
(no doc) [4 implementers]
writers/writer.go
ContainerFilter (Interface)
(no doc) [1 implementers]
filter.go
DSBuilder (Interface)
(no doc) [1 implementers]
ds_builder.go
Controller (Interface)
(no doc) [1 implementers]
controller.go
DS (Interface)
(no doc) [1 implementers]
ds.go
EventSource (Interface)
(no doc) [1 implementers]
util.go
Event (Interface)
(no doc) [1 implementers]
util.go

Core symbols most depended-on inside this repo

closeAll
called by 35
ds.go
Log
called by 12
util.go
process
called by 11
buffer.go
String
called by 10
util.go
Source
called by 9
util.go
parseIds
called by 9
cmd/kail/main.go
Namespace
called by 8
util.go
Done
called by 7
ds.go

Shape

Method 99
Function 27
Struct 13
Interface 10
TypeAlias 3

Languages

Go100%

Modules by API surface

ds_builder.go35 symbols
ds.go19 symbols
util.go18 symbols
controller.go16 symbols
monitor.go13 symbols
cmd/kail/main.go12 symbols
filter.go11 symbols
writers/zerolog.go5 symbols
writers/json.go5 symbols
writers/default.go5 symbols
buffer.go5 symbols
writers/raw.go4 symbols

For agents

$ claude mcp add kail \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page