Merge pull request #33224 from fabioy/fix-logrotate

Automatic merge from submit-queue

(GCI) Configure logrotate to rotate all .log files in /var/log.

Fixes logrotate configuration in GCI to rotate all "*.log" files in /var/log. 

Fixes issue #33223.
pull/6/head
Kubernetes Submit Queue 2016-09-21 20:01:35 -07:00 committed by GitHub
commit 290982d6bc
1 changed files with 6 additions and 7 deletions

View File

@ -103,8 +103,9 @@ function setup-logrotate() {
}
EOF
# Configuration for k8s services that redirect logs to /var/log/<service>.log
# files. Whenever logrotate is ran, this config will:
# Configure log rotation for all logs in /var/log, which is where k8s services
# are configured to write their log 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
@ -112,10 +113,8 @@ EOF
# (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} <<EOF
/var/log/${file}.log {
cat > /etc/logrotate.d/allvarlogs <<EOF
/var/log/*.log {
rotate 5
copytruncate
missingok
@ -128,7 +127,7 @@ EOF
create 0644 root root
}
EOF
done
}
# Finds the master PD device; returns it in MASTER_PD_DEVICE