Skip to content

Commit 7ffa7da

Browse files
committed
Configure logrotate for pod logs.
1 parent 9e4f8d6 commit 7ffa7da

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

cluster/gce/config-default.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,14 @@ if [[ -n "${LOGROTATE_MAX_SIZE:-}" ]]; then
415415
PROVIDER_VARS="${PROVIDER_VARS:-} LOGROTATE_MAX_SIZE"
416416
fi
417417

418+
if [[ -n "${POD_LOG_MAX_FILE:-}" ]]; then
419+
PROVIDER_VARS="${PROVIDER_VARS:-} POD_LOG_MAX_FILE"
420+
fi
421+
422+
if [[ -n "${POD_LOG_MAX_SIZE:-}" ]]; then
423+
PROVIDER_VARS="${PROVIDER_VARS:-} POD_LOG_MAX_SIZE"
424+
fi
425+
418426
# Fluentd requirements
419427
# YAML exists to trigger a configuration refresh when changes are made.
420428
FLUENTD_GCP_YAML_VERSION="v3.2.0"

cluster/gce/config-test.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,14 @@ if [[ -n "${LOGROTATE_MAX_SIZE:-}" ]]; then
432432
PROVIDER_VARS="${PROVIDER_VARS:-} LOGROTATE_MAX_SIZE"
433433
fi
434434

435+
if [[ -n "${POD_LOG_MAX_FILE:-}" ]]; then
436+
PROVIDER_VARS="${PROVIDER_VARS:-} POD_LOG_MAX_FILE"
437+
fi
438+
439+
if [[ -n "${POD_LOG_MAX_SIZE:-}" ]]; then
440+
PROVIDER_VARS="${PROVIDER_VARS:-} POD_LOG_MAX_SIZE"
441+
fi
442+
435443
# Fluentd requirements
436444
# YAML exists to trigger a configuration refresh when changes are made.
437445
FLUENTD_GCP_YAML_VERSION="v3.2.0"

cluster/gce/gci/configure-helper.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,21 @@ function setup-logrotate() {
374374
}
375375
EOF
376376

377+
# Configure log rotation for pod logs in /var/log/pods/NAMESPACE_NAME_UID.
378+
cat > /etc/logrotate.d/allpodlogs <<EOF
379+
/var/log/pods/*/*.log {
380+
rotate ${POD_LOG_MAX_FILE:-5}
381+
copytruncate
382+
missingok
383+
notifempty
384+
compress
385+
maxsize ${POD_LOG_MAX_SIZE:-5M}
386+
daily
387+
dateext
388+
dateformat -%Y%m%d-%s
389+
create 0644 root root
390+
}
391+
EOF
377392
}
378393

379394
# Finds the master PD device; returns it in MASTER_PD_DEVICE

0 commit comments

Comments
 (0)