tailing-sidecar icon indicating copy to clipboard operation
tailing-sidecar copied to clipboard

[Proposal] logrotate enhancement

Open JaredTan95 opened this issue 2 years ago • 0 comments

In some scenarios, our application logs in Pod will not rotate log files, such as envoy 's access log.

So, Can we add that feature in tailing sidecar container image

For my undstanding, We have 2 options to support:

  1. We could add a feature by LOGROTATE env in tailing sidecar container image https://github.com/SumoLogic/tailing-sidecar/blob/main/sidecar/Dockerfile

And for sidecar configuration in https://github.com/SumoLogic/tailing-sidecar/blob/main/operator/docs/configuration.md#sidecarspec:

metadata:
  annotations:
    tailing-sidecar: <sidecar-name-0>:<volume-name-0>:<path-to-tail-0>:false;<sidecar-name-1>:<volume-name-1>:<path-to-tail-1>:true 

false are default here and represents don't need logrotate, but this way may looks inflexible.

  1. Or maybe we can support a new annotations like:
metadata:
  annotations:
   tailing-sidecar-logrotate: <log-path-to-rotate-0>:<logrotate-config-json-string>
   #tailing-sidecar-logrotate: sample.log:"{\n size 1k\n copytruncate\n create 700 root root\n rotate 4\n compress\n}"

operator will parse tailing-sidecar-logrotate and make a logrotate.conf in tailing-sidecar-image as follows:

sample.log {
 size 1k
 copytruncate
 create 700 root root
 rotate 4
 compress
}

JaredTan95 avatar Aug 01 '22 08:08 JaredTan95