kail

package module
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2017 License: MIT Imports: 22 Imported by: 0

README

kail: kubernetes tail Build Status

Kubernetes tail. Streams logs from all containers of all matched pods.

asciicast

Kail reacts to a changing cluster and will pick up any new matching pods that are created. Logs from pods that fall out of selection are removed from the output while the rest continue.

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.

Flag Selection
--label LABEL-SELECTOR match pods based on a standard label selector
--pod NAME match pods by name
--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
--deploy NAME match pods belonging to the given deployment
--node NODE-NAME match pods running on the given node
--containers CONTAINER-NAME restrict which containers logs are shown for
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

Installing

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

Kail binaries for Linux and OSX can be found on the latest release page.

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerFilter added in v0.2.0

type ContainerFilter interface {
	Accept(cs v1.ContainerStatus) bool
}

func NewContainerFilter added in v0.2.0

func NewContainerFilter(names []string) ContainerFilter

type Controller

type Controller interface {
	Events() <-chan Event
	Close()
	Done() <-chan struct{}
}

func NewController

func NewController(
	ctx context.Context,
	cs kubernetes.Interface,
	pcontroller pod.Controller,
	filter ContainerFilter) (Controller, error)

type DS

type DS interface {
	Pods() pod.Controller
	Ready() <-chan struct{}
	Done() <-chan struct{}
	Close()
}

type DSBuilder

type DSBuilder interface {
	WithIgnore(selectors ...labels.Selector) DSBuilder
	WithSelectors(selectors ...labels.Selector) DSBuilder
	WithPods(id ...nsname.NSName) DSBuilder
	WithNamespace(name ...string) DSBuilder
	WithService(id ...nsname.NSName) DSBuilder
	WithNode(name ...string) DSBuilder
	WithRC(id ...nsname.NSName) DSBuilder
	WithRS(id ...nsname.NSName) DSBuilder
	WithDS(id ...nsname.NSName) DSBuilder
	WithDeployment(id ...nsname.NSName) DSBuilder

	Create(ctx context.Context, cs kubernetes.Interface) (DS, error)
}

func NewDSBuilder

func NewDSBuilder() DSBuilder

type Event

type Event interface {
	Source() EventSource
	Log() []byte
}

type EventSource

type EventSource interface {
	Namespace() string
	Name() string
	Container() string
	Node() string
}

type Writer

type Writer interface {
	Print(event Event) error
	Fprint(w io.Writer, event Event) error
}

func NewWriter

func NewWriter(out io.Writer) Writer

Directories

Path Synopsis
cmd
kail command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL