Code Monkey home page Code Monkey logo

kail's Introduction

kail: kubernetes tail Build Status

Kubernetes tail. Streams logs from all containers of all matched pods. Match pods by service, replicaset, deployment, and others. Adjusts to a changing cluster - pods are added and removed from logging as they fall in or out of the selection.

asciicast

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.

All flags can be set by an environment variable - KAIL_POD=foo kail is the same as kail --pod foo.

Selectors

Flag Selection
-l, --label LABEL-SELECTOR match pods based on a standard label selector
-p, --pod NAME match pods by name
-n, --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
-d, --deploy NAME match pods belonging to the given deployment
--sts NAME match pods belonging to the given statefulset
-j, --job NAME match pods belonging to the given job
--node NODE-NAME match pods running on the given node
--ing NAME match pods belonging to services targeted by the given ingress
-c, --containers CONTAINER-NAME restrict which containers logs are shown for
--ignore LABEL-SELECTOR Ignore pods that the selector matches. (default: kail.ignore=true)
--current-ns Match pods in the namespace specified in Kubernetes' "current context"
--ignore-ns NAME Ignore pods in the given namespaces. Overridden by --ns, --current-ns. (default: kube-system)

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

Other Flags

Flag Description
-h, --help Display help and usage
--context CONTEXT-NAME Use the given Kubernetes context
--dry-run Print initial matched pods and exit
--log-level LEVEL Set the logging level (default: error)
--log-file PATH Write output to PATH (default: /dev/stderr)
--since DURATION Display logs as old as given duration. Ex: 5s, 2m, 1.5h or 2h45m (defaults: 1s). See here for more information on the duration format.
-o, --output You can choose to display logs in default, raw (without prefix), json, pretty json and zerolog formats.

Installing

Homebrew

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

Krew

$ kubectl krew install tail
$ kubectl tail -h

Downloading

Kail binaries for Linux and OSX can be found on the latest release page. Download and install into your $GOPATH/bin.

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

Stress testing

Start minikube with a fair amount of CPU and memory.

$ minikube start --cpus 4 --memory 8192

Start stress.yml resources.

$ kubectl create -f _example/stress.yml

Wait a while for the pods to run

$ kubectl get pods --namespace stress | grep Running | wc -l
100

Run kail

./kail --ns stress

kail's People

Contributors

boz avatar carlossg avatar chandanpasunoori avatar chmouel avatar cpnviz avatar davidreuss avatar dependabot[bot] avatar forget-c avatar glyn avatar grosa1 avatar hanfried avatar ivanilves avatar johncsnyder avatar kenden avatar mnaser avatar nlowe avatar notque avatar ofpiyush avatar p-wall avatar paulbdavis avatar scothis avatar shonge avatar slach avatar snebel29 avatar suzuki-shunsuke avatar testwill avatar vibioh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kail's Issues

Add support for CronJob

I'm new to Kubernetes and kail and recently setup a CronJob, following the docs here: https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/

I was trying to use kail to stream the logs, but it doesn't look like it's supported at this time. Would it be possible to allow for commands structured like kail -n staging -j daily-job where -j is the job name, which can be retrieved via kubectl -n staging get jobs. Ideally, we wouldn't have to supply the numeric suffix, because especially for jobs that run often, it will be super dynamic.

Adapt deployment selector to k8s v1.16

The kail deployment selector does not work for Kubernetes v1.16.

For example:
I have some running deployments (all healthy) in the current namespace:

$ k get deploy
NAME                         READY   UP-TO-DATE   AVAILABLE   AGE
[...]
grafana-operators            1/1     1            1           39m
grafana-users                1/1     1            1           39m
kibana-logging               1/1     1            1           40m
kube-apiserver               1/1     1            1           44m
kube-controller-manager      1/1     1            1           44m
[...]

When I now try to use kail for the kube-apiserver deployment it does not work:

$ kail --current-ns -d kube-apiserver -c kube-apiserver
ERRO[0000] client list: the server could not find the requested resource  cmp=lister
ERRO[0000] lister error: client list: the server could not find the requested resource  cmp=controller
^Ckail: error: Unable to initialize data source

I guess, this is related to the recent changes in k8s v1.16, as the extensions/v1beta1.Deployment resource is now completely removed (see https://kubernetes.io/blog/2019/09/18/kubernetes-1-16-release-announcement/)

$ k version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.2", GitCommit:"c97fe5036ef3df2967d086711e6c0c405941e14b", GitTreeState:"clean", BuildDate:"2019-10-15T23:42:50Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.2", GitCommit:"c97fe5036ef3df2967d086711e6c0c405941e14b", GitTreeState:"clean", BuildDate:"2019-10-15T19:09:08Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}
$ kail version
0.12.0 (0d6900b110161d93625ba4fc6ac8fe7f0e8fe781)

Command should exit with 1 if not --wait

I ran this:

kail --svc frontend --deploy webapp

I have no service named frontend or deployment named webapp, so it should eventually fail right? If you want it to keep looking for awhile (if services are starting up etc), then maybe a wait option?

kail --svc frontend --deploy webapp --wait=20

20 seconds or trying every 2 seconds?

Namespaced deployment

Hi.

i just trying to use this tool inside a k8spin.cloud namespace to collect all logs in my namespace.

I mean, i have a scenario where i have (almost full) permissions in my namespace but i have not cluster permissions.

As i understand if i pass --current-ns flag and/or -n flag to kail it will query for logs in my namespace.

But i see the following logs:

time="2019-10-07T13:55:25Z" level=error msg="client list: pods is forbidden: User \"system:serviceaccount:angelbarrerasanchez-gmail-com-registry:angelbarrerasanchez-gmail-com-registry\" cannot list resource \"pods\" in API group \"\" at the cluster scope" cmp=lister
time="2019-10-07T13:55:25Z" level=error msg="lister error: client list: pods is forbidden: User \"system:serviceaccount:angelbarrerasanchez-gmail-com-registry:angelbarrerasanchez-gmail-com-registry\" cannot list resource \"pods\" in API group \"\" at the cluster scope" cmp=controller

This makes me think that kail does not support namespaced deployment. Am i right?

This is the pod.yaml i am using:

apiVersion: v1
kind: Pod
metadata:
  labels:
    kail.ignore: "true"
  name: kail
  namespace: angelbarrerasanchez-gmail-com-registry
spec:
  serviceAccountName: angelbarrerasanchez-gmail-com-registry
  containers:
  - args:
    - --current-ns
    - -n
    - angelbarrerasanchez-gmail-com-registry
    - --log-level
    - debug
    image: abozanich/kail
    imagePullPolicy: Always
    name: kail
    resources:
      limits:
        cpu: 20m
        memory: 64Mi
      requests:
        cpu: 20m
        memory: 64Mi

Let me know if i can try anything different

Issues running install from brew.

I just installed it from brew and the software just hang there if I use any flags..
e.g.

kube-system/calico-node-gd4xx[calico-node]: 2017-11-02 14:09:32.803 [INFO][89] int_dataplane.go 674: Applying dataplane updates
2017-11-02 14:09:32.803 [INFO][89] ipsets.go 224: Asked to resync with the dataplane on next update. family="inet"
2017-11-02 14:09:32.803 [INFO][89] ipsets.go 224: Asked to resync with the dataplane on next update. family="inet6"
2017-11-02 14:09:32.803 [INFO][89] ipsets.go 255: Resyncing ipsets with dataplane. family="inet"
2017-11-02 14:09:32.803 [INFO][89] ipsets.go 255: Resyncing ipsets with dataplane. family="inet6"
2017-11-02 14:09:32.805 [INFO][89] ipsets.go 297: Finished resync family="inet6" numInconsistenciesFound=0 resyncDuration=1.595033ms
2017-11-02 14:09:32.805 [INFO][89] ipsets.go 297: Finished resync family="inet" numInconsistenciesFound=0 resyncDuration=1.841668ms
2017-11-02 14:09:32.806 [INFO][89] int_dataplane.go 689: Finished applying updates to dataplane. msecToApply=2.152992
kube-system/calico-node-tqnbw[calico-node]: 2017-11-02 14:09:34.229 [INFO][91] int_dataplane.go 674: Applying dataplane updates
2017-11-02 14:09:34.229 [INFO][91] ipsets.go 224: Asked to resync with the dataplane on next update. family="inet"
2017-11-02 14:09:34.229 [INFO][91] ipsets.go 224: Asked to resync with the dataplane on next update. family="inet6"```
Works just fine right?

Now..

โžœ kail --pod kube-system/calico
^C%
~ took 1m 40s


Am I doing it wrong? 

running on macOs 10.13.1, lemme know if I can provide any other info to help find out what is going on.

Output should be line-buffered

When running kail on a k8s cluster with many pods logging at the same time it seems like log lines are trimmed or displayed interleaved, for instances:

1: foobar/core-data-6767d5f5df-bdgqj[core-data]: dler.go:81] (get) a4BE settings
2: D1124 12:27:38.566878 00001 core.data.core-data d87e1dc6 003_3649_002_000 indexhandler.go:46] (get.page) a4BE
3: D1124 12:27:38.560970 00001 core.data.core-data d87e1dc6 003_3640_001_000 handler.go:81] (get) a4BB settings
4: 00 handler.go:81] (get) a4BA settings
5: D1124 12:27:38.564373 00001 core.data.core-data d87e1dc6 003_3646_002_000 indexhandler.go:46] (get.page) a4BD
6: D1124 12:27:38.566814 00001 core.data.core-data d87e1dc6 003_3649_001_000 han

Note that lines 2,3 and 5 are complete while 1,4,6 are not. Running kubectl logs of course gives the full lines.

Unable to see ALL logs

Hi

Probably I am missing something, but is there a way to see all the logs ( info,debug,error) etc. Kind of the equivalent of tail -f which just prints everything.

Feature: Add timestamps

There should be timestamp data embedded in the original docker logs, it would be nice to expose these with a --timestamps flag like the regular kubectl logs command

Unexpected error when reading response body: context canceled

i use this command

kail --deploy my-deployment-name -n myns

and get this error

ERRO[0000] client list: listing deployments in : the server could not find the requested resource  cmp=lister
ERRO[0000] lister error: client list: listing deployments in : the server could not find the requested resource  cmp=controller
^CE0226 12:01:10.659400   17170 request.go:858] Unexpected error when reading response body: context canceled
ERRO[0001] client list: listing pods in : Unexpected error when reading response body. Please retry. Original error: context canceled  cmp=lister
kail: error: Unable to initialize data source

however kail alone works but it's from all pods

Running Kail without cluster role

Hello,

I was not be able to run Kail for just a namespace with a service account that has the full access for the given namespace.
There is away to have this on place?

./kail -n mynamespace

time="2020-11-20T13:48:22Z" level=error msg="client list: listing pods in : pods is forbidden: User "system:serviceaccount:mynamespace:mysa" cannot list pods at the cluster scope: no RBAC policy matched" cmp=lister

ย  | time="2020-11-20T13:48:22Z" level=error msg="lister error: client list: listing pods in : pods is forbidden: User "system:serviceaccount:mynamespace:system:serviceaccount:mynamespace:mysa" cannot list pods at the cluster scope: no RBAC policy matched" cmp=controller
ย  | kail: error: Unable to initialize data source

I dont want to run that with cluster role, I just want to run the Kail in single namespace with a service account that has the full access in that namespace.

Requires a lot of CPU

Is it expected that Kail would require 100% of a CPU? Can this be reduced by allowing the polling frequency to be lowered or something?

image

Nice project by the way.

not able to get logs of two pods

I run the below command and it is printing only app1 pod logs.

kail --ns myns -p app1-65c5fbdcd4-t6glp -p app2-6466c664c7-64cc4

then I also tried to use --rs option and it is not printing anything.

Feature: ARM64 builds

It would be great to get ARM64 builds for Linux and macOS (Darwin). I tried a quick compile of ARM64 for macOS and it seemed to work without any noticeable issues.

In v0.10.1 release please fix checksums.txt file name

Please rename checksums.txt to kail_0.10.1_checksums.txt

The install script will fail because it looks for a different file name

/tmp/install_kail -d
boz/kail info checking GitHub for latest tag
boz/kail debug http_download https://github.com/boz/kail/releases/latest
boz/kail info found version: 0.10.1 for v0.10.1/linux/amd64
boz/kail debug downloading files into /tmp/tmp.fhR7MdVmab
boz/kail debug http_download https://github.com/boz/kail/releases/download/v0.10.1/kail_0.10.1_linux_amd64.tar.gz
boz/kail debug http_download https://github.com/boz/kail/releases/download/v0.10.1/kail_0.10.1_checksums.txt
boz/kail debug http_download_curl received HTTP status 404

Kail gets sad with oidc auth providers such as CoreOS tectonic uses

kubectl is definitely configured correctly:

$ kubectl get pods
NAME                                           READY     STATUS    RESTARTS   AGE
awacs-server-prod-rqworker-2710497568-7gfml    1/1       Running   0          1h
awacs-server-prod-web-751514954-1gkt5          2/2       Running   0          1h
awacs-server-prod-web-751514954-kd9hn          2/2       Running   0          1h
awacs-server-prod-web-751514954-xqvnh          2/2       Running   0          1h
awacs-server-qa-rqworker-1613750792-7z589      1/1       Running   0          1h
awacs-server-qa-web-434843186-ljgc0            2/2       Running   0          1h
awacs-server-qa-web-434843186-x270d            2/2       Running   0          1h
awacs-server-qa-web-434843186-x6tm7            2/2       Running   0          1h
awacs-splunk-agent-prod-web-1225906819-1fzhw   2/2       Running   0          1h
awacs-splunk-agent-prod-web-1225906819-q6xcn   2/2       Running   0          1h
awacs-splunk-agent-prod-web-1225906819-wczqd   2/2       Running   0          1h
awacs-splunk-agent-qa-web-214160008-g7f89      2/2       Running   0          2h
awacs-splunk-agent-qa-web-214160008-sck9p      2/2       Running   0          2h
awacs-splunk-agent-qa-web-214160008-x1vck      2/2       Running   0          2h

The current kubectl config:

$ kubectl config view --minify
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: REDACTED
    server: https://[CENSORED]:443
  name: tectonic
contexts:
- context:
    cluster: tectonic
    namespace: awacs
    user: tectonic-oidc
  name: tectonic
current-context: tectonic
kind: Config
preferences: {}
users:
- name: tectonic-oidc
  user:
    auth-provider:
      config:
        client-id: tectonic-kubectl
        client-secret: [CENSORED]
        extra-scopes: groups
        id-token: [CENSORED}
        idp-certificate-authority-data: [CENSORED]
        idp-issuer-url: https://[CENSORED]/identity
        refresh-token: [CENSORED]
      name: oidc
$ kail --context=tectonic --deploy awacs-server-qa
kail: error: Error configuring kubernetes connection: No Auth Provider found for name "oidc"
$ kail --deploy awacs-server-qa
kail: error: Error configuring kubernetes connection: No Auth Provider found for name "oidc"

Release of sts support

Hi there,

Can we have a release of latest add like sts support?

If no release that will not accessible by krew install !

Thank a lot.

Add support proxy-url from config

Hello,

Since 1.19 kube supports proxy-url per cluster.

This was added here kubernetes/kubernetes#81443

Sample config:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: REMOVED
    server: https://api.some-server.com
    proxy-url: http://some-proxy:1234
  name: cluster-name
contexts:
- context:
    cluster: cluster-name
    namespace: default
    user: user
  name: default
kind: Config
preferences: {}
users:
- name: cluster-name
  user:
    password: REMOVED
    username: admin
- name: cluster-name-basic-auth
  user:
    password: REMOVED
    username: admin

Could you please honour this proxy-url property from config?

If you have few clusters with different proxies it's not that convenient to set http_proxy before using Kail.

Add help to `--since`option

$ kail -p router-webapp-router-3393347979-r43p1 -n web --since 3600
kail: error: time: missing unit in duration 3600, try --help
$ kail --help
usage: kail [<flags>]
...
Flags:
...
      --since=DURATION        Display logs generated since given duration.

The suggestion to try --help is not helpful here.

Suggested help:

--since=DURATION        Display logs generated since given duration, like 300ms, 5s, 2m, 1.5h or 2h45m. Defaults to 1s""

`Can't connnect to kubernetes: Unauthorized` error when using aws-iam-authenticator

I have been using this tool (and its fantastic) for the past week or so. I recently moved to the aws-iam-authenticator and it now returns the error above.

I saw an older related ticket and fix (#2). It seem to just be adding the GCP auth pluging.

aws-iam-authenticator is handled through exec so maybe just adding the following will work?

https://github.com/kubernetes/client-go/blob/master/plugin/pkg/client/auth/exec/exec.go

I'm curious if there is a way for it to work with all supported authentication strategies. Based on the files in that auth directory, I assume people using OIDC have the same issue?

Version: 0.6.0 (e2ee089)

Support wildcards in names

It would be useful if we could use wilcards in name selectors. For example, instead of

kail -c video-streamer-c40 -c video-streamer-c41 -c video-streamer-c42 -c video-streamer-c43

we could just do

kail -c video-streamer-*

I'm proposing glob syntax because it's simple and probably sufficient. There's also the possibility of using regexp instead.

Make a plugin: kubectl tail

๐Ÿ‘‹ Hello, maintainer of the kubectl plugin manager krew here (https://github.com/kubernetes-sigs/krew).

What do you think of distributing this as a kubectl plugin named kubectl tail?

Why?

  • kubectl plugins are becoming a thing now, we have over 30 plugins.
  • kubectl tail is more natural and memorable than a custom binary name
  • krew helps you package/distribute your tool on macOS, Linux and Windows so you don't deal with homebrew, apt/dnf, chocolatey etc separately.

I suspect there would be no code changes required. The release process would involve periodic updates to the plugin manifest file hosted at https://github.com/kubernetes-sigs/krew-index/tree/master/plugins.

Ctrl-C is slow to give control back, sometimes doesn't

Ctrl-C is slow to give control back, sometimes doesn't

$ kail
kube-system/calico-node-8fnnk[calico-node]: 2017-09-26 14:16:50.884 [INFO][87] int_dataplane.go 584: Applying dataplane updates
2017-09-26 14:16:50.884 [INFO][87] table.go 632: Invalidating dataplane cache ipVersion=0x4 reason="refresh timer" table="filter"
2017-09-26 14:16:50.884 [INFO][87] table.go 416: Loading current iptables state and checking it is correct. ipVersion=0x4 table="filter"
2017-09-26 14:16:50.889 [INFO][87] int_dataplane.go 599: Finished applying updates to dataplane. msecToApply=4.747806000000001
2017-09-26 14:16:51.607 [INFO][87] int_dataplane.go 584: Applying dataplane updates
2017-09-26 14:16:51.607 [INFO][87] table.go 632: Invalidating dataplane cache ipVersion=0x6 reason="refresh timer" table="nat"
2017-09-26 14:16:51.607 [INFO][87] table.go 416: Loading current iptables state and checking it is correct. ipVersion=0x6 table="nat"
2017-09-26 14:16:51.609 [INFO][87] int_dataplane.go 599: Finished applying updates to dataplane. msecToApply=1.808908
^C^C^C^C^C^C^C^C^C^C^C^C^C^C%
$ kail
kube-system/calico-node-8fnnk[calico-node]: 2017-09-26 14:19:40.427 [INFO][87] int_dataplane.go 584: Applying dataplane updates
2017-09-26 14:19:40.427 [INFO][87] route_table.go 141: Queueing a resync of routing table. ipVersion=0x4
2017-09-26 14:19:40.427 [INFO][87] route_table.go 141: Queueing a resync of routing table. ipVersion=0x6
2017-09-26 14:19:40.427 [INFO][87] ipsets.go 214: Asked to resync with the dataplane on next update. family="inet"
2017-09-26 14:19:40.427 [INFO][87] ipsets.go 214: Asked to resync with the dataplane on next update. family="inet6"
2017-09-26 14:19:40.427 [INFO][87] ipsets.go 242: Resyncing ipsets with dataplane. family="inet"
2017-09-26 14:19:40.428 [INFO][87] ipsets.go 242: Resyncing ipsets with dataplane. family="inet6"
kube-system/calico-node-8fnnk[calico-node]: 2017-09-26 14:19:40.436 [INFO][87] ipsets.go 283: Finished resync family="inet6" numInconsistenciesFound=0 resyncDuration=8.075512ms
kube-system/calico-node-8fnnk[calico-node]: 2017-09-26 14:19:40.438 [INFO][87] ipsets.go 283: Finished resync family="inet" numInconsistenciesFound=0 resyncDuration=11.158785ms
kube-system/calico-node-8fnnk[calico-node]: 2017-09-26 14:19:40.443 [INFO][87] int_dataplane.go 599: Finished applying updates to dataplane. msecToApply=16.286828
kube-system/calico-node-8fnnk[calico-node]: 2017-09-26 14:19:40.983 [INFO][87] int_dataplane.go 584: Applying dataplane updates
2017-09-26 14:19:40.983 [INFO][87] table.go 632: Invalidating dataplane cache ipVersion=0x4 reason="refresh timer" table="filter"
2017-09-26 14:19:40.983 [INFO][87] table.go 416: Loading current iptables state and checking it is correct. ipVersion=0x4 table="filter"
kube-system/calico-node-8fnnk[calico-node]: 2017-09-26 14:19:40.988 [INFO][87] int_dataplane.go 599: Finished applying updates to dataplane. msecToApply=5.1373169999999995
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C%
kail --svc web-router
^CERRO[0001] client list: couldn't get version/kind; json parse error: unexpected end of JSON input  cmp=lister
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C

(killed the terminal)

Versions

$ uname -a
Darwin apollo 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64 i386 MacBookPro11,3 Darwin

$ brew info boz/repo/kail
boz/repo/kail: stable 0.4.1

Add http page support

Adding http page support will be great

say use url to directly locate the pod's log.

Deployment selector does not seem to work

Trying to use a deployment as the selector against a 1.5.7 cluster does not return any pods

โ””> kail --deploy modeler --dry-run
NAMESPACE NAME NODE

Matching on the RS directly does work however.

error when used with restricted access rights

When I try to use kail to get logs from an svc I get this error:

./kail --ns=ns1 --context=dev  --svc=projector
kail: error: Can't connnect to kubernetes: namespaces is forbidden: User "..." cannot list namespaces at the cluster scope

It seems like kail tries to list namespaces despite being given a precise namespace and svc.

Am I missing something?

Feature: Parse JSON logs

It would be very nice if kail could parse each line as a json document, then only print some selection of fields.

Most of our services print json documents on console, which is recorded then shipped to ES.

I could be willing to work on this, but some pointers on how it should be done would be nice.

Cannot get logs using kail

I can't get any logs out of kail

$ kail --pod router-3393347979-286gk --since 4m
...
...
...
... (nothing)
...
$ kail
^C^C^C^C^C^C^C^C^C^C^C^C^C
(have to kill the terminal)

Expected: logs should be displayed.

It works with default tools:

$ kubectl logs router-3393347979-286gk --since 4m
2017/09/26 12:46:01 [error] 13#0: *18713 connect() failed (111: Connection refused) while connecting to upstream, client: 199.55.39.200, server: test.readacted.com$, request: "GET /Redacted/ HTTP/1.1", upstream: "http://10.0.0.42:80/search?id=203&requestId=DCF1987C-6EDA-47D0-9276-356CE5F87C52", host: "test.redacted.com"
2017/09/26 12:46:01 [error] 13#0: *18713 connect() failed (111: Connection refused) while connecting to upstream, client: 199.55.39.200, server: test.readacted.com$, request: "GET /Redacted/ HTTP/1.1", upstream: "http://10.0.0.196:80/search?id=203&requestId=DCG1987C-6EDA-47D0-9276-356CE5F87C52", host: "test.redacted.com"

Or other tools:


$ stern router-3393347979-286gk --since 4m
2017/09/26 12:46:01 [error] 13#0: *18713 connect() failed (111: Connection refused) while connecting to upstream, client: 199.55.39.200, server: test.readacted.com$, request: "GET /Redacted/ HTTP/1.1", upstream: "http://10.0.0.42:80/search?id=203&requestId=DCF1987C-6EDA-47D0-9276-356CE5F87C52", host: "test.redacted.com"
2017/09/26 12:46:01 [error] 13#0: *18713 connect() failed (111: Connection refused) while connecting to upstream, client: 199.55.39.200, server: test.readacted.com$, request: "GET /Redacted/ HTTP/1.1", upstream: "http://10.0.0.196:80/search?id=203&requestId=DCG1987C-6EDA-47D0-9276-356CE5F87C52", host: "test.redacted.com"

$ kubetail router-3393347979-286gk --since 4m
2017/09/26 12:46:01 [error] 13#0: *18713 connect() failed (111: Connection refused) while connecting to upstream, client: 199.55.39.200, server: test.readacted.com$, request: "GET /Redacted/ HTTP/1.1", upstream: "http://10.0.0.42:80/search?id=203&requestId=DCF1987C-6EDA-47D0-9276-356CE5F87C52", host: "test.redacted.com"
2017/09/26 12:46:01 [error] 13#0: *18713 connect() failed (111: Connection refused) while connecting to upstream, client: 199.55.39.200, server: test.readacted.com$, request: "GET /Redacted/ HTTP/1.1", upstream: "http://10.0.0.196:80/search?id=203&requestId=DCG1987C-6EDA-47D0-9276-356CE5F87C52", host: "test.redacted.com"

Versions

$ uname -a
Darwin apollo 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64 i386 MacBookPro11,3 Darwin

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.6", GitCommit:"4bc5e7f9a6c25dc4c03d4d656f2cefd21540e28c", GitTreeState:"clean", BuildDate:"2017-09-15T08:51:09Z", GoVersion:"go1.9", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.2", GitCommit:"922a86cfcd65915a9b2f69f3f193b8907d741d9c", GitTreeState:"clean", BuildDate:"2017-07-21T08:08:00Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}

$ go version
go version go1.9 darwin/amd64

$ brew info boz/repo/kail
boz/repo/kail: stable 0.4.0

Feature: Add completion support

Thanks for this really usefull app !

It will be nice to have some completion support for option (--ns, ...).
And really awesome to have some completion based on context --ns my-namespace

arm64 support in krew

krew installation failing for arm64 and I don't see arm64 in https://github.com/kubernetes-sigs/krew-index/blob/master/plugins/tail.yaml or https://github.com/boz/kail/releases

can we add this, I can see https://github.com/boz/kail/blob/master/.goreleaser.yml already has arm64.

what is required to add arm64 in release, I can contribute if you require.

$ kubectl krew version
OPTION            VALUE
GitTag            v0.4.3
GitCommit         dbfefa5
IndexURI          https://github.com/kubernetes-sigs/krew-index.git
BasePath          /Users/cp/.krew
IndexPath         /Users/cp/.krew/index/default
InstallPath       /Users/cp/.krew/store
BinPath           /Users/cp/.krew/bin
DetectedPlatform  darwin/arm64
$ kubectl krew install tail

Updated the local copy of plugin index.
Installing plugin: tail
W0317 15:01:20.772855 61973 install.go:164] failed to install plugin "tail": plugin "tail" does not offer installation for this platform
failed to install some plugins: [tail]: plugin "tail" does not offer installation for this platform

Feature: support --kubeconfig flag

In many other tools you can use --kubeconfig to point to a kubeconfig file to select context/cluster to connect to.

Consider adding this support to this tool.

Default to current namespace? (or via `--ns`)

Currently kail with no arguments matches every pod in the cluster โ€” personally I think this should be the current namespace, there's so many system pods and their logs aren't usually relevant to day to day application work. Not sure how you feel about changing that default?

Otherwise, it'd be nice for kail --ns (ie. with no namespace) to default to the current namespace. Currently, --ns matches all namespaces, and --ns= matches nothing.

Allow not printing prefix

It would be great if there was way to disable printing the prefix, the same way there is --prefix=true/false in kubernetes

It would makes copy and paste a bit easier...

Homebrew: Calling `bottle :unneeded` is deprecated

Hi there

I ran a brew upgrade today and got this warning:

Warning: Calling bottle :unneeded is deprecated! There is no replacement.
Please report this issue to the boz/repo tap (not Homebrew/brew or Homebrew/core):
  /opt/homebrew/Library/Taps/boz/homebrew-repo/kail.rb:6

Feature request: add `--version`

For debugging, information, knowing what's installed, it would be nice to have a nicer way to get the version installed.

$ kail --version
kail: error: unknown long flag '--version', try --help
$ kail version
kail: error: unexpected version, try --help

Expected:

$ kail --version
0.4.1

Workaround:

$ brew info boz/repo/kail
boz/repo/kail: stable 0.4.1
kubernetes tail - pod log viewer
https://github.com/boz/kail
/usr/local/Cellar/kail/0.4.0 (5 files, 29MB)
  Built from source on 2017-09-26 at 15:04:27
/usr/local/Cellar/kail/0.4.1 (5 files, 29MB) *
  Built from source on 2017-09-26 at 15:53:10
From: https://github.com/boz/homebrew-repo/blob/master/kail.rb
# (highest version must be the one?)

Release? DNS on macOS with VPNs doesn't work

When connected to a VPN on macOS which is used for DNS-lookups:

$ kail -d my-deploy
kail: error: Can't connnect to kubernetes: Get https://api.my.k8s.example.com/api/v1/namespaces:
dial tcp: lookup api.my.k8s.example.com on 192.168.1.254:53: no such host

It's basically a Go issue where it doesn't check the places it needs to for DNS resolution on macOS. But it's fixed in Go 1.13, which is already used for kail on master ๐Ÿฅณ

Possible to cut a release?

Differentiate logs coming from different pods

It would be nice to differentiate the logs coming from different pods.
Show all pods with a different color?

Or maybe, depending on params, something like this:

If logs are shown from different pods, it could be nice to show different colors.
$ kail
---> show all pods in the same namespace with the same colors? Else, different colors?

$ kail --ns kube-system
---> show pods bellonging to the same deployment/daemonset/rs/rc with the same color, and different colors otherwise?

$ kail --ns kube-system --ds <name>
$ kail --ns kube-system --deploy <name>
$ kail --ns kube-system --rs <name>
$ kail --ns kube-system --rc <name>
$ kail --ns kube-system --ing <name>
---> show all pods with a different color?

Here is what I miss:

  • kubetail --help:
-k, --colored-output Use colored output (pod|line|false).
                         pod = only color podname, line = color entire line, false = don't use any colors.
                         Defaults to line.
  • stern --help:
--color string          Color output. Can be 'always', 'never', or 'auto' (default "auto")

`brew install` error message on `--help`

Hi, just wanted to note that I see the following error when I run --help.

> kail --help
usage: kail [<flags>] <command> [<args> ...]

Tail for kubernetes pods

Flags:
  -h, --help                  Show context-sensitive help (also try --help-long and --help-man).
      --ignore=SELECTOR ...   ignore selector
  -l, --label=SELECTOR ...    label
  -p, --pod=NAME ...          pod
  -n, --ns=NAME ...           namespace
      --svc=NAME ...          service
      --rc=NAME ...           replication controller
      --rs=NAME ...           replica set
      --ds=NAME ...           daemonset
  -d, --deploy=NAME ...       deployment
      --node=NAME ...         node
      --ing=NAME ...          ingress
      --context=CONTEXT-NAME  kubernetes context
  -c, --containers=NAME ...   containers
      --dry-run               print matching pods and exit
      --log-file=/dev/stderr  log file output
      --log-level=error       log level
      --since=DURATION        Display logs generated since given duration, like 5s, 2m, 1.5h or
                              2h45m. Defaults to 1s.
      --glog-v="0"            glog -v value
      --glog-vmodule=""       glog -panic: template: usage:30:53: executing "usage" at <
>: write /dev/stderr: resource temporarily unavailable

goroutine 1 [running]:
github.com/boz/kail/vendor/gopkg.in/alecthomas/kingpin%2ev2.(*Application).writeUsage(0xc4202700f0, 0xc420113680, 0x0, 0x0)
	/home/travis/gopath/src/github.com/boz/kail/vendor/gopkg.in/alecthomas/kingpin.v2/app.go:235 +0x11b
github.com/boz/kail/vendor/gopkg.in/alecthomas/kingpin%2ev2.(*Application).maybeHelp(0xc4202700f0, 0xc420113680)
	/home/travis/gopath/src/github.com/boz/kail/vendor/gopkg.in/alecthomas/kingpin.v2/app.go:249 +0xd0
github.com/boz/kail/vendor/gopkg.in/alecthomas/kingpin%2ev2.(*Application).Parse(0xc4202700f0, 0xc42000a090, 0x1, 0x1, 0xc4202700f0, 0x1d2d9fb, 0x7, 0x1d39aed)
	/home/travis/gopath/src/github.com/boz/kail/vendor/gopkg.in/alecthomas/kingpin.v2/app.go:213 +0x18a
github.com/boz/kail/vendor/gopkg.in/alecthomas/kingpin%2ev2.Parse(0x1d2d9fb, 0x7)
	/home/travis/gopath/src/github.com/boz/kail/vendor/gopkg.in/alecthomas/kingpin.v2/global.go:37 +0x77
main.main()
	/home/travis/gopath/src/github.com/boz/kail/cmd/kail/main.go:88 +0x113

I installed via homebrew on my Mac.

Versions:

  • macOS Mojave v10.14.2
  • brew version 1.9.3-102-g058274a
  • kail version 0.7.0 (62372338c90a53d48566a637c5afbed4c9926452)

Make statefulsets matchable

Cannot match es-app-data-* and cannot match a service since the sts is not connected to the service (only es-client is)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.