Need help with ktail?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

atombender
141 Stars 9 Forks MIT License 71 Commits 2 Opened issues

Description

ktail is a tool to easily tail Kubernetes logs.

Services available

!
?

Need anything else?

Contributors list

# 113,317
s3
Azure
drone-c...
codegen...
64 commits
# 158,313
Kuberne...
HTML
JavaScr...
kubectl...
2 commits
# 29,988
Go
Kuberne...
Less
Rails
1 commit
# 166,336
sed
D
sip
source-...
1 commit
# 40,352
python3
golang
github-...
penetra...
1 commit

ktail is a tool to tail Kubernetes logs. It's like

kubectl logs
, but with a bunch of features to make it more convenient.

:whitecheckmark: 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.

:whitecheckmark: Tails multiple pods and containers 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.

:whitecheckmark: All containers 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.

:whitecheckmark: Recovers from failure. ktail will keep retrying forever.

kubectl
just gives up.

Usage

Tailing based on label:

$ 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.

It's also possible to filter on pod/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.

To abort tailing, hit

Ctrl+C
.

Options

Run

ktail -h
for usage.

Templating

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 as
    Name
    ,
    Namspace
    ,
    Status
    , etc.
  • Container
    : The container object. It properties such as
    Name
    .

Installation

Homebrew

$ brew tap atombender/ktail
$ brew install atombender/ktail/ktail

Binary installation

Precompiled binaries for Windows, macOS, Linux (x64 and ARM) are available on the GitHub release page.

Linux

$ curl -L https://github.com/atombender/ktail/releases/download/v0.7.0/ktail-linux-amd64 -o ktail
$ chmod +x ktail
$ sudo mv ./ktail /usr/local/bin/ktail

macOS

$ curl -L https://github.com/atombender/ktail/releases/download/v0.7.0/ktail-darwin-amd64 -o ktail
$ chmod +x ktail
$ sudo mv ./ktail /usr/local/bin/ktail

Windows

Download from GitHub and add the binary to your

PATH
.

From source

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 .

Acknowledgements

Some setup code was borrowed from k8stail.

License

MIT license. See

LICENSE
file.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.