Sign inSign up

imroc/logrotate

By imroc

Updated over 2 years ago

Image
0

10K+

imroc/logrotate repository overview

A multi-platform docker container of logrotate, can be used as a sidecar.

Configuration

For crond, you can configure it through the following environment variables:

EnvironmentDescriptionDefault
CRON_EXPRcron expression for logrotate*/5 * * * * (every 5 minutes)
CROND_LOGLEVELlog level of crond, 0~8, 0 is the most verbose8

For logrotate, you can directly mount logrotate.conf to /etc/logrotate.conf, or configure the following environment variables:

EnvironmentDescriptionDefault
LOGROTATE_FILE_PATTERNthe file pattern of logs
LOGROTATE_FILESIZEFiles exceeding this size can be rotated50M
LOGROTATE_FILENUMNumber of files to keep rotating5

Example: Rotate the logs of nginx ingress controller

Configure values.yaml for ingress-nginx helm chart:

controller:
  config:
    access-log-path: /var/log/nginx/nginx_access.log
    error-log-path: /var/log/nginx/nginx_error.log
  extraVolumes:
    - name: log
      emptyDir: {}
  extraVolumeMounts:
    - name: log
      mountPath: /var/log/nginx
  extraContainers: # logrotate sidecar
    - name: logrotate
      image: imroc/logrotate:latest
      imagePullPolicy: IfNotPresent
      env:
        - name: LOGROTATE_FILE_PATTERN
          value: "/var/log/nginx/nginx_*.log"
        - name: LOGROTATE_FILESIZE
          value: "20M"
        - name: LOGROTATE_FILENUM
          value: "10"
        - name: CRON_EXPR
          value: "*/1 * * * *"
        - name: CROND_LOGLEVEL
          value: "7"
      volumeMounts:
        - name: log # share log directory
          mountPath: /var/log/nginx

Tag summary

Content type

Image

Digest

sha256:135c769e6

Size

13.3 MB

Last updated

over 2 years ago

docker pull imroc/logrotate