{"id":13524298,"url":"https://github.com/johanhaleby/kubetail","last_synced_at":"2025-05-13T22:00:16.765Z","repository":{"id":39617187,"uuid":"45980052","full_name":"johanhaleby/kubetail","owner":"johanhaleby","description":"Bash script to tail Kubernetes logs from multiple pods at the same time","archived":false,"fork":false,"pushed_at":"2024-11-28T06:59:57.000Z","size":147,"stargazers_count":3413,"open_issues_count":36,"forks_count":289,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-04-29T13:05:04.990Z","etag":null,"topics":["bash","kubernetes","pod","tail"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johanhaleby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["johanhaleby"]}},"created_at":"2015-11-11T12:21:29.000Z","updated_at":"2025-04-29T11:18:49.000Z","dependencies_parsed_at":"2024-12-27T07:00:32.520Z","dependency_job_id":"81876db2-0529-4f7a-bfde-405a3d997a76","html_url":"https://github.com/johanhaleby/kubetail","commit_stats":{"total_commits":225,"total_committers":55,"mean_commits":4.090909090909091,"dds":"0.31999999999999995","last_synced_commit":"30b00b33f7cdf00a424767004b70b5204f330ea3"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johanhaleby%2Fkubetail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johanhaleby%2Fkubetail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johanhaleby%2Fkubetail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johanhaleby%2Fkubetail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johanhaleby","download_url":"https://codeload.github.com/johanhaleby/kubetail/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254036806,"owners_count":22003651,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","kubernetes","pod","tail"],"created_at":"2024-08-01T06:01:08.777Z","updated_at":"2025-05-13T22:00:16.397Z","avatar_url":"https://github.com/johanhaleby.png","language":"Shell","funding_links":["https://github.com/sponsors/johanhaleby","https://www.buymeacoffee.com/johanhaleby"],"categories":["Monitoring Services","Kubernetes","Shell","Command Line Tools","Tools and Libraries","kubernetes","K8S-Tools","🏗相关开源项目","bash","一、核心工具集（按场景分类）"],"sub_categories":["[Jenkins](#jenkins)","Utils","Command Line Tools","Kubernetes tools","监控工具","1. 命令行效率工具（日常操作必备）"],"readme":"# Kubetail\n\nBash script that enables you to aggregate (tail/follow) logs from multiple pods into one stream.\nThis is the same as running \"kubectl logs -f \u003cpod\u003e\" but for multiple pods.\n\n## Installation\n\nJust download the [kubetail](https://raw.githubusercontent.com/johanhaleby/kubetail/master/kubetail) file (or any of the [releases](https://github.com/johanhaleby/kubetail/releases)) and you're good to go.\n\n### Homebrew\n\nYou can also install kubetail using [brew](https://brew.sh/):\n\n\t$ brew install johanhaleby/kubetail/kubetail\n\nIt's also possible to install kubetail abbreviated to `kt` by using the `--with-short-names` suffix:\n\n\t$ brew install johanhaleby/kubetail/kubetail --with-short-names\n\nNote that you may need to run `compinit` for zsh to pick-up the changes in competition after having upgraded from the non abbreviated installation.\n\nUse `brew install --HEAD johanhaleby/kubetail/kubetail` to install the latest (unreleased) version.\n\n### ASDF\n\nYou can install kubetail using the [asdf](https://github.com/asdf-vm/asdf) version manager.\n\n```\nasdf plugin-add kubetail https://github.com/janpieper/asdf-kubetail.git\nasdf install kubetail \u003cversion\u003e\n```\n\nTo find out the available versions to install, you can run the following command:\n\n```\nasdf list-all kubetail\n```\n\n### ZSH plugin\n\nIf you're using a ZSH plugin manager, you can install `kubetail` as a plugin.\n\n#### Antigen\n\nIf you're using [Antigen](https://github.com/zsh-users/antigen):\n\n1. Add `antigen bundle johanhaleby/kubetail` to your `.zshrc` where you've listed your other plugins.\n2. 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.\n\n#### oh-my-zsh\n\nIf you're using [oh-my-zsh](github.com/robbyrussell/oh-my-zsh):\n\n1. In the command line, change to _oh-my-zsh_'s custom plugin directory :\n\n    `cd ~/.oh-my-zsh/custom/plugins/`\n\n2. Clone the repository into a new `kubetail` directory:\n\n    `git clone https://github.com/johanhaleby/kubetail.git kubetail`\n\n3. Edit your `~/.zshrc` and add `kubetail` – same as clone directory – to the list of plugins to enable:\n\n    `plugins=( ... kubetail )`\n\n4. Then, restart your terminal application to **refresh context** and use the plugin. Alternatively, you can source your current shell configuration:\n\n    `source ~/.zshrc`\n\n#### zgen\n\nIf you're using [zgen](https://github.com/tarjoilija/zgen):\n\n1. Add `zgen load johanhaleby/kubetail` to your `.zshrc` along with your other `zgen load` commands.\n2. `zgen reset \u0026\u0026 zgen save`\n\n### Completion\n\nThe easiest option is to install kubetail from homebrew to dynamically display the pods names on `$ kubetail \u003ctab\u003e`. Alternatively install any of the [completion scripts](completion/) (bash/zsh/fish) manually. For example:\n* On Ubuntu, download the [kubetail.bash](https://raw.githubusercontent.com/johanhaleby/kubetail/master/completion/kubetail.bash) script and execute it in your `~/.bash_completion` file `source $HOME/kubetail/completion/kubetail.bash`. \n* On Mac with zsh copy the [kubetail.zsh](https://raw.githubusercontent.com/johanhaleby/kubetail/master/completion/kubetail.zsh) script to `/usr/local/share/zsh/site-functions/_kubetail`.\n* On Mac with fish copy the [kubetail.fish](https://raw.githubusercontent.com/johanhaleby/kubetail/master/completion/kubetail.fish) script to `~/.config/fish/completions/`.\n\nDon't forget to restart your terminal afterwards.\n\n## Usage\n\nFirst find the names of all your pods:\n\n\t$ kubectl get pods\n\nThis will return a list looking something like this:\n\n```bash\nNAME                   READY     STATUS    RESTARTS   AGE\napp1-v1-aba8y          1/1       Running   0          1d\napp1-v1-gc4st          1/1       Running   0          1d\napp1-v1-m8acl  \t       1/1       Running   0          6d\napp1-v1-s20d0  \t       1/1       Running   0          1d\napp2-v31-9pbpn         1/1       Running   0          1d\napp2-v31-q74wg         1/1       Running   0          1d\nmy-demo-v5-0fa8o       1/1       Running   0          3h\nmy-demo-v5-yhren       1/1       Running   0          2h\n```\n\nTo tail the logs of the two \"app2\" pods in one go simply do:\n\n\t$ kubetail app2\n\nTo tail only a specific container from multiple pods specify the container like this:\n\n\t$ kubetail app2 -c container1\n\nYou can repeat `-c` to tail multiple specific containers:\n\n\t$ kubetail app2 -c container1 -c container2\n\nTo tail multiple applications at the same time seperate them by comma:\n\n\t$ kubetail app1,app2\n\nFor advanced matching you can use regular expressions:\n\n\t$ kubetail \"^app1|.*my-demo.*\" --regex\n\t\nTo tail logs within a specific namespace, make sure to append the namespace flag *after* you have provided values for containers and applications:\n\n\t$ kubetail app2 -c container1 -n namespace1\n\nSupply `-h` for help and additional options:\n\n\t$ kubetail -h\n\n## Colors\n\nBy using the `-k` argument you can specify how kubetail makes use of colors (only applicable when tailing multiple pods).\n\n| Value   |     Description  |\n|----------|---------------|\n| pod | Only the pod name is colorized but the logged text is using the terminal default color |\n| line | The entire line is colorized (default) |\n| false | Don't colorize the output at all |\n   \nExample:\n\n\t$ kubetail app2 -k false\n\nIf 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.\n\t\n## Filtering / Highlighting etc\n\nkubetail itself doesn't have filtering or highlighting capabilities built-in. If you're on MacOSX I recommend using [iTerm2](https://www.iterm2.com/) 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). \n\nIf you're not using iTerm2 or think that kubetail is lacking in features there's a [fork](https://github.com/aks/kubetail) of kubetail made by [Alan Stebbens](https://github.com/aks) that allows for richer configuration and uses [multitail](https://www.vanheusden.com/multitail/) and [bash-lib](https://github.com/aks/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.\n\n## Environment\n\nkubetail can take default option values from environment variables matching the option name.\n\n    KUBETAIL_PREVIOUS\n    KUBETAIL_SINCE\n    KUBETAIL_NAMESPACE\n    KUBETAIL_FOLLOW\n    KUBETAIL_PREFIX\n    KUBETAIL_LINE_BUFFERED\n    KUBETAIL_COLORED_OUTPUT\n    KUBETAIL_TIMESTAMPS\n    KUBETAIL_JQ_SELECTOR\n    KUBETAIL_SKIP_COLORS\n    KUBETAIL_TAIL\n    KUBETAIL_SHOW_COLOR_INDEX\n\n## More\n\nPull requests are very welcome!\n\nSee also: http://code.haleby.se/2015/11/13/tail-logs-from-multiple-pods-simultaneously-in-kubernetes/\n\n\u003ca href=\"https://www.buymeacoffee.com/johanhaleby\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/arial-blue.png\" alt=\"Buy Me A Coffee\" style=\"height: 42px !important;width: 180px !important;\" height=\"42px\" width=\"180px\"\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohanhaleby%2Fkubetail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohanhaleby%2Fkubetail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohanhaleby%2Fkubetail/lists"}