[K8s] Persisting Audit logs

I used helm charts to deploy Percona Server for MongoDB and now I need to persist the audit logs in an external PVC.
I can’t find an option in helm charts to mount an external volume to mongos pod.

How can I persist audit logs?

3 Likes

Hi @reab, thank you for your question in the Percona forum.

If you want to persist audit logs, a good way to do it is by using Sidecar containers. Using a sidecar container is indeed a classic and often the best approach for managing tasks such as transferring, processing, and storing logs in a Kubernetes environment, especially when working with complex applications.
Here there is an example of sidecars for MySQL.

 sidecars:
    - image: busybox:latest 
      command: ["/bin/sh"]  
      args:
      - "-c"
      - |
        trap 'echo "got sigterm" ; exit 0' SIGTERM
        tail -n 20 -F /var/lib/mysql/audit.log &
        while true; do sleep 1; done
      name: audit-tail
      resources: 
        requests:
          memory: 100M    
          cpu: 100m
        limits:
          memory: 200M
          cpu: 200m
      volumeMounts:   
      - mountPath: /var/lib/mysql
        name: datadir

You could adapt it to your needs.

Yes, our Operator supports the mounting of external volumes. These volumes can be either a host path or a volume with a specific StorageClass. A host path allows for the mounting of a specific directory on the Kubernetes node (e.g., a NFS root). With StorageClass, users can select NAS/SAN-based volumes.

Let me know if this answers your question, and if you have more questions, don’t hesitate to write to us.