Reputation: 167
My pod have more than one log file, such as php-fpm
+ nginx
stack. How to collect the log files?
I know nginx doing it with symlink. But this cannot deal with more than 2 log files.
I want to mount volume in host to pods, but how to set different folder for every pod? Is there anyway to mount a folder named by podname
in the host to pod folder /logs
.
raychaser gave a way to collect folders to /var/log/containers/
, but I don't think it works in kubernetes.
Upvotes: 4
Views: 4870
Reputation: 167
Finally, I find a way to collect the logs.
/med/log
.entrypoint.sh
./log/$HOSTNAME
ln -sf /log/$HOSTNAME /med/log
.In k8s, you need to mount the host log folder /var/log/k8s/
to /log
. And the log dir looks like:
/var/log/k8s/
|-- app1-${container_id}/
| |-- access.log
| |-- error.log
|-- app2-${container_id}/
|-- access.log
|-- error.log
Upvotes: 3
Reputation: 8835
You can use a logging solution like Fluentd, which allows you to define multiple information sources. As you have several log files it could work for your use case.
http://docs.fluentd.org/v0.12/articles/quickstart http://docs.fluentd.org/v0.12/articles/config-file
Upvotes: 0