• Stars
    star
    138
  • Rank 264,508 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created about 8 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

tail -f experience for Kubernetes Pods

k8stail

GitHub Actions codecov GitHub release

tail -f experience for Kubernetes Pods

As you know, kubectl logs can stream only ONE pod at the same time. k8stail enables you to watch log streams of ALL pods in the specified namespace or labels in real time, like tail -f.

example

Table of Contents

Requirements

Kubernetes 1.3 or above

Installation

Using Homebrew (OS X only)

Formula is available at dtan4/homebrew-dtan4.

$ brew tap dtan4/dtan4
$ brew install k8stail

Precompiled binary

Precompiled binaries for Windows, OS X, Linux are available at Releases.

From source

$ go get -d github.com/dtan4/k8stail
$ cd $GOPATH/src/github.com/dtan4/k8stail
$ make deps
$ make install

Run in a Docker container

Docker image is no longer provided officially. If you'd like to run k8sec in Docker image, see Dockerfile and build image by yourself.

docker build -t k8stail .

Usage

Logs of all pods, all containers in pod in the specified namespace are streaming. When new pod is added, logs of the pod also appears. To stop streaming and exit, press Ctrl-C.

$ k8stail --namespace awesome-app
Namespace: awesome-app
Labels:
----------
Pod awesome-app-web-4212725599-67vd4 has detected
Pod awesome-app-web-4212725599-6pduy has detected
Pod awesome-app-web-4212725599-lbuny has detected
Pod awesome-app-web-4212725599-mh3g1 has detected
Pod awesome-app-web-4212725599-pvjsm has detected
[awesome-app-web-4212725599-mh3g1][web]  | creating base compositions...
[awesome-app-web-4212725599-zei9h][web]  |    (47.1ms)  CREATE TABLE "schema_migrations" ("version" character varying NOT NULL)
[awesome-app-web-4212725599-zei9h][web]  |    (45.1ms)  CREATE UNIQUE INDEX  "unique_schema_migrations" ON "schema_migrations"  ("version")
[awesome-app-web-4212725599-zei9h][web]  |   ActiveRecord::SchemaMigration Load (1.8ms)  SELECT "schema_migrations".* FROM "schema_migrations"
[awesome-app-web-4212725599-zei9h][web]  | Migrating to CreatePosts (20160218082522)

With --timestamps option, log timestamp is printed together.

$ k8stail --namespace awesome-app --timestamps
Namespace: awesome-app
Labels:
----------
Pod awesome-app-web-4212725599-67vd4 has detected
Pod awesome-app-web-4212725599-6pduy has detected
Pod awesome-app-web-4212725599-lbuny has detected
Pod awesome-app-web-4212725599-mh3g1 has detected
Pod awesome-app-web-4212725599-pvjsm has detected
[awesome-app-web-4212725599-mh3g1][web] 2016-11-15T10:57:22.178667425Z  | creating base compositions...
[awesome-app-web-4212725599-zei9h][web] 2016-11-15T10:57:22.309011520Z  |    (47.1ms)  CREATE TABLE "schema_migrations" ("version" character varying NOT NULL)
[awesome-app-web-4212725599-zei9h][web] 2016-11-15T10:57:22.309053601Z  |    (45.1ms)  CREATE UNIQUE INDEX  "unique_schema_migrations" ON "schema_migrations"  ("version")
[awesome-app-web-4212725599-zei9h][web] 2016-11-15T10:57:22.463700110Z  |   ActiveRecord::SchemaMigration Load (1.8ms)  SELECT "schema_migrations".* FROM "schema_migrations"
[awesome-app-web-4212725599-zei9h][web] 2016-11-15T10:57:22.463743373Z  | Migrating to CreatePosts (20160218082522)

With --labels option, you can filter pods to watch.

$ k8stail --namespace awesome-app --labels name=awesome-app-web
Namespace: awesome-app
Labels:    name=awesome-app-web
----------
Pod awesome-app-web-4212725599-67vd4 has detected
Pod awesome-app-web-4212725599-6pduy has detected
Pod awesome-app-web-4212725599-lbuny has detected
Pod awesome-app-web-4212725599-mh3g1 has detected
Pod awesome-app-web-4212725599-pvjsm has detected
[awesome-app-web-4212725599-mh3g1][web]  | creating base compositions...
[awesome-app-web-4212725599-zei9h][web]  |    (47.1ms)  CREATE TABLE "schema_migrations" ("version" character varying NOT NULL)
[awesome-app-web-4212725599-zei9h][web]  |    (45.1ms)  CREATE UNIQUE INDEX  "unique_schema_migrations" ON "schema_migrations"  ("version")
[awesome-app-web-4212725599-zei9h][web]  |   ActiveRecord::SchemaMigration Load (1.8ms)  SELECT "schema_migrations".* FROM "schema_migrations"
[awesome-app-web-4212725599-zei9h][web]  | Migrating to CreatePosts (20160218082522)

kubeconfig file

k8stail uses ~/.kube/config as default. You can specify another path by KUBECONFIG environment variable or --kubeconfig option. --kubeconfig option always overrides KUBECONFIG environment variable.

$ KUBECONFIG=/path/to/kubeconfig k8stail
# or
$ k8stail --kubeconfig=/path/to/kubeconfig

Options

Option Description Required Default
--context=CONTEXT Kubernetes context
--debug Debug mode using pprof (http://localhost:6060) false
--kubeconfig=KUBECONFIG Path of kubeconfig ~/.kube/config
--labels=LABELS Label filter query (e.g. app=APP,role=ROLE)
--namespace=NAMESPACE Kubernetes namespace default
--timestamps Include timestamps on each line false
-h, -help Print command line usage
-v, -version Print version

Development

Go 1.7 or above is required.

Clone this repository and build using make.

$ go get -d github.com/dtan4/k8stail
$ cd $GOPATH/src/github.com/dtan4/k8stail
$ make

Author

Daisuke Fujita (@dtan4)

License

MIT License

More Repositories

1

terraforming

Export existing AWS resources to Terraform style (tf, tfstate) / No longer actively maintained
Ruby
4,316
star
2

k8sec

CLI tool to manage Kubernetes Secrets easily
Go
258
star
3

nginx-basic-auth-proxy

Docker image of Nginx Proxy with Basic Auth
Shell
83
star
4

paus

Docker Compose PaaS
HTML
75
star
5

s3url

Generate S3 object pre-signed URL in one command
Go
39
star
6

k8s-pod-notifier

Notify Pod status to Slack
Go
34
star
7

k8s-job-cleaner

Clean up completed Kubernetes Jobs
Go
33
star
8

dockerfile-terraforming

Docker Image for Terraforming
Ruby
27
star
9

terraforming-gke

Generate Terraform HCL files from existng GKE resources
Ruby
26
star
10

ct2stimer

Convert crontab to systemd timer
Go
22
star
11

sendgrid2datadog

Send SendGrid metrics to DataDog
Go
18
star
12

k8s-unused-secret-detector

Detect unused Kubernetes Secrets
Go
18
star
13

valec

Handle application secrets securely
Go
16
star
14

ec2-event-slack-notifier

AWS Lambda function / Docker image to notify EC2 Scheduled Events to Slack
JavaScript
10
star
15

ghrls

List & Describe GitHub Releases
Go
10
star
16

esnctl

Elasticsearch Node Controller with AWS Auto Scaling Group
Go
10
star
17

aws-sign-proxy

HTTP proxy that signs requests for AWS service endpoints
Go
10
star
18

k8ship

Deploy image to Kubernetes
Go
7
star
19

systemd-timers

Better systemctl list-timers
Go
7
star
20

terraforming-dnsimple

Terraforming extension for DNSimple
Ruby
6
star
21

yaml2dirs

Create directory tree from YAML
Go
5
star
22

md2pukiwiki

Convert Markdown to Pukiwiki-notation
Ruby
5
star
23

ecr-gc

AWS Lambda function to clean up untagged images stored in ECR
JavaScript
5
star
24

terraforming-datadog

Terraforming extension for Datadog Monitors
Ruby
4
star
25

ec2c

Simple AWS EC2 CLI
Go
4
star
26

rdm2bq

Send Amazon RDS Enhanced Monitoring process metrics to Google BigQuery
Ruby
4
star
27

paus-gitreceive

Git server of Paus
Go
4
star
28

lambda-go-ping-function

Go
4
star
29

aws4_signer.cr

Crystal
4
star
30

apig-sample

Go
4
star
31

spotrack

Make spot instance requests and watch them whether accepted or rejected
Ruby
3
star
32

xronor

Timezone-aware Job Scheduler DSL and Converter
Ruby
3
star
33

skytraq-datalogger

C
3
star
34

docker-service-rails

Ruby
3
star
35

lambda-smart-autoscaling

JavaScript
3
star
36

vuejs-sample

Ruby
3
star
37

whosekey

Find the IAM user who has the specified AWS_ACCESS_KEY_ID
Go
2
star
38

xlapse

Serverless periodical image collector
Starlark
2
star
39

nowtv

What TV programs are broadcasted now?
Ruby
2
star
40

picam2s3

Send mjpeg-streamer snapshot to S3
Go
2
star
41

aperdeen

Amazon API Gateway client and local proxy
Go
2
star
42

grpc-pg-todo

Ruby
2
star
43

dockerfile-vault

Docker Image for HashiCorp Vault
Ruby
2
star
44

mado

Realtime Github Flavored Markdown Preview with WebSocket
Ruby
2
star
45

valecjr

Go
1
star
46

photomosaic

Photomosaic Generator
Ruby
1
star
47

paus-frontend

Web frontend of Paus
Go
1
star
48

homebrew-tools

Homebrew recipes of @dtan4 tools
Ruby
1
star
49

grpc-private-bff-example

Go
1
star
50

dockerfile-texlive

1
star
51

dot.zsh

.zsh
Shell
1
star
52

gamesh

Go implementation of ramesh
Go
1
star
53

design-pattern-ruby

GoF design patterns implemented in Ruby
Ruby
1
star
54

k8s-ls-pods

List Kubernetes Pods!
Go
1
star
55

try-prometheus

1
star
56

teppan

CLI tool to generate text from template with .env
Go
1
star
57

ramesh-dashboard

Dashboard for ramesh
Ruby
1
star
58

xygon

Simple Password Manager
Ruby
1
star
59

sintaku

Check EC2 Spot Instance Termination Notice from outside
Go
1
star
60

multihost-coreos-es-cluster

Build Elasticsearch cluster between multiple CoreOS instances
HTML
1
star
61

memot

Synchronize Evernote and Markdown in Dropbox
Ruby
1
star
62

coreos-vulcand-sample

Zero-downtime Blue-Green deployment on CoreOS + Vulcand
Ruby
1
star
63

drone-on-docker

[WIP] Run Drone CI as Docker container
Ruby
1
star
64

aprice

AWS Price List CLI
Go
1
star
65

ramesh

Command Line Tool for ๆฑไบฌใ‚ขใƒกใƒƒใ‚ทใƒฅ (Tokyo-Amesh)
Ruby
1
star
66

2son

API Server to Convert 2ch to JSON
Ruby
1
star
67

dockerfile-emacs

Shell
1
star
68

imageup

Pull Docker images via HTTP webhook
Go
1
star