diff --git a/cluster/gce/gci/configure-helper.sh b/cluster/gce/gci/configure-helper.sh index 4f657f83f93..f854538a791 100644 --- a/cluster/gce/gci/configure-helper.sh +++ b/cluster/gce/gci/configure-helper.sh @@ -77,12 +77,21 @@ function setup-logrotate() { compress maxsize 10M daily + dateext + dateformat -%Y%m%d-%s create 0644 root root } EOF # Configuration for k8s services that redirect logs to /var/log/.log - # files. + # files. Whenever logrotate is ran, this config will: + # * rotate the log file if its size is > 100Mb OR if one day has elapsed + # * save rotated logs into a gzipped timestamped backup + # * log file timestamp (controlled by 'dateformat') includes seconds too. this + # ensures that logrotate can generate unique logfiles during each rotation + # (otherwise it skips rotation if 'maxsize' is reached multiple times in a + # day). + # * keep only 5 old (rotated) logs, and will discard older logs. local logrotate_files=( "kube-scheduler" "kube-proxy" "kube-apiserver" "kube-controller-manager" "kube-addons" ) for file in "${logrotate_files[@]}" ; do cat > /etc/logrotate.d/${file} <