kubelogtail

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

README

kube-log-tail

tail/follow logs from multiple pods and their containers.

kube-log-tail will follow logs of new pods that are created while it is running.

Inspired by kubetail.

Installation

To install the latest master, you need a working local Go environment, and run:

go get -u github.com/bakins/kube-log-tail/cmd/kube-log-tail

For released versions, see Releases. Download, chmod +x the file, and move it into your PATH.

Usage

$ kube-log-tail -h
tail kubernetes pod logs

Usage:
  kube-log-tail [flags]

Flags:
  -k, --colored-output string   use colored output (pod|line|off) (default "pod")
  -h, --help                    help for kube-log-tail
      --kubeconfig string       path to kubeconfig (default "/Users/bakins/.kube/config")
  -n, --namespace string        namespace for pods. use "" for all namespaces (default "default")
  -r, --refresh duration        how often to refresh the list of pods (default 10s)
  -l, --selector string         label selector for pods
  -v, --version                 display the current version

The selector is a label selector. Simple selectors such as app=my-app as well as more complex selectors such as environment in (production, qa) are supported.

Namespace limits the pod search to specific namespaces. Use an empty namespace (ie, --namespace="") to search all namespaces.

kube-log-tail will refresh the list of pods periodically. One may change the interval, by passing in --refesh=1m, for example, to only refresh once per minute. Deleted pods will no longer output, and new pods will begin tailing without having to restart kube-log-tail.

By using the -k argument you can specifiy how kube-log-tail makes use of colors.

Value Description
pod Only the pod name is colorized but the logged text is using the terminal default color (default)
line The entire line is colorized
false Don't colorize the output at all

Only a small number of colors are currently supported, and each container in each pod is given a color, so colors may repeat.

Know Issues

  • Sometimes, kube-log-tail will just stop tailing a log. If this happens, check if the last log line from the container was unexpected stream type "" or similar. This is an issue with Kubernetes and I'm thinking of workaround.

TODO

  • Homebrew recipe
  • use watches for pod events rather than a full refresh
  • allow disabling seeing old log lines
  • Handle containers that sre not running - ie, in ContainerStart

LICENSE

See LICENSE

Acknowledgements

Thanks to Johan Haleby for kubetail.

Documentation

Overview

Package kubelogtail provides a simple log tailer for Kubernetes pods

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KubeLogTail

type KubeLogTail struct {
	// contains filtered or unexported fields
}

KubeLogTail is a wrapper for discovering and printing logs from Kubernetes containers.

func New

func New(options ...OptionsFunc) (*KubeLogTail, error)

New creates a new KubeLogTail

func (*KubeLogTail) Run

func (k *KubeLogTail) Run() error

Run discovers the pods and tails the container logs. This generally does not return.

func (*KubeLogTail) Stop

func (k *KubeLogTail) Stop()

Stop triggers the kubelog tail to stop processing.

type OptionsFunc

type OptionsFunc func(*KubeLogTail) error

OptionsFunc is a function passed to new for setting options on a new KubeLogTail.

func SetColorMode

func SetColorMode(mode string) OptionsFunc

SetColorMode creates a function that will set the color print mode. Generally, only used when create a new KubeLogTail.

func SetKubeConfig

func SetKubeConfig(kubeconfig string) OptionsFunc

SetKubeConfig creates a function that will set the kubeconfig. Generally, only used when create a new KubeLogTail.

func SetLabelSelector

func SetLabelSelector(query string) OptionsFunc

SetLabelSelector creates a function that will set the label selecotr for listing pods. Generally, only used when create a new KubeLogTail.

func SetNamespace

func SetNamespace(namespace string) OptionsFunc

SetNamespace creates a function that will set the namespace for pods. a blank string indicates all namespaces Generally, only used when create a new KubeLogTail.

func SetRefreshTime

func SetRefreshTime(duration time.Duration) OptionsFunc

SetRefreshTime creates a function that will set the pod refresh time. Generally, only used when create a new KubeLogTail.

Directories

Path Synopsis
cmd
kube-log-tail
Package main runs the command and handles command line options
Package main runs the command and handles command line options

Jump to

Keyboard shortcuts

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