Skip to content

Commit a213886

Browse files
authored
Merge pull request kubernetes#74502 from Random-Liu/collect-pod-log
Collect pod log in fluentd-gcp
2 parents eb6a1b6 + 7ffa7da commit a213886

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
@@ -413,6 +413,14 @@ if [[ -n "${LOGROTATE_MAX_SIZE:-}" ]]; then
413413
PROVIDER_VARS="${PROVIDER_VARS:-} LOGROTATE_MAX_SIZE"
414414
fi
415415

416+
if [[ -n "${POD_LOG_MAX_FILE:-}" ]]; then
417+
PROVIDER_VARS="${PROVIDER_VARS:-} POD_LOG_MAX_FILE"
418+
fi
419+
420+
if [[ -n "${POD_LOG_MAX_SIZE:-}" ]]; then
421+
PROVIDER_VARS="${PROVIDER_VARS:-} POD_LOG_MAX_SIZE"
422+
fi
423+
416424
# Fluentd requirements
417425
# YAML exists to trigger a configuration refresh when changes are made.
418426
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)