• Stars
    star
    272
  • Rank 151,235 (Top 3 %)
  • Language
    Go
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A tool to easily tail Kubernetes container logs

ktail is a tool to tail Kubernetes containers

It's like kubectl logs, but with a bunch of nice features

Terminal animation

βœ… 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.

Usage

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.

Options

Run ktail -h for usage.

Configuration

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: ""

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, Namespace, Status, etc.
  • Container: The container object. It has 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.

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.

More Repositories

1

sublime_text_alternative_autocompletion

Adds TextMate-like autocompletion to Sublime Text 2 and 3.
Python
147
star
2

keywurl

Keywurl only supports Safari 4.x and earlier and is therefore deprecated.
Objective-C
86
star
3

mongrel_proctitle

This is a simple module which changes Mongrel's process title to reflect what it's currently doing. You can then determine a given Mongrel server's status using "ps".
Ruby
24
star
4

ruby-hdfs

Native Ruby bindings to Hadoop's libhdfs, for interacting with Hadoop DFS.
C
16
star
5

backbone-jquery-collectionview

Generic, reusable view that provides automatic view management and mouse drag/drop.
8
star
6

bysykkel

A tiny JavaScript app to get real-time map of Oslo bike sharing status
JavaScript
8
star
7

k8s-config-controller

A simple helper application for Kubernetes that is designed to reload an application whenever its configmap changes.
Go
5
star
8

go-diff

Go library for line-based diffing.
Go
4
star
9

jlf

jlf is a basic JSON line formatter
Go
3
star
10

prompt

Prompt is an exporter for Prometheus that spawns a set of registered exporters on demand as subprocesses.
Go
2
star
11

gce-metadata-exporter

Exporter for Prometheus that collects metadata from Google Compute Engine.
Go
2
star
12

foil

Foil is a fast, simple WebDAV proxy written in Ruby
Ruby
2
star
13

pfinn

Simple Finn.no scraper and Pinterest-like frontend, written in Haskell.
Haskell
1
star
14

hackernews_feed_generator

Generates a properly formatted feed for Hacker News (news.ycombinator.com)
Ruby
1
star
15

homebrew-ktail

Homebrew formula for ktail.
Ruby
1
star
16

yardbird

Yardbird produces REST API documentation in Markdown format, via Yardoc comments in Ruby code.
Ruby
1
star