From fac4a495bbee232fc788ad3d4694ef6b8d0a0cf9 Mon Sep 17 00:00:00 2001 From: Olaf Klischat Date: Tue, 20 Apr 2021 11:29:23 +0200 Subject: [PATCH] restart kubelets if they consume too much memory Signed-off-by: Olaf Klischat --- pkg/userdata/scripts/health-monitor.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/userdata/scripts/health-monitor.sh b/pkg/userdata/scripts/health-monitor.sh index f0f3f1a19..eef3c56c9 100644 --- a/pkg/userdata/scripts/health-monitor.sh +++ b/pkg/userdata/scripts/health-monitor.sh @@ -82,6 +82,9 @@ function kubelet_monitoring { if journalctl -u kubelet -n 10 | grep -q "use of closed network connection"; then failed=true echo "Kubelet stopped posting node status. Restarting" + elif [ "$(systemctl show kubelet.service -p MemoryCurrent | cut -d= -f2)" -gt 2000000000 ]; then + failed=true + echo "Kubelet consuming too much memory. Restarting" elif ! output=$(curl -m "${max_seconds}" -f -s -S http://127.0.0.1:10248/healthz 2>&1); then failed=true # Print the response and/or errors.