mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
(GCI) Configure logrotate to rotate all .log files in /var/log.
This commit is contained in:
parent
313ef63993
commit
177fee1358
@ -103,8 +103,9 @@ function setup-logrotate() {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Configuration for k8s services that redirect logs to /var/log/<service>.log
|
# Configure log rotation for all logs in /var/log, which is where k8s services
|
||||||
# files. Whenever logrotate is ran, this config will:
|
# 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
|
# * rotate the log file if its size is > 100Mb OR if one day has elapsed
|
||||||
# * save rotated logs into a gzipped timestamped backup
|
# * save rotated logs into a gzipped timestamped backup
|
||||||
# * log file timestamp (controlled by 'dateformat') includes seconds too. This
|
# * 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
|
# (otherwise it skips rotation if 'maxsize' is reached multiple times in a
|
||||||
# day).
|
# day).
|
||||||
# * keep only 5 old (rotated) logs, and will discard older logs.
|
# * 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" )
|
cat > /etc/logrotate.d/allvarlogs <<EOF
|
||||||
for file in "${logrotate_files[@]}" ; do
|
/var/log/*.log {
|
||||||
cat > /etc/logrotate.d/${file} <<EOF
|
|
||||||
/var/log/${file}.log {
|
|
||||||
rotate 5
|
rotate 5
|
||||||
copytruncate
|
copytruncate
|
||||||
missingok
|
missingok
|
||||||
@ -128,7 +127,7 @@ EOF
|
|||||||
create 0644 root root
|
create 0644 root root
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Finds the master PD device; returns it in MASTER_PD_DEVICE
|
# Finds the master PD device; returns it in MASTER_PD_DEVICE
|
||||||
|
Loading…
Reference in New Issue
Block a user