It is a bash script that uses your current kubectl context to interactively select namespaces and multiple pods to download logs from. It basically runs kubectl logs in a loop for all containers, redirecting the logs to local files.
kubelogs relies on whiptail to enable interactive selection.
Whiptail is included by default on Debian. If you are using another OS, make sure to have it installed:
yum install newt
or apt-get install whiptail
brew install newt
Just download the kubelogs file and it's done (download from releases to get stable ones).
Run kubelogs
without any flags to:
- Interactively select a namespace from current context
- Interactively select multiple pods to dump logs from (space bar to check, enter to confirm)
- Input a output dir for log files
Output filenames are created in the form pod_container.log
Use kubelogs --help
for all available options and examples.
Optionally, the --namespace
and --output-dir
flags can be used to skip namespace selection and/or typing of output dir (entirely skipping of whiptail is not supported yet).
Some flags can be passed to kubectl logs that runs under the hood. Use kubelogs --help
to see the available ones.
kubelogs supports the following option values from environment variables:
KUBELOGS_NAMESPACE
KUBELOGS_OUTPUT_DIR
KUBELOGS_TAIL
KUBELOGS_TIMESTAMPS
Pull requests are welcome! Feel free to open an issue to report bugs or requesting new features.