mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Use docker log rotation mechanism instead of logrotate
This commit is contained in:
parent
66529d51ba
commit
cabb9890ac
@ -705,6 +705,21 @@ EOF
|
|||||||
if [ -n "${DOCKER_TEST_LOG_LEVEL:-}" ]; then
|
if [ -n "${DOCKER_TEST_LOG_LEVEL:-}" ]; then
|
||||||
cat >>$file <<EOF
|
cat >>$file <<EOF
|
||||||
DOCKER_TEST_LOG_LEVEL: $(yaml-quote ${DOCKER_TEST_LOG_LEVEL})
|
DOCKER_TEST_LOG_LEVEL: $(yaml-quote ${DOCKER_TEST_LOG_LEVEL})
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
if [ -n "${DOCKER_LOG_DRIVER:-}" ]; then
|
||||||
|
cat >>$file <<EOF
|
||||||
|
DOCKER_LOG_DRIVER: $(yaml-quote ${DOCKER_LOG_DRIVER})
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
if [ -n "${DOCKER_LOG_MAX_SIZE:-}" ]; then
|
||||||
|
cat >>$file <<EOF
|
||||||
|
DOCKER_LOG_MAX_SIZE: $(yaml-quote ${DOCKER_LOG_MAX_SIZE})
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
if [ -n "${DOCKER_LOG_MAX_FILE:-}" ]; then
|
||||||
|
cat >>$file <<EOF
|
||||||
|
DOCKER_LOG_MAX_FILE: $(yaml-quote ${DOCKER_LOG_MAX_FILE})
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
if [ -n "${ENABLE_CUSTOM_METRICS:-}" ]; then
|
if [ -n "${ENABLE_CUSTOM_METRICS:-}" ]; then
|
||||||
|
@ -95,21 +95,6 @@ function ensure-local-ssds() {
|
|||||||
# Installs logrotate configuration files
|
# Installs logrotate configuration files
|
||||||
function setup-logrotate() {
|
function setup-logrotate() {
|
||||||
mkdir -p /etc/logrotate.d/
|
mkdir -p /etc/logrotate.d/
|
||||||
cat >/etc/logrotate.d/docker-containers <<EOF
|
|
||||||
/var/lib/docker/containers/*/*-json.log {
|
|
||||||
rotate 5
|
|
||||||
copytruncate
|
|
||||||
missingok
|
|
||||||
notifempty
|
|
||||||
compress
|
|
||||||
maxsize 10M
|
|
||||||
daily
|
|
||||||
dateext
|
|
||||||
dateformat -%Y%m%d-%s
|
|
||||||
create 0644 root root
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Configure log rotation for all logs in /var/log, which is where k8s services
|
# 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
|
# are configured to write their log files. Whenever logrotate is ran, this
|
||||||
# config will:
|
# config will:
|
||||||
@ -491,6 +476,11 @@ function assemble-docker-flags {
|
|||||||
docker_opts+=" --registry-mirror=${DOCKER_REGISTRY_MIRROR_URL}"
|
docker_opts+=" --registry-mirror=${DOCKER_REGISTRY_MIRROR_URL}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Configure docker logging
|
||||||
|
docker_opts+=" --log-driver=${DOCKER_LOG_DRIVER:-json-file}"
|
||||||
|
docker_opts+=" --log-opt=max-size=${DOCKER_LOG_MAX_SIZE:-10m}"
|
||||||
|
docker_opts+=" --log-opt=max-file=${DOCKER_LOG_MAX_FILE:-5}"
|
||||||
|
|
||||||
echo "DOCKER_OPTS=\"${docker_opts} ${EXTRA_DOCKER_OPTS:-}\"" > /etc/default/docker
|
echo "DOCKER_OPTS=\"${docker_opts} ${EXTRA_DOCKER_OPTS:-}\"" > /etc/default/docker
|
||||||
|
|
||||||
if [[ "${use_net_plugin}" == "true" ]]; then
|
if [[ "${use_net_plugin}" == "true" ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user