Collect log files from kubernets pods

If your container writs logs to filesystem you really only have three choices that I can think of:

  1. Use a sidecar container to collect logs. This is probably the most straight forward and least intrusive to both your app development and deployment process.

  2. You can mount some sort of volumes to your container’s /var/log/ directory. You can do this either by using persistent volumes, or by making your container DAEMON and mount the volume from host. Neither of which is ideal.

  3. Change your app and write everything to stdout. You can use structured output like JSON to include things such as log file name, so that can be parsed and grouped into separate log streams from your log pipeline. This of course requires cooperation from your app development team.

1 Like