diff --git a/cluster/gce/config-default.sh b/cluster/gce/config-default.sh index 5cae332cf9e..1147ad6b076 100755 --- a/cluster/gce/config-default.sh +++ b/cluster/gce/config-default.sh @@ -425,6 +425,9 @@ METADATA_CLOBBERS_CONFIG="${METADATA_CLOBBERS_CONFIG:-false}" ENABLE_BIG_CLUSTER_SUBNETS="${ENABLE_BIG_CLUSTER_SUBNETS:-false}" +# Optional: Enable log rotation for k8s services +ENABLE_LOGROTATE_FILES="${ENABLE_LOGROTATE_FILES:-false}" +PROVIDER_VARS="${PROVIDER_VARS:-} ENABLE_LOGROTATE_FILES" if [[ -n "${LOGROTATE_FILES_MAX_COUNT:-}" ]]; then PROVIDER_VARS="${PROVIDER_VARS:-} LOGROTATE_FILES_MAX_COUNT" fi @@ -432,6 +435,10 @@ if [[ -n "${LOGROTATE_MAX_SIZE:-}" ]]; then PROVIDER_VARS="${PROVIDER_VARS:-} LOGROTATE_MAX_SIZE" fi +# Optional: Enable log rotation for pod logs +ENABLE_POD_LOG="${ENABLE_POD_LOG:-false}" +PROVIDER_VARS="${PROVIDER_VARS:-} ENABLE_POD_LOG" + if [[ -n "${POD_LOG_MAX_FILE:-}" ]]; then PROVIDER_VARS="${PROVIDER_VARS:-} POD_LOG_MAX_FILE" fi diff --git a/cluster/gce/config-test.sh b/cluster/gce/config-test.sh index f44e810d605..57bf9c4050d 100755 --- a/cluster/gce/config-test.sh +++ b/cluster/gce/config-test.sh @@ -467,6 +467,9 @@ ADVANCED_AUDIT_LOG_MODE=${ADVANCED_AUDIT_LOG_MODE:-batch} # batch, blocking ENABLE_BIG_CLUSTER_SUBNETS=${ENABLE_BIG_CLUSTER_SUBNETS:-false} +# Optional: Enable log rotation for k8s services +ENABLE_LOGROTATE_FILES="${ENABLE_LOGROTATE_FILES:-false}" +PROVIDER_VARS="${PROVIDER_VARS:-} ENABLE_LOGROTATE_FILES" if [[ -n "${LOGROTATE_FILES_MAX_COUNT:-}" ]]; then PROVIDER_VARS="${PROVIDER_VARS:-} LOGROTATE_FILES_MAX_COUNT" fi @@ -474,6 +477,10 @@ if [[ -n "${LOGROTATE_MAX_SIZE:-}" ]]; then PROVIDER_VARS="${PROVIDER_VARS:-} LOGROTATE_MAX_SIZE" fi +# Optional: Enable log rotation for pod logs +ENABLE_POD_LOG="${ENABLE_POD_LOG:-false}" +PROVIDER_VARS="${PROVIDER_VARS:-} ENABLE_POD_LOG" + if [[ -n "${POD_LOG_MAX_FILE:-}" ]]; then PROVIDER_VARS="${PROVIDER_VARS:-} POD_LOG_MAX_FILE" fi diff --git a/cluster/gce/gci/configure-helper.sh b/cluster/gce/gci/configure-helper.sh index 6213d498986..407ef698e19 100644 --- a/cluster/gce/gci/configure-helper.sh +++ b/cluster/gce/gci/configure-helper.sh @@ -428,17 +428,19 @@ function ensure-local-ssds() { # Installs logrotate configuration files function setup-logrotate() { mkdir -p /etc/logrotate.d/ - # 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 - # ensures that logrotate can generate unique logfiles during each rotation - # (otherwise it skips rotation if 'maxsize' is reached multiple times in a - # day). - # * keep only 5 old (rotated) logs, and will discard older logs. - cat > /etc/logrotate.d/allvarlogs < 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 + # ensures that logrotate can generate unique logfiles during each rotation + # (otherwise it skips rotation if 'maxsize' is reached multiple times in a + # day). + # * keep only 5 old (rotated) logs, and will discard older logs. + cat > /etc/logrotate.d/allvarlogs < /etc/logrotate.d/allpodlogs < /etc/logrotate.d/allpodlogs <