✅ Detects pods and containers as they come and go. If you run ktail foo
and later start a pod or container named foo
, then it will be picked up automatically. kubectl
only works on a running pod/container.
✅ Tails multiple pods and containers in multiple namespaces at the same time, based on names and labels. kubectl
can only tail a single pod and container. ktail will match the pattern or patterns you specify against both the pod name and the container name.
✅ All containers in a pod are tailed by default, not just a specific one. With kubectl
, you have to use -c
. With ktail, just do ktail foo
and all its containers are automatically tailed.
✅ Recovers from failure. ktail will keep retrying forever. kubectl
often just gives up.
✅ Better formatting. ktail will show log lines in different colours, and has syntax highlighting of JSON payloads.
ktail makes it super easy to tail by pod or container name. The following will match all containers whose pod name or container name contains the substring foo
:
$ ktail foo
The arguments are regular expressions, so this is possible:
$ ktail '^foo'
If no filters are specified, all pods in the current namespace are tailed.
Tailing supports the usual things like labels:
$ ktail -l app=myapp
This will tail all containers in all pods matching the label app=myapp
. As new pods are created, it will also automatically tail those, too.
To abort tailing, hit Ctrl+C
.
Run ktail -h
for usage.
Ktail will read the file $HOME/.config/ktail/config.yml
if it exists. This must be a file in YAML format. The following options can be set (these are the defaults):
noColor: false
raw: false
timestamps: false
quiet: false
colorScheme: bw
colorMode: auto
kubeConfigPath: ""
templateString: ""
ktail has a basic output format. To override, you can use a simple Go template. For example:
$ ktail -t "{{.Container.Name}} {{.Message}}"
The following variables are available:
Timestamp
: The time of the log event.Message
: The log message.Pod
: The pod object. It has properties such asName
,Namespace
,Status
, etc.Container
: The container object. It has properties such asName
.
$ brew tap atombender/ktail
$ brew install atombender/ktail/ktail
Precompiled binaries for Windows, macOS, Linux (x64 and ARM) are available on the GitHub release page.
This requires Go >= 1.10, as we use Go modules.
$ mkdir -p $GOPATH/src/github.com/atombender
$ cd $GOPATH/src/github.com/atombender
$ git clone https://github.com/atombender/ktail
$ cd ktail
$ go install .
Some setup code was borrowed from k8stail.
MIT license. See LICENSE
file.