Giter VIP home page Giter VIP logo

kubetail's Introduction

Kubetail

Bash script that enables you to aggregate (tail/follow) logs from multiple pods into one stream. This is the same as running "kubectl logs -f " but for multiple pods.

Installation

Just download the kubetail file (or any of the releases) and you're good to go.

Homebrew

You can also install kubetail using brew:

$ brew tap johanhaleby/kubetail && brew install kubetail

It's also possible to install kubetail abbreviated to kt by using the --with-short-names suffix:

$ brew tap johanhaleby/kubetail && brew install kubetail --with-short-names

Note that you may need to run compinit for zsh to pick-up the changes in competition after having upgraded from the non abbreviated installation.

Use brew install --HEAD kubetail to install the latest (unreleased) version.

ASDF

You can install kubetail using the asdf version manager.

asdf plugin-add kubetail https://github.com/janpieper/asdf-kubetail.git
asdf install kubetail <version>

To find out the available versions to install, you can run the following command:

asdf list-all kubetail

ZSH plugin

If you're using a ZSH plugin manager, you can install kubetail as a plugin.

Antigen

If you're using Antigen:

  1. Add antigen bundle johanhaleby/kubetail to your .zshrc where you've listed your other plugins.
  2. Close and reopen your Terminal/iTerm window to refresh context and use the plugin. Alternatively, you can run antigen bundle johanhaleby/kubetail in a running shell to have antigen load the new plugin.

oh-my-zsh

If you're using oh-my-zsh:

  1. In the command line, change to oh-my-zsh's custom plugin directory :

    cd ~/.oh-my-zsh/custom/plugins/

  2. Clone the repository into a new kubetail directory:

    git clone https://github.com/johanhaleby/kubetail.git kubetail

  3. Edit your ~/.zshrc and add kubetail – same as clone directory – to the list of plugins to enable:

    plugins=( ... kubetail )

  4. Then, restart your terminal application to refresh context and use the plugin. Alternatively, you can source your current shell configuration:

    source ~/.zshrc

zgen

If you're using zgen:

  1. Add zgen load johanhaleby/kubetail to your .zshrc along with your other zgen load commands.
  2. zgen reset && zgen save

Completion

The easiest option is to install kubetail from homebrew to dynamically display the pods names on $ kubetail <tab>. Alternatively install any of the completion scripts (bash/zsh/fish) manually. For example:

  • On Ubuntu, download the kubetail.bash script and execute it in your ~/.bash_completion file source $HOME/kubetail/completion/kubetail.bash.
  • On Mac with zsh copy the kubetail.zsh script to /usr/local/share/zsh/site-functions/_kubetail.
  • On Mac with fish copy the kubetail.fish script to ~/.config/fish/completions/.

Don't forget to restart your terminal afterwards.

Usage

First find the names of all your pods:

$ kubectl get pods

This will return a list looking something like this:

NAME                   READY     STATUS    RESTARTS   AGE
app1-v1-aba8y          1/1       Running   0          1d
app1-v1-gc4st          1/1       Running   0          1d
app1-v1-m8acl  	       1/1       Running   0          6d
app1-v1-s20d0  	       1/1       Running   0          1d
app2-v31-9pbpn         1/1       Running   0          1d
app2-v31-q74wg         1/1       Running   0          1d
my-demo-v5-0fa8o       1/1       Running   0          3h
my-demo-v5-yhren       1/1       Running   0          2h

To tail the logs of the two "app2" pods in one go simply do:

$ kubetail app2

To tail only a specific container from multiple pods specify the container like this:

$ kubetail app2 -c container1

You can repeat -c to tail multiple specific containers:

$ kubetail app2 -c container1 -c container2

To tail multiple applications at the same time seperate them by comma:

$ kubetail app1,app2

For advanced matching you can use regular expressions:

$ kubetail "^app1|.*my-demo.*" --regex

To tail logs within a specific namespace, make sure to append the namespace flag after you have provided values for containers and applications:

$ kubetail app2 -c container1 -n namespace1

Supply -h for help and additional options:

$ kubetail -h

Colors

By using the -k argument you can specify how kubetail makes use of colors (only applicable when tailing multiple pods).

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

Example:

$ kubetail app2 -k false

If you find that some colors are difficult to see then they can be skipped by supplying the color index either to the -z flag or by setting the KUBETAIL_SKIP_COLORS environment variable (either choice could be comma seperated). To find the color index you'd like to skip more easily, set the -i flag to true (-i true) or set the KUBETAIL_SHOW_COLOR_INDEX environment variable to true (KUBETAIL_SHOW_COLOR_INDEX=true). This will print the color index as a prefix to the pod name (e.g. [3:my-pod-12341] some log where 3 is the index of the color). This is also helpful if you suffer from color blindness since the index will always be printed with the default terminal color.

Filtering / Highlighting etc

kubetail itself doesn't have filtering or highlighting capabilities built-in. If you're on MacOSX I recommend using iTerm2 which allows for continuous highlighting of search terms, good scrolling capabilities and multitab arrangements. Another useful feature of iTerm2 is the "timeline" (cmd + shift + e) which lets you display a timeline in your own local timezone next to the logs (that are typically in UTC).

If you're not using iTerm2 or think that kubetail is lacking in features there's a fork of kubetail made by Alan Stebbens that allows for richer configuration and uses multitail and bash-lib. Alan has been kind enough to provide a pull request but my current thinking is that I'd like kubetail to stay simple and small and not use any dependencies.

Environment

kubetail can take default option values from environment variables matching the option name.

KUBETAIL_PREVIOUS
KUBETAIL_SINCE
KUBETAIL_NAMESPACE
KUBETAIL_FOLLOW
KUBETAIL_PREFIX
KUBETAIL_LINE_BUFFERED
KUBETAIL_COLORED_OUTPUT
KUBETAIL_TIMESTAMPS
KUBETAIL_JQ_SELECTOR
KUBETAIL_SKIP_COLORS
KUBETAIL_TAIL
KUBETAIL_SHOW_COLOR_INDEX

More

Pull requests are very welcome!

See also: http://code.haleby.se/2015/11/13/tail-logs-from-multiple-pods-simultaneously-in-kubernetes/

Buy Me A Coffee

kubetail's People

Contributors

aaronzirbes avatar astorije avatar bean5 avatar ben-harack avatar dariusf avatar diego-schmidt-apontador avatar dimasalakhov avatar drewwells avatar esvinson avatar felixbuenemann avatar fmmr avatar franciscocpg avatar garystv avatar hakob avatar hazzard17h avatar janpieper avatar johanhaleby avatar joshperry avatar l2fprod avatar lordjabez avatar neclimdul avatar nicklavrov avatar nowaker avatar rahulwa avatar samirtalwar avatar shihabuddinbuet avatar stonemaster avatar towolf avatar troyanov avatar unixorn 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kubetail's Issues

Default namespace et al not applied

I want to be able to set a default namespace from my environment, so I tweaked the preamble to

default_namespace="${KUBETAIL_NAMESPACE:-default}"

Unfortunately it appears that the default_namespace variable, and it cousins, are not actually effective unless an empty option is provided, because

-n|--namespace)
	if [ -z "$2" ]; then
		namespace="${default_namespace}"
	else
		namespace="$2"
	fi

I don't think this can be intentional since the namespace argument is provided, for example, to kubectl when finding matching pods, regardless of whether -n|--namespace was provided to kubetail.

color break when there is only 1 pod

$ kubetail --colored-output false -T -l name=tiller -n kube-system
Will tail 1 logs...
/Users/gmmaster/bin/kubetail: line 208: ((: >= 0 &&  <= 7 : syntax error: operand expected (error token is ">= 0 &&  <= 7 ")
Bad color code!
tiller-deploy-1651596238-gnxn7
^C

obs: no diference without option --colored-output false

Create 1.0 release

By creating a 1.0 release in Github, this can be added to homebrew and people can install kubetail by just running:

brew install kubetail

Would be nice.

No log output with latest kubetail

With this revision f7bf162, when I run kubetail fibo I get:

 $> kubetail fibo
Will tail 0 logs...

Although one pod should match:

$> kubectl get pods
NAME                                    READY     STATUS    RESTARTS   AGE
fibonacci-deployment-5bfffb94b9-qp7jr   1/1       Running   0          49m

This pod has one container.

kubetail works if I use https://raw.githubusercontent.com/johanhaleby/kubetail/3550902638ea7f22fe6d202bbdcce352a856d8d0/kubetail

This change seems to break kubetail: fa54961#diff-44c926232b5c97d99e30d68b3335237b

My kubectl env:

kubectl version
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.3", GitCommit:"a4529464e4629c21224b3d52edfe0ea91b072862", GitTreeState:"clean", BuildDate:"2018-09-09T18:02:47Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.7+IKS", GitCommit:"6b552b70cf51a673d033947f83e88fa5ac3167ab", GitTreeState:"clean", BuildDate:"2018-08-23T06:08:08Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

Now you need to explicitly pass --namespace with --context if namespace is different from the current-context one

Hi there,

Not sure, if that's the intended behaviour but presently if I pass --context and that context has a namespace attached to it in my kube config file, I won't be able to tail anything as it won't get the specific namespace of that context, it will set the namespace of the current-context no matter what.

My configuration is something like that:

- context:
    cluster: cluster-1.com
    namespace: dev
    user: user-cluster-1.com
  name: dev
- context:
    cluster: cluster-2.com
    namespace: prod
    user: user-cluster-2.com
  name: prod
current-context: dev

When running the following with kubetail version 1.6.10

$ kubetail oauth --context prod

returns

No pod exists that matches oauth

However, running

kubetail oauth --context prod -n prod

returns all the logs expected.

I've looked into the script and while I'm not an expert in bash I think it's due to the method calculate_default_namespace() which doesn't get passed the --context option if one is given to the kubetail command, thus, grabbing the namespace of the current-context every time that function is ran.

Happy to help if needed.

Kubetail not display logs of main container when use initContainers

kubetail version : 1.6.11-SNAPSHOT

I use the initContainers check status MySQL service when it startup.

...
    spec:
      initContainers:
        - name: init-mysql
          image: busybox
          command: ['sh', '-c', "until nslookup mysql; do echo waiting for mysql; sleep 2; done;"]
      containers:
        - name: app-service
          image: app-service:1.0
...

Kubetail display logs from init containers, when the init containers are complete, it does not display logs of "app-service"

[app-service-6bfc85597c-nrbcm init-mysql] Server:		10.152.183.10 
[app-service-6bfc85597c-nrbcm init-mysql] Address:	10.152.183.10:53 
[app-service-6bfc85597c-nrbcm init-mysql]  
[app-service-6bfc85597c-nrbcm init-mysql] Name:	mysql.default.svc.cluster.local 
[app-service-6bfc85597c-nrbcm init-mysql] Address: 10.152.183.217 
[app-service-6bfc85597c-nrbcm init-mysql]  
[app-service-6bfc85597c-nrbcm init-mysql] *** Can't find mysql.svc.cluster.local: No answer 
[app-service-6bfc85597c-nrbcm init-mysql] *** Can't find mysql.cluster.local: No answer 
[app-service-6bfc85597c-nrbcm init-mysql] *** Can't find mysql.default.svc.cluster.local: No answer 
[app-service-6bfc85597c-nrbcm init-mysql] *** Can't find mysql.svc.cluster.local: No answer 
[app-service-6bfc85597c-nrbcm init-mysql] *** Can't find mysql.cluster.local: No answer 
[app-service-6bfc85597c-nrbcm init-mysql] 

Kube stops here, no logs while "app-service" still working.

kubetail breaks when colored grep is enabled, and pod name contains an invalid regex range

OS: OSX 10.14.5 Mojave

When running kubetail myservice, kubetail failed with the following error: grep: invalid character range, and failed to tail any logs. After some digging we found the line that produces a bad list of matching pods:

matching_pods=(`${KUBECTL_BIN} get pods ${context:+--context=${context}} "${selector[@]}" ${namespace_arg} ${cluster} --output=jsonpath='{.items[*].metadata.name}' | xargs -n1 | grep $grep_matcher "${pod}"`)

This is because the matching pod names contain ANSI escape sequences due to coloured grep being enabled. The matching pod names contained square bracket characters that are later used on the following line:

pod_containers=($(echo -e "$all_pods_containers" | grep $pod | cut -d ' ' -f2- | xargs -n1))

leading to the grep: invalid character range error. By changing the first line to the following, we alleviated the issue:

matching_pods=(`${KUBECTL_BIN} get pods ${context:+--context=${context}} "${selector[@]}" ${namespace_arg} ${cluster} --output=jsonpath='{.items[*].metadata.name}' | xargs -n1 | grep --color=never $grep_matcher "${pod}"`)

I believe I only saw this issue because our pod had the following name: myservice-v1-6f4fd875d7-5dgh. The culprit is the 7-5 substring, which is evaluated as an invalid regex range due to the grep colouring.

I can't filter if using namespace option

If I use the -n (namespace) option I'll receive logs from all pods, regardless of the app option

How to reproduce:
kubetail -n MYNAMSPACE my-app

I'll receive logs from all apps in the MYNAMSPACE

The order in which parameters are passed produces different behaviors

Thank you, as well, for the excellent tool. It's very handy.

One thing I noticed is that the order of the parameters causes the script to select a different set of pods. For example:

kubetail mypod -n somenamespace

... will select all pods from "somenamespace" with "mypod" in their names.

However,

kubetail -n somenamespace mypod

... will select all pods from "somenamespace", regardless if they have "mypod" in their name. Looks like an ambiguity in the filter, since the search results for "mypod" get overlapped with the list all pods in that namespace.

I honestly don't mind the script behaving like this. But it would be nice to either change it to make more consistent or warn users in the help text.

First character missing from lines

First character seems to be missing in the logs for some lines.

[iobroker-12-rfnln] I0313 14:58:24.106875       1 interceptors.go:101] Incoming Request: GET /REDACTED?deploymentId=REDACTED&type=stdout&download=false&startTime=1552481337000&endTime=1552488534000&use croll=true HTTP/1.1
 iobroker-12-rfnln] Host: iobroker
 iobroker-12-rfnln] Accept: application/json, text/plain, */*
 iobroker-12-rfnln] Accept-Encoding: gzip, deflate, br
 iobroker-12-rfnln] Accept-Language: en-US,en;q=0.5

Add a feature to write to file

If I am tailing multiple different pods and I want to write it to logs I have to do it by hand unless I want it all to be redirected into a single file. It'd be cool to be able to output each pod's logs to a separate file in real time to be able to handover to devs.

Pretty please and thank you! This tool is already infinitely useful as is!

Tail from different contexts

When running Kubernetes Federation, currently it's only possible to tail one of the clusters by passing the context to kubetail --context, as in kubectl.

Is there any interest in supporting tailing from the whole federation?

If yes, we could:

  • detect that the context belongs to a federation, and tail from all its clusters
  • introduce a new flag --contexts
  • maybe other options

What do you think?

Add watch support for new pods matching a criteria

First of all I just want to thank you for this amazing tool!
I just found it today and it'll definitely stay on my toolbelt.

Any chance there is a way to make it watch for new pods matching the criteria.
In our CD workflow it would be very much in use such a feature

kubetail not killing kube log processes

Hello. I'm on OS X 10.13 using zsh -- not sure what else might affect this.

When I do "kubetail front -e regex" to tail a couple kube pods then hit CTRL-C it doesn't clean up the proceses. It's trying to kill processes matching a kubetail regex however kubectl processes still get left behind: ps -ef yields these two orphans for these two pods:

  501 85637     1   0  9:07AM ttys005    0:00.25 kubectl logs governance-front-service-f6cb85d4b-c92ht governance-front-service -f --since=10s --tail=-1 --namespace=
  501 85640     1   0  9:07AM ttys005    0:00.24 kubectl logs governance-front-service-f6cb85d4b-fqxhf governance-front-service -f --since=10s --tail=-1 --namespace=```

Kubetail kills parent shell

If you call kubetail from a script, it will kill the script when it's done.

% sh -c 'echo shell pid $$; kubetail -k false -f false -s 1s >/dev/null; echo foo'
shell pid 31337
[1]    31337 terminated  sh -c 
%

This forces the user to trap TERM, to avoid failure during successful execution and consequently messes up signal handling in that script, which won't die when sent TERM from elsewhere.

See: https://github.com/johanhaleby/kubetail/blob/master/kubetail#L277

What is the proper way to parse when logs are json?

we tried

kubetail -j <pod> -n <namespace>

we get:

backend/0 is not defined at <top-level>, line 1:
. as $line | try (fromjson | <pod name> ) catch $line

Am i calling this correctly? Our logs for a particular service output as json

Please add an option for disabling default tail

Hi
Thanks for your great product! But it has some misses which seem really useful. For example grep option which there is a pull request which adds this feature. And another essential feature is some option that helps me to get all log of the pods not from now on, I mean not applying tail option. Can you add this feature too?

Add extra options option for Multitail

This fork of Kubetail has helped me a lot but an option I've missed is the ability to send extra options to Multitail. As such:

-O, --multitail-options use additional 'multitail' options from command line (eg. -O "-E {regex}")

Crashes if either of the pods is in PodInitializing state

curiosity~ % kubetail test
Will tail 5 logs...
exasperated-sparrow-test-38122chcrx
exasperated-sparrow-test-38122ft0z7
exasperated-sparrow-test-38122k36w4
exasperated-sparrow-test-38122rfm8s
exasperated-sparrow-test-38122x6v2h
[exasperated-sparrow-test-38122k36w4] Sun, 02 Apr 2017 20:38:31 GMT xfetch:attemptRequest received response (status code) 404
[exasperated-sparrow-test-38122k36w4] Sun, 02 Apr 2017 20:38:31 GMT xfetch:attemptRequest maximum number of attempts has been exhausted
[exasperated-sparrow-test-38122k36w4]
[exasperated-sparrow-test-38122k36w4] /srv/dist/bin/index.js:15
[exasperated-sparrow-test-38122k36w4] throw error;
[exasperated-sparrow-test-38122k36w4] ^
[exasperated-sparrow-test-38122k36w4] UnexpectedResponseCodeError: Unexpected response.
[exasperated-sparrow-test-38122k36w4] at isResponseValid (/srv/test/node_modules/xfetch/dist/index.js:47:11)
[exasperated-sparrow-test-38122k36w4] at operation.attempt (/srv/test/node_modules/xfetch/dist/attemptRequest.js:49:39)
[exasperated-sparrow-test-38122k36w4] at process._tickCallback (internal/process/next_tick.js:109:7)
Error from server (BadRequest): container "test" in pod "exasperated-sparrow-test-38122ft0z7" is waiting to start: PodInitializing

The error terminates the tail.

kubetail should fail if its subprocesses fail

I was trying kubetail (5a238f8) and finding that it leaves behind orphan sub-processes after it exits (#49).

Initially I could see that it spawns a kubectl logs sub-process for each target Pod.
After a while, I noticed that it had fewer kubectl sub-process.

I attempted to run the kubectl logs command manually and noted the following error message:

kubectl logs fluentd-gcp-v2.0.17-hdrqq fluentd-gcp -f --since=10s --tail=-1 --namespace=kube-system
...
failed to create fsnotify watcher: too many open files

And exit code 1.

This seems to be caused by kubernetes/kubernetes#64315

kubetail was masking this error.

I think the kubetail ought to exit with a non-zero code and an error message if its sub-processes exit with a non-zero exit code.

Slow startup

kubetail podname takes about 20s to start on my computer, while this script (myscript.sh podname) takes only about 2s:

#!/bin/bash

declare -a children

onexit() {
        echo "Terminating children: ${children[*]}"
        kill "${children[@]}"
}
trap onexit EXIT

pattern="$1"
while read -r pod _ ; do
        kubectl logs -f pod/"${pod}" &
        children+=("$!")
done < <(kubectl get pods | grep "${pattern}")

sleep infinity

Can the startup time of kubetail be improved to be comparable?

kubetail returns blank logs even when kubectl logs works OK

Versions

os: CentOS 7

kubectl

clientVersion:
  buildDate: "2021-05-12T11:29:07Z"
  compiler: gc
  gitCommit: ac0cc736d0018d817c763083945e4db863168d12
  gitTreeState: clean
  gitVersion: v1.18.19
  goVersion: go1.13.15
  major: "1"
  minor: "18"
  platform: linux/amd64
serverVersion:
  buildDate: "2021-01-13T13:14:05Z"
  compiler: gc
  gitCommit: 73dd5c840662bb066a146d0871216333181f4b64
  gitTreeState: clean
  gitVersion: v1.18.15
  goVersion: go1.13.15
  major: "1"
  minor: "18"
  platform: linux/amd64

kubetail: 1.6.13

Issue

Need some advice on diagnosing.

kubectl logs <pod_name> seems to work okay.

However kubetail does not return any logs (though it does discover the pods). Same result for specifying just 1 pod. The buffer seems empty and when I hit ENTER it acts like stdout is hung and returns a line.

Logs appear to come from a single pod

Thanks for making this script. I tried it out today, and was surprised to see my logs were all coming from a single pod. Here's how to reproduce:

Given two pods are running

$ kubectl run foo --image=busybox --command --replicas=2 -- ping google.com

When I run kubetail foo
Then I see:

(red) foo-221420571-g4pds
(grn) foo-221420571-tatcd
(red) [foo-221420571-tatcd] 64 bytes from 74.125.130.139: seq=177 ttl=47 time=2.001 ms
(grn) [foo-221420571-tatcd] 64 bytes from 74.125.130.138: seq=177 ttl=47 time=2.977 ms

[1.6.0] No pods exists that matches ...

I have installed kubetail via the homebrew tap in the Readme. Prior to June 10, 2018 the brew tap installed version 1.5.0 on my mac which would work:

$ kubetail my-pod
... coloured logs appear ...

Then sometime after June 10, 2018 the tap was updated to install 1.6.0; now when I run:

$ kubetail my-pod
No pods exists that matches my-pod

I'm not sure what's changed between 1.5.0 and 1.6.0 but it seems to break the usage detailed above.

Stops watching when pods restart

If a pod crashes and gets restarted kubetail stops tailing the pod, and any logs from the newly restarted pod are not seen. And since monitoring these types of crashes and the clusters response to them is my main purpose for trying to use kubetail...

Add "with short name" option (ktail)

Hello!

I tend to type ku (then tab) to autocomplete kubectl...
It would be nice to add an isntall option (--with-short-name or something similar) that would install it as ktail rather than kubetail

Thank you

color order for multiple pod

I am partially color blind and hence cannot correclty figure our difference between green and orange. Can we make color options configurable. Example I would love yellow, red and blue
image

--line-buffered doesn't work

I have a container that spits out a log entry every 5 seconds which is annoying. I want to kubetail $args | grep -v annoying but now new output doesn't show up immediately, but shows up in chunks when the buffer fills up. Conclusion: --line-buffered doesn't work.

This doesn't work:

kubetail container --line-buffered | grep -v somethingelse

But this does:

kubectl logs -l app.kubernetes.io/instance=myinstance -f | grep -v somethingelse

Using

kubetail --version
1.6.13-SNAPSHOT

Running kubetail on Ubuntu 16

Getting the below error after installing brew on Ubuntu 16 using Homebrew v.0.9.8

$ brew tap johanhaleby/kubetail && brew install kubetail
Warning: Tap johanhaleby/kubetail already tapped.
Warning: johanhaleby/kubetail/kubetail-1.4.3 already installedl

$  kubetail -v
$  kubetail: command not found

Any suggestions why I'm not able to Exectute kubetail? Thank you

Service/label Logging Support

Hi there,

Awesome project! A coworker asked me if kubectl logs or kubectl exec supported going by service or label and we solved their issue by using a precursor command that gets pods by labels and then loops through running the command for each.

It then hit me that this might be a perfect case for kubetail! So wanted to share the idea.

My thought is the user would indicate they want to tail by label or service and then behind the scenes kubetail would get pods by label or describe service to get the currently matching pods and then tail all of them as if entered manually.

Thanks again for the project! It's quite handy.

kubetail command not working

Here is my pods

kubectl get pods | grep txt-service
txt-service-2988243-26n4q             1/1       Running            1          13h
txt-service-2988243-h9sht             1/1       Running            0          10h

kubetail txt-service
No pods exists that matches txt-service

kubetail txt-service-2988243
No pods exists that matches txt-service

why am I getting this error when pods clearly exists?

Not getting the line output when using ssh channel

I am using jSCH channel to execute the Kubetail command on my K8S cluster. However, if I use ChannelShell instead of channelExec , the output is coming.

Is it changing the output buffer if I use channelExec ?

Completion on Ubuntu with Zsh (Oh My Zsh)

Hello,

I'm on Ubuntu and I use Zsh with Oh my Zsh and I'm not able to add the completion.

I tried to :

  • copy the kubetail.bash script to /etc/bash_completion.d/ but as I use zsh and not bash the file is not used
  • copy the kubetail.zsh script to /usr/local/share/zsh/site-functions/_kubetail but it does nothing.

Thanks, it is a very useful plugin !

After pull request #85, kubetail won't use namespace configured in .kube/config.

@johanhaleby, after pull request #85 and #53, kubetail won't use namespace configured in .kube/config.
The "default" namespace could be already set at .kube/config.

To set the namespace could just run:

# Reference from: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
kubectl config set-context $(kubectl config current-context) --namespace=<insert-namespace-name-here>

# or
# use a utility tool: https://github.com/ahmetb/kubectx
kubens <namespace>

My suggestion is to the variable KUBETAIL_NAMESPACE is really necessary, at least don't hard code default as the default namespace, and get it from:

kubectl config view --minify --output 'jsonpath={..namespace}'

Originally posted by @diego-schmidt-apontador in #85 (comment)

Ability to see the color index number next to display name preview

There is already an option (-z) to skip certain color indices however there is no mapping between the colors that are selected and how they perform in your terminal.

The terminal below shows the display name preview but as you can see there are certain colors that are very hard to see

image

By adding the color index to the output you can more easily see which colors you should suppress

image

This feature could solve #92 as the preview would list each pod name in the selected color and then right after would show the number for the color but the number would be in the default color. A color-blind person could see the display name preview and any color they are not able to see they could add a -z 18,19

I will be submitting a PR shortly

Not able to tail logs of different multiple pod

today I just downloaded this tool and really find helpful.
I am trying to run the below command in order to tail two pod logs simultaneously but it is tailing logs of one pod.

`kubetail wiremock-wiremock-65c5fbdcd4-t6glp,app2-6466c664c7-64cc4`

Will tail 2 logs...
wiremock-wiremock-65c5fbdcd4-t6glp
app2-6466c664c7-64cc4
[wiremock-wiremock-65c5fbdcd4-t6glp] 2020-11-17 18:01:22.886 Received request to /docs with body
[wiremock-wiremock-65c5fbdcd4-t6glp] 2020-11-17 18:01:32.886 Received request to /docs with body
[wiremock-wiremock-65c5fbdcd4-t6glp] 2020-11-17 18:01:42.886 Received request to /docs with body

is there any way how we can tail logs of multiple pods?
the version which I used

./kubetail --version
1.6.13-SNAPSHOT

Usage info implies options can be before pod name

$ kubetail -b foo
usage: grep [-abcDEFGHhIiJLlmnOoqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
	[-e pattern] [-f file] [--binary-files=value] [--color=when]
	[--context[=num]] [--directories=action] [--label] [--line-buffered]
	[--null] [pattern] [file ...]

Turns out the pod name has to be the first argument.

error: unexpected EOF (kubetail 1.5)

hello,
i've upgraded kubetail with using homebrew to 1.5

 ~ kubetail -v                                                                                                                                                              rvm:
1.5.0

i've 1.9 cluster, but i'm using 1.10 client

 ~ kubectl version                                                                                                                                                          rvm:
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.1", GitCommit:"d4ab47518836c750f9949b9e0d387f20fb92260b", GitTreeState:"clean", BuildDate:"2018-04-13T22:29:03Z", GoVersion:"go1.9.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.7", GitCommit:"dd5e1a2978fd0b97d9b78e1564398aeea7e7fe92", GitTreeState:"clean", BuildDate:"2018-04-18T23:58:35Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

here is what happens when i try to tail log for a deployment:

kpw (master) ✔ kubetail kpw                                                                                                                                (master) ✔
Will tail 3 logs...
kpw-6c59c78cd8-jjppp
kpw-6c59c78cd8-s28xl
kpw-6c59c78cd8-tl79d


[kpw-6c59c78cd8-tl79d] 10.244.219.0 - - [10/May/2018:13:49:59 +0000] "GET / HTTP/1.1" 302 -
[kpw-6c59c78cd8-jjppp] 10.244.219.0 - - [10/May/2018:13:49:59 +0000] "GET /?f=u&c=api HTTP/1.1" 200 2859
Unable to connect to the server: unexpected EOF
error: unexpected EOF
error: unexpected EOF

EOF messages started 4-5 seconds after actual log messages

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.