KiweeEu / magento2-on-kubernetes

Configuration to deploy Magento 2 in a Kubernetes cluster
https://kiwee.eu/magento-2-on-kubernetes/
MIT License
81 stars 47 forks source link

How can we store the logs even if the pod is terminated #232

Open Naveen-LinuxAwsguy opened 3 weeks ago

Naveen-LinuxAwsguy commented 3 weeks ago

can we use any PVC path for persistence of logs , including every log

tom00 commented 3 weeks ago

For log persistence, I recommend installing logs aggregation tool like Grafana Loki or ELK (Elasticsearch + Fluentbit + Kibana) . You get logs aggregated in a single database that can be effectively filtered and searched.

macieklewkowicz commented 3 weeks ago

Sure, you can mount var/log and var/reports to a volume, similar topub/media: https://github.com/KiweeEu/magento2-on-kubernetes/blob/3b437451fb65e99d30ae9174cb682c3e03ba2229/deploy/bases/app/magento-web.yaml#L200-L203

You can either use a different subPath or create a new PVC altogether.

However, this project is set up in such a way, that all Magento logs are automatically included in container (Pod) logs. We're using a module for that: https://github.com/KiweeEu/magento2-on-kubernetes/blob/3b437451fb65e99d30ae9174cb682c3e03ba2229/src/composer.json#L24

This is the recommended way of handling application logs: https://12factor.net/logs

These logs are then collected, stored, and managed by a dedicated log aggregation system such as EFK stack, ELK stack, Loki, or a specific solution offered by your cloud provider. See https://www.cncf.io/blog/2023/07/03/kubernetes-logging-best-practices/ for a general overview of how log aggregation works in Kubernetes.

Naveen-LinuxAwsguy commented 1 week ago

where will be php-fpm & php logs will be stored if we want view this

macieklewkowicz commented 1 week ago

PHP, PHP-FPM, Nginx and Magento logs are all forwarded to container stdout.

To view the logs run kubectl logs -n <namespace_name> <pod_name>.

In order to store these logs, you'll need to have log aggregation set up as outlined in my previous comment.