@@ -439,17 +439,19 @@ function ensure-local-ssds() {
439
439
# Installs logrotate configuration files
440
440
function setup-logrotate() {
441
441
mkdir -p /etc/logrotate.d/
442
- # Configure log rotation for all logs in /var/log, which is where k8s services
443
- # are configured to write their log files. Whenever logrotate is ran, this
444
- # config will:
445
- # * rotate the log file if its size is > 100Mb OR if one day has elapsed
446
- # * save rotated logs into a gzipped timestamped backup
447
- # * log file timestamp (controlled by 'dateformat') includes seconds too. This
448
- # ensures that logrotate can generate unique logfiles during each rotation
449
- # (otherwise it skips rotation if 'maxsize' is reached multiple times in a
450
- # day).
451
- # * keep only 5 old (rotated) logs, and will discard older logs.
452
- cat > /etc/logrotate.d/allvarlogs << EOF
442
+
443
+ if [[ " ${ENABLE_LOGROTATE_FILES:- false} " = " true" ]]; then
444
+ # Configure log rotation for all logs in /var/log, which is where k8s services
445
+ # are configured to write their log files. Whenever logrotate is ran, this
446
+ # config will:
447
+ # * rotate the log file if its size is > 100Mb OR if one day has elapsed
448
+ # * save rotated logs into a gzipped timestamped backup
449
+ # * log file timestamp (controlled by 'dateformat') includes seconds too. This
450
+ # ensures that logrotate can generate unique logfiles during each rotation
451
+ # (otherwise it skips rotation if 'maxsize' is reached multiple times in a
452
+ # day).
453
+ # * keep only 5 old (rotated) logs, and will discard older logs.
454
+ cat > /etc/logrotate.d/allvarlogs << EOF
453
455
/var/log/*.log {
454
456
rotate ${LOGROTATE_FILES_MAX_COUNT:- 5}
455
457
copytruncate
@@ -463,9 +465,11 @@ function setup-logrotate() {
463
465
create 0644 root root
464
466
}
465
467
EOF
468
+ fi
466
469
467
- # Configure log rotation for pod logs in /var/log/pods/NAMESPACE_NAME_UID.
468
- cat > /etc/logrotate.d/allpodlogs << EOF
470
+ if [[ " ${ENABLE_POD_LOG:- false} " = " true" ]]; then
471
+ # Configure log rotation for pod logs in /var/log/pods/NAMESPACE_NAME_UID.
472
+ cat > /etc/logrotate.d/allpodlogs << EOF
469
473
/var/log/pods/*/*.log {
470
474
rotate ${POD_LOG_MAX_FILE:- 5}
471
475
copytruncate
479
483
create 0644 root root
480
484
}
481
485
EOF
486
+ fi
482
487
}
483
488
484
489
# Finds the master PD device; returns it in MASTER_PD_DEVICE
0 commit comments