From 7938748d77af8cb8ab345fce64a86a88dbea8fe6 Mon Sep 17 00:00:00 2001
From: Bas van den Brink <basvandenbrink@users.noreply.github.com>
Date: Thu, 26 Nov 2020 09:32:19 +0100
Subject: [PATCH] Allow configuring container log limits for Kubelet (#6933)

---
 roles/kubernetes/node/defaults/main.yml                     | 6 ++++++
 .../node/templates/kubelet-config.v1beta1.yaml.j2           | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/roles/kubernetes/node/defaults/main.yml b/roles/kubernetes/node/defaults/main.yml
index b1fb2a26e..686e2e609 100644
--- a/roles/kubernetes/node/defaults/main.yml
+++ b/roles/kubernetes/node/defaults/main.yml
@@ -69,6 +69,12 @@ kubelet_config_extra_args: {}
 ## Support parameters to be passed to kubelet via kubelet-config.yaml only on nodes, not masters
 kubelet_node_config_extra_args: {}
 
+# Maximum number of container log files that can be present for a container.
+kubelet_logfiles_max_nr: 5
+
+# Maximum size of the container log file before it is rotated
+kubelet_logfiles_max_size: 10Mi
+
 ## Support custom flags to be passed to kubelet
 kubelet_custom_flags: []
 
diff --git a/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2 b/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2
index 826234fbd..868d1bc93 100644
--- a/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2
+++ b/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2
@@ -24,6 +24,8 @@ enforceNodeAllocatable:
 {% endif %}
 staticPodPath: {{ kube_manifest_dir }}
 cgroupDriver: {{ kubelet_cgroup_driver|default(kubelet_cgroup_driver_detected) }}
+containerLogMaxFiles: {{ kubelet_logfiles_max_nr }}
+containerLogMaxSize: {{ kubelet_logfiles_max_size }}
 maxPods: {{ kubelet_max_pods }}
 address: {{ kubelet_bind_address }}
 readOnlyPort: {{ kube_read_only_port }}
-- 
GitLab