Coder Social home page Coder Social logo

ktail's Introduction

ktail is a tool to tail Kubernetes containers

It's like kubectl logs, but with a bunch of nice features

Terminal animation

Detects pods and containers as they come and go. If you run ktail foo and later start a pod or container named foo, then it will be picked up automatically. kubectl only works on a running pod/container.

Tails multiple pods and containers in multiple namespaces at the same time, based on names and labels. kubectl can only tail a single pod and container. ktail will match the pattern or patterns you specify against both the pod name and the container name.

All containers in a pod are tailed by default, not just a specific one. With kubectl, you have to use -c. With ktail, just do ktail foo and all its containers are automatically tailed.

Recovers from failure. ktail will keep retrying forever. kubectl often just gives up.

Better formatting. ktail will show log lines in different colours, and has syntax highlighting of JSON payloads.

Usage

ktail makes it super easy to tail by pod or container name. The following will match all containers whose pod name or container name contains the substring foo:

$ ktail foo

The arguments are regular expressions, so this is possible:

$ ktail '^foo'

If no filters are specified, all pods in the current namespace are tailed.

Tailing supports the usual things like labels:

$ ktail -l app=myapp

This will tail all containers in all pods matching the label app=myapp. As new pods are created, it will also automatically tail those, too.

To abort tailing, hit Ctrl+C.

Options

Run ktail -h for usage.

Configuration

Ktail will read the file $HOME/.config/ktail/config.yml if it exists. This must be a file in YAML format. The following options can be set (these are the defaults):

noColor: false
raw: false
timestamps: false
quiet: false
colorScheme: bw
colorMode: auto
kubeConfigPath: ""
templateString: ""

Templating

ktail has a basic output format. To override, you can use a simple Go template. For example:

$ ktail -t "{{.Container.Name}} {{.Message}}"

The following variables are available:

  • Timestamp: The time of the log event.
  • Message: The log message.
  • Pod: The pod object. It has properties such as Name, Namespace, Status, etc.
  • Container: The container object. It has properties such as Name.

Installation

Homebrew

$ brew tap atombender/ktail
$ brew install atombender/ktail/ktail

Binary installation

Precompiled binaries for Windows, macOS, Linux (x64 and ARM) are available on the GitHub release page.

From source

This requires Go >= 1.10, as we use Go modules.

$ mkdir -p $GOPATH/src/github.com/atombender
$ cd $GOPATH/src/github.com/atombender
$ git clone https://github.com/atombender/ktail
$ cd ktail
$ go install .

Acknowledgements

Some setup code was borrowed from k8stail.

License

MIT license. See LICENSE file.

ktail's People

Contributors

atombender avatar code0x58 avatar dependabot[bot] avatar nneul avatar ruckc avatar schellj avatar sstarcher avatar testwill avatar unguiculus avatar vadasambar 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

ktail's Issues

WARNING: 50% of Log Entries are Duplicates

@atombender: thanks for the tool

I've been chasing down log duplicates in our logging pipeline. Out of 562 million log entries, half of those are "unique". About 33% of them are repeated lines, where the previous line is byte-for-byte identical as the current line. I'm fairly certain that ktail is the culprit as the custom template I'm outputting is duplicated as well.

I used mmuniq-hash and mmuniq-bloom to get the 50% numbers.

I'm not sure if k8s has made changes or if there is a bug.

Related to #4 -- however, no stateful sets were in use.

brew upgrade?

Hi @atombender ,

Can you please upgrade the version of ktail available in homebrew? It is still on 0.11, which doesn't support oidc login.

Thanks in advance,
Tommy

unable to run ktail

~ ktail --version
ktail 1.0.1

 ktail  foo-pod -n foo
stat /Users/vamsee.lakamsani/.kube/lab.yaml:/Users/vamsee.lakamsani/.kube/config no such file or directory%

kubectl works fine in the same terminal. Context is already set with cluster and namespace using kubectl config use-context. Same issue with the --context flag as well. Somethi

ktail continually prints connection warnings/errors after losing network connection

I usually have a terminal window open running ktail on one or more deployments/statefulsets. If I close my laptop and come back later, the terminal window will be continually printing the warnings/errors below.
The logs will resume tailing as expected if I quit ktail and run the same command that was running.

==> Warning: Error while tailing container [xxx-1:yyy]: Get https://xxx.xxx.xxx.xxx/api/v1/namespaces/default/pods/xxx-1/log?container=yyy&follow=true&sinceTime=2020-04-14T18%3A52%3A51Z&timestamps=true: http2: no cached connection was available
E0414 14:11:26.286144   59041 reflector.go:205] pkg/mod/k8s.io/[email protected]+incompatible/tools/cache/reflector.go:99: Failed to list *v1.Pod: Get https://xxx.xxx.xxx.xxx/api/v1/namespaces/default/pods?limit=500&resourceVersion=0: http2: no cached connection was available
E0414 14:11:27.290462   59041 reflector.go:205] pkg/mod/k8s.io/[email protected]+incompatible/tools/cache/reflector.go:99: Failed to list *v1.Pod: Get https://xxx.xxx.xxx.xxx/api/v1/namespaces/default/pods?limit=500&resourceVersion=0: http2: no cached connection was available
E0414 14:11:28.292712   59041 reflector.go:205] pkg/mod/k8s.io/[email protected]+incompatible/tools/cache/reflector.go:99: Failed to list *v1.Pod: Get https://xxx.xxx.xxx.xxx/api/v1/namespaces/default/pods?limit=500&resourceVersion=0: http2: no cached connection was available
E0414 14:11:29.295761   59041 reflector.go:205] pkg/mod/k8s.io/[email protected]+incompatible/tools/cache/reflector.go:99: Failed to list *v1.Pod: Get https://xxx.xxx.xxx.xxx/api/v1/namespaces/default/pods?limit=500&resourceVersion=0: http2: no cached connection was available
E0414 14:11:30.296057   59041 reflector.go:205] pkg/mod/k8s.io/[email protected]+incompatible/tools/cache/reflector.go:99: Failed to list *v1.Pod: Get https://xxx.xxx.xxx.xxx/api/v1/namespaces/default/pods?limit=500&resourceVersion=0: http2: no cached connection was available

(Statefulset, container, and IP addresses redacted)

ktail on statefulset duplicates

If running ktail statefulpod-0 it will tail the pod. If that pod is killed lets say 5 times. Ktail will now tail the latest pod and output the information 5 times.

Feature suggestion - colorized (per pod) output

I got here looking for an alternative to kubetail. One of it's limitations is that it doesn't see new pods as they are created.

However, one feature of kubetail that is missing in ktail is it's colorization support. Kubetail picks a different randomly assigned color for each container - so if you are watching multiple, you can easily see from one set of output to the next.

That would be a nice feature to see added here.

New Release

I built ktail from master and PR #8 resolves an issue my team has encountered. Would you be able to cut a new release with these changes included?

Documentation: Add Warning / Known Issues to the README

I appreciate the time you spent on ktail and thought it was nifty.

I also know how much time and pain it has caused to troubleshoot for us.

If you don't have time to fix the bug; can you please mark it as a known issue in the readme and/or deprecate the repo?

RE: #14 #4

Upgrade to 0.11.0 via homebrew fails on macOS 10.14.5

$ brew upgrade ktail -v
==> Upgrading 1 outdated package:
atombender/ktail/ktail 0.10.0 -> 0.11.0
==> Upgrading atombender/ktail/ktail
rm /usr/local/bin/ktail
/usr/bin/sandbox-exec -f /private/tmp/homebrew20190717-89952-el9ron.sb nice /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -W0 -I /usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/simplecov-cobertura-1.3.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/ruby-macho-2.2.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rubocop-rspec-1.33.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rubocop-performance-1.4.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rubocop-0.72.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/unicode-display_width-1.6.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/ruby-progressbar-1.10.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rspec-wait-0.0.9/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rspec-retry-0.6.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rspec-its-1.3.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rspec-3.8.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rspec-mocks-3.8.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rspec-expectations-3.8.4/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rspec-core-3.8.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rspec-support-3.8.2/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/ronn-0.7.3/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rdiscount-2.2.0.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/extensions/universal-darwin-18/2.3.0/rdiscount-2.2.0.1:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/rainbow-3.0.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/plist-3.5.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/parser-2.6.3.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/parallel_tests-2.29.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/parallel-1.17.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/mustache-1.1.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/mechanize-2.7.6/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/webrobots-0.1.2/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/ntlm-http-0.1.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/nokogiri-1.10.3/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/extensions/universal-darwin-18/2.3.0/nokogiri-1.10.3:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/mini_portile2-2.4.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/net-http-persistent-3.0.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/net-http-digest_auth-1.4.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/mime-types-3.2.2/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/mime-types-data-3.2019.0331/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/jaro_winkler-1.5.3/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/extensions/universal-darwin-18/2.3.0/jaro_winkler-1.5.3:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/http-cookie-1.0.3/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/hpricot-0.8.6/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/extensions/universal-darwin-18/2.3.0/hpricot-0.8.6:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/domain_name-0.5.20180417/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/unf-0.1.4/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/unf_ext-0.0.7.6/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/extensions/universal-darwin-18/2.3.0/unf_ext-0.0.7.6:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/diff-lcs-1.3/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/coveralls-0.8.23/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/thor-0.20.3/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/term-ansicolor-1.7.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/tins-1.20.3/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/simplecov-0.16.1/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/simplecov-html-0.10.2/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/docile-1.3.2/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/json-2.2.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/extensions/universal-darwin-18/2.3.0/json-2.2.0:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/connection_pool-2.2.2/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/backports-3.15.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/ast-2.4.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/activesupport-5.2.3/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/tzinfo-1.2.5/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/thread_safe-0.3.6/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/minitest-5.11.3/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/i18n-1.6.0/lib:/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.3.0/gems/concurrent-ruby-1.1.5/lib:/Library/Ruby/Site/2.3.0:/Library/Ruby/Site/2.3.0/x86_64-darwin18:/Library/Ruby/Site/2.3.0/universal-darwin18:/Library/Ruby/Site:/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/vendor_ruby/2.3.0:/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/vendor_ruby/2.3.0/x86_64-darwin18:/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/vendor_ruby/2.3.0/universal-darwin18:/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/vendor_ruby:/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0:/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/x86_64-darwin18:/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/universal-darwin18:/usr/local/Homebrew/Library/Homebrew -- /usr/local/Homebrew/Library/Homebrew/build.rb /usr/local/Homebrew/Library/Taps/atombender/homebrew-ktail/ktail.rb --verbose
==> Cloning https://github.com/atombender/ktail.git
Updating /Users/kforsthoevel/Library/Caches/Homebrew/ktail--git
git config remote.origin.url https://github.com/atombender/ktail.git
git config remote.origin.fetch \+refs/tags/v0.11.0:refs/tags/v0.11.0
git config remote.origin.tagOpt --no-tags
==> Checking out tag v0.11.0
git checkout -f v0.11.0 --
HEAD is now at 8616853 .travis.yml: Update API key.
git reset --hard v0.11.0 --
HEAD is now at 8616853 .travis.yml: Update API key.
cp -pR /Users/kforsthoevel/Library/Caches/Homebrew/ktail--git/controller.go /private/tmp/d20190717-89953-41795x/controller.go
cp -pR /Users/kforsthoevel/Library/Caches/Homebrew/ktail--git/go.mod /private/tmp/d20190717-89953-41795x/go.mod
cp -pR /Users/kforsthoevel/Library/Caches/Homebrew/ktail--git/LICENSE /private/tmp/d20190717-89953-41795x/LICENSE
cp -pR /Users/kforsthoevel/Library/Caches/Homebrew/ktail--git/CHANGELOG.md /private/tmp/d20190717-89953-41795x/CHANGELOG.md
cp -pR /Users/kforsthoevel/Library/Caches/Homebrew/ktail--git/tailer.go /private/tmp/d20190717-89953-41795x/tailer.go
cp -pR /Users/kforsthoevel/Library/Caches/Homebrew/ktail--git/Makefile /private/tmp/d20190717-89953-41795x/Makefile
cp -pR /Users/kforsthoevel/Library/Caches/Homebrew/ktail--git/go.sum /private/tmp/d20190717-89953-41795x/go.sum
cp -pR /Users/kforsthoevel/Library/Caches/Homebrew/ktail--git/README.md /private/tmp/d20190717-89953-41795x/README.md
cp -pR /Users/kforsthoevel/Library/Caches/Homebrew/ktail--git/.gitignore /private/tmp/d20190717-89953-41795x/.gitignore
cp -pR /Users/kforsthoevel/Library/Caches/Homebrew/ktail--git/matching.go /private/tmp/d20190717-89953-41795x/matching.go
cp -pR /Users/kforsthoevel/Library/Caches/Homebrew/ktail--git/.git/. /private/tmp/d20190717-89953-41795x/.git
cp -pR /Users/kforsthoevel/Library/Caches/Homebrew/ktail--git/.travis.yml /private/tmp/d20190717-89953-41795x/.travis.yml
cp -pR /Users/kforsthoevel/Library/Caches/Homebrew/ktail--git/main.go /private/tmp/d20190717-89953-41795x/main.go
cp -pR /private/tmp/d20190717-89953-41795x/controller.go /private/tmp/ktail-20190717-89953-b1xbhf/controller.go
cp -pR /private/tmp/d20190717-89953-41795x/go.mod /private/tmp/ktail-20190717-89953-b1xbhf/go.mod
cp -pR /private/tmp/d20190717-89953-41795x/LICENSE /private/tmp/ktail-20190717-89953-b1xbhf/LICENSE
cp -pR /private/tmp/d20190717-89953-41795x/CHANGELOG.md /private/tmp/ktail-20190717-89953-b1xbhf/CHANGELOG.md
cp -pR /private/tmp/d20190717-89953-41795x/tailer.go /private/tmp/ktail-20190717-89953-b1xbhf/tailer.go
cp -pR /private/tmp/d20190717-89953-41795x/Makefile /private/tmp/ktail-20190717-89953-b1xbhf/Makefile
cp -pR /private/tmp/d20190717-89953-41795x/go.sum /private/tmp/ktail-20190717-89953-b1xbhf/go.sum
cp -pR /private/tmp/d20190717-89953-41795x/README.md /private/tmp/ktail-20190717-89953-b1xbhf/README.md
cp -pR /private/tmp/d20190717-89953-41795x/.gitignore /private/tmp/ktail-20190717-89953-b1xbhf/.gitignore
cp -pR /private/tmp/d20190717-89953-41795x/matching.go /private/tmp/ktail-20190717-89953-b1xbhf/matching.go
cp -pR /private/tmp/d20190717-89953-41795x/.git/. /private/tmp/ktail-20190717-89953-b1xbhf/.git
cp -pR /private/tmp/d20190717-89953-41795x/.travis.yml /private/tmp/ktail-20190717-89953-b1xbhf/.travis.yml
cp -pR /private/tmp/d20190717-89953-41795x/main.go /private/tmp/ktail-20190717-89953-b1xbhf/main.go
chmod -Rf +w /private/tmp/d20190717-89953-41795x
==> glide install --strip-vendor
Failed to execute: glide install --strip-vendor

==> Formula
Tap: atombender/ktail
Path: /usr/local/Homebrew/Library/Taps/atombender/homebrew-ktail/ktail.rb
==> Configuration
HOMEBREW_VERSION: 2.1.7
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: 2b83463091513826127c14acae81a7c354dfce69
Last commit: 9 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: d81f4c8f24b72f536bc895c877643f8c7474a0b3
Core tap last commit: 11 hours ago
HOMEBREW_PREFIX: /usr/local
CPU: quad-core 64-bit skylake
Homebrew Ruby: 2.3.7 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 10.0 build 1001
Git: 2.22.0 => /usr/local/bin/git
Curl: 7.54.0 => /usr/bin/curl
macOS: 10.14.5-x86_64
CLT: 10.2.1.0.1.1554506761
Xcode: 10.2.1
CLT headers: 10.2.1.0.1.1554506761
==> ENV
HOMEBREW_CC: clang
HOMEBREW_CXX: clang++
MAKEFLAGS: -j4
CMAKE_PREFIX_PATH: /usr/local
CMAKE_INCLUDE_PATH: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers
CMAKE_LIBRARY_PATH: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries
PKG_CONFIG_LIBDIR: /usr/lib/pkgconfig:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.14
HOMEBREW_GIT: git
HOMEBREW_SDKROOT: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
ACLOCAL_PATH: /usr/local/share/aclocal
PATH: /usr/local/Homebrew/Library/Homebrew/shims/mac/super:/usr/local/opt/go/bin:/usr/bin:/bin:/usr/sbin:/sbin

Error: atombender/ktail/ktail 0.11.0 did not build
Logs:
     /Users/kforsthoevel/Library/Logs/Homebrew/ktail/00.options.out
     /Users/kforsthoevel/Library/Logs/Homebrew/ktail/01.glide
If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):
  https://github.com/atombender/homebrew-ktail/issues


ln -s ../Cellar/ktail/0.10.0/bin/ktail ktail
==> Checking dependents for outdated formulae
==> No dependents to upgrade
==> Checking dependents for broken library links
==> No broken dependents to reinstall

Could anyone help please? Thanks.

Linux build documentation?

Hey there 👋
Neat project!

I've somehow avoided Go for a decade+, so I'm not familiar with its toolchain.

Issue

Is there more information needed for building on modern GNU/Linux systems?
Can't for the life of me build this project on Linux.
Spent an hour investigating and trying.

Troubleshooting Details

Distro: Arch Linux (kernel 5.19.5)
Go version: go1.19 linux/amd64

Per the README:

$ mkdir -p $GOPATH/src/github.com/atombender
$ cd $GOPATH/src/github.com/atombender
$ git clone https://github.com/atombender/ktail
$ cd ktail
$ go install .
go: downloading github.com/jpillora/backoff v1.0.0
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/alecthomas/chroma v0.10.0
go: downloading k8s.io/api v0.25.3
go: downloading github.com/fatih/color v1.7.0
go: downloading k8s.io/apimachinery v0.25.3
go: downloading github.com/go-logr/logr v1.2.3
go: downloading k8s.io/client-go v0.25.3
go: downloading k8s.io/klog/v2 v2.80.1
go: downloading github.com/mattn/go-colorable v0.1.12
go: downloading github.com/mattn/go-isatty v0.0.14
go: downloading github.com/gogo/protobuf v1.3.2
go: downloading github.com/google/gofuzz v1.1.0
go: downloading k8s.io/utils v0.0.0-20221012122500-cfd413dd9e85
go: downloading github.com/dlclark/regexp2 v1.4.0
go: downloading sigs.k8s.io/structured-merge-diff/v4 v4.2.3
go: downloading gopkg.in/inf.v0 v0.9.1
go: downloading golang.org/x/sys v0.1.0
go: downloading sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2
go: downloading golang.org/x/net v0.1.0
go: downloading github.com/json-iterator/go v1.1.12
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
go: downloading github.com/modern-go/reflect2 v1.0.2
go: downloading golang.org/x/oauth2 v0.1.0
go: downloading github.com/golang/protobuf v1.5.2
go: downloading github.com/google/gnostic v0.5.7-v3refs
go: downloading github.com/imdario/mergo v0.3.6
go: downloading golang.org/x/term v0.1.0
go: downloading golang.org/x/time v0.0.0-20220210224613-90d013bbcef8
go: downloading sigs.k8s.io/yaml v1.2.0
go: downloading google.golang.org/protobuf v1.28.1
go: downloading k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/google/go-cmp v0.5.8
go: downloading cloud.google.com/go v0.97.0
go: downloading golang.org/x/text v0.4.0
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822
go: downloading github.com/go-openapi/swag v0.19.14
go: downloading github.com/emicklei/go-restful/v3 v3.8.0
go: downloading github.com/go-openapi/jsonreference v0.19.5
go: downloading github.com/go-openapi/jsonpointer v0.19.5
go: downloading github.com/PuerkitoBio/purell v1.1.1
go: downloading github.com/mailru/easyjson v0.7.6
go: downloading github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578
go: downloading github.com/josharian/intern v1.0.0
# github.com/atombender/ktail
./main.go:101:18: undefined: isTerminal
$

^ Undefined symbol isTerminal.

--
Let's find out where that's called in the code:

$ grep -RI isTerminal .
./main.go
101:            colorEnabled = isTerminal(os.Stdout)

--
Ok, let's find out which module that comes from:

$ grep -RIl isTerminal $GOPATH/pkg/mod/
/data/go/pkg/mod/k8s.io/[email protected]/plugin/pkg/client/auth/exec/exec_test.go
/data/go/pkg/mod/golang.org/x/[email protected]/term_plan9.go
/data/go/pkg/mod/golang.org/x/[email protected]/term.go
/data/go/pkg/mod/golang.org/x/[email protected]/term_windows.go
/data/go/pkg/mod/golang.org/x/[email protected]/term_unix.go
/data/go/pkg/mod/golang.org/x/[email protected]/term_unsupported.go

^ Seems like golang.org/x/term.

--
Let's see where that module is imported:

$ grep -RIi x/term
go.mod
45:     golang.org/x/term v0.1.0 // indirect

go.sum
407:golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
408:golang.org/x/term v0.1.0 h1:g6Z6vPFA9dYBAF7DWcH6sCcOntplXsDKcliusYijMlw=
409:golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=

^ go.mod and go.sum. Ok, I really don't know Go...

--
Maybe it needs to be imported in main.go?! 🙂

$ go install .
# github.com/atombender/ktail
./main.go:19:9: imported and not used: "golang.org/x/term"
./main.go:102:18: undefined: isTerminal

^ Nope ("Imported and not used")! 😅

--
Let's find the commit(s) where isTerminal is modified:

$ git log -GisTerminal -p
commit 0ca582825e6be80ee34ecfd2f56b0d7b55b23c61
Author: Alexander Staubo <[email protected]>
Date:   Mon Oct 17 13:17:25 2022 +0200

    feat: don't enable colour when not writing to a tty; adds --color/--colour to
    control colour output precisely.
diff --git a/main.go b/main.go
index 422ec6a..81c96a9 100644
--- a/main.go
+++ b/main.go
@@ -43,6 +43,7 @@ func main() {
                includePatterns       []*regexp.Regexp
                excludePatternStrings []string
                noColor               bool
+               colorMode             string
        )

        flags := pflag.NewFlagSet("ktail", pflag.ExitOnError)
@@ -68,7 +69,9 @@ func main() {
        flags.BoolVarP(&sinceStart, "since-start", "s", false,
                "Start reading log from the beginning of the container's lifetime.")
        flags.BoolVarP(&showVersion, "version", "", false, "Show version.")
-       flags.BoolVarP(&noColor, "no-color", "", false, "Disable color.")
+       flags.BoolVar(&noColor, "no-color", false, "Alias for --color=never.")
+       flags.StringVar(&colorMode, "color", "auto", "Set color mode: one of 'auto' (default), 'never', or 'always'.")
+       flags.StringVar(&colorMode, "colour", "auto", "Set color mode: one of 'auto' (default), 'never', or 'always'.")

        if err := flags.Parse(os.Args[1:]); err != nil {
                if err == pflag.ErrHelp {
@@ -78,7 +81,19 @@ func main() {
                os.Exit(1)
        }

-       color.NoColor = noColor
+       if noColor {
+               colorMode = "never"
+       }
+       var colorEnabled bool
+       switch colorMode {
+       case "always":
+               colorEnabled = true
+       case "auto":
+               colorEnabled = isTerminal(os.Stdout)
+       case "never":
+       }
+
+       color.NoColor = !colorEnabled

        if showVersion {
                fmt.Printf("ktail %s\n", version)
@@ -222,7 +237,7 @@ func main() {
                        }

                        payload := event.Message
-                       if !noColor && len(payload) >= 2 && payload[0] == '{' && payload[len(payload)-1] == '}' {
+                       if colorEnabled && len(payload) >= 2 && payload[0] == '{' && payload[len(payload)-1] == '}' {
                                var dest interface{}
                                if err := json.Unmarshal([]byte(payload), &dest); err == nil {
                                        var buf bytes.Buffer

^ Ok, just one commit. Fairly recent... maybe not battle-tested "building in the wild" yet... 🤔

--
Find any commits involving the string "x/term":

$ git log -Gx/term --stat
commit 80ddf41b886ba762fb10a3ce0041e20d3fa8bffa
Author: Alexander Staubo <[email protected]>
Date:   Thu Oct 20 23:14:32 2022 +0200

    feat: upgrades Kubernetes client and HTTP2 client to pick up bug fixes etc.

 go.mod |  53 +++++++++++++----------
 go.sum | 243 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------
 2 files changed, 164 insertions(+), 132 deletions(-)

commit d94d59538c9f185c4a1649af4f1c7908472c5ba8
Author: Curtis Ruck <[email protected]>
Date:   Thu Dec 16 13:15:51 2021 -0500

    update dependencies to latest kubernetes client version

 go.mod |  49 ++++++--
 go.sum | 621 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------
 2 files changed, 560 insertions(+), 110 deletions(-)

^ Just lots of go.mod and go.sum noise.

--
Ok.
Discover goimports tool.
Install it with go install golang.org/x/tools/cmd/goimports@latest.
Run it:

$ goimports -d main.go
$

^ No output. goimports thinks everything is legit as hell. 😞

--
I then desperately tried make build, make clean, go clean, export GODEBUG=gocacheverify=1, and wiping out my entire build cache and modules directory, etc etc etc.

No amount of Googling and nothing I could do would make it compile.

Is there something wrong with my Go installation?
Seems like I can go install everything else.

Thanks!

Please add `--version` flag

Please add a --version flag that simply returns the version and exits. (for future releases)

Thanks in advance,
Tommy

Mac install with M1 Chip fails

Error Details :

# golang.org/x/sys/unix
../../../../pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:28:3: //go:linkname must refer to declared function or variable
../../../../pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:43:3: //go:linkname must refer to declared function or variable
../../../../pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:59:3: //go:linkname must refer to declared function or variable
../../../../pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:75:3: //go:linkname must refer to declared function or variable
../../../../pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:90:3: //go:linkname must refer to declared function or variable
../../../../pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:105:3: //go:linkname must refer to declared function or variable
../../../../pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:121:3: //go:linkname must refer to declared function or variable
../../../../pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:136:3: //go:linkname must refer to declared function or variable
../../../../pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:151:3: //go:linkname must refer to declared function or variable
../../../../pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:166:3: //go:linkname must refer to declared function or variable
../../../../pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:166:3: too many errors
make: *** [/private/tmp/ktail-20220503-99886-1hubp9t/src/github.com/atombender/ktail/build/ktail] Error 2

==> Formula
Tap: atombender/ktail
Path: /opt/homebrew/Library/Taps/atombender/homebrew-ktail/ktail.rb
==> Configuration
HOMEBREW_VERSION: 3.4.10
ORIGIN: https://github.com/Homebrew/brew
HEAD: 3088bbf1a696961cd4202d9ef85ac5f95b977e7c
Last commit: 3 days ago

Env Details :

==> ENV
HOMEBREW_CC: clang
HOMEBREW_CXX: clang++
MAKEFLAGS: -j10
CMAKE_PREFIX_PATH: /opt/homebrew
CMAKE_INCLUDE_PATH: /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers
CMAKE_LIBRARY_PATH: /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries
PKG_CONFIG_LIBDIR: /usr/lib/pkgconfig:/opt/homebrew/Library/Homebrew/os/mac/pkgconfig/12
HOMEBREW_GIT: git
HOMEBREW_SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
ACLOCAL_PATH: /opt/homebrew/share/aclocal
PATH: /opt/homebrew/Library/Homebrew/shims/mac/super:/opt/homebrew/opt/go/bin:/usr/bin:/bin:/usr/sbin:/sbin

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.