protokol

command module
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2023 License: MIT Imports: 20 Imported by: 0

README

protokol - Collect Kubernetes Pod Logs with Ease

protokol is a command line tool to watch for pods and storing their logs as text files on your local machine. It's primarily intended to be used in test scenarios where you need to gather logs of many different, possibly restarting or reconciled pods at the same time.

Installation

You can download a binary for the latest release on GitHub or install protokol via Go:

go install go.xrstf.de/protokol

Usage

Usage of protokol:
  -c, --container stringArray   Container names to store logs for (supports glob expression) (can be given multiple times)
      --events                  Dump events for each matching Pod as a human readable log file (note: label selectors are not respected)
      --events-raw              Dump events for each matching Pod as YAML (note: label selectors are not respected)
  -f, --flat                    Do not create directory per namespace, but put all logs in the same directory
      --kubeconfig string       kubeconfig file to use (uses $KUBECONFIG by default)
  -l, --labels string           Label-selector as an alternative to specifying resource names
      --live                    Only consider running pods, ignore completed/failed pods
      --metadata                Dump Pods additionally as YAML (note that this can include secrets in environment variables)
  -n, --namespace stringArray   Kubernetes namespace to watch resources in (supports glob expression) (can be given multiple times)
      --oneshot                 Dump logs, but do not tail the containers (i.e. exit after downloading the current state)
  -o, --output string           Directory where logs should be stored
      --prefix string           Prefix pattern to put at the beginning of each streamed line (pn = Pod name, pN = Pod namespace, c = container name) (default "[%pN/%pn:%c] >>")
      --stream                  Do not just dump logs to disk, but also stream them to stdout
  -v, --verbose                 Enable more verbose output

Examples

protokol '*'

This is the BFG: it will watch all Pods in all namespaces and stream the logs for each running container to a text file in your disk. Don't do this, you do not want to kill the apiserver with a gazillion streams.

protokol -n kube-system -n 'cluster-*'

You can restrict the Pods to a set of namespaces. Wildcards are allowed.

protokol -l 'foo=bar'

Label selectors work just as you would expect.

protokol 'kube-*' 'coredns-*' 'etcd-*'

You can give multiple name patterns, placeholders are allowed.

protokol -c 'test*' 'kube-*' 'coredns-*' 'etcd-*'

You can restrict the container names using -c. This flag can be given multiple times and also supports wildcards.

protokol -o test 'kube-*' 'coredns-*' 'etcd-*'

By default protokol will create a protokol-%Y%m%dT%m.%h%s directory whenever you invoke it, but you can also specify a directory yourself.

protokol -o test -f 'kube-*' 'coredns-*' 'etcd-*'

By default protokol will create one directory per namespace. With -f (--flat) you can disable this behaviour.

protokol --stream 'etcd-*'

This will not just dump the logs to disk, but also stream them to stdout.

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL