From a99ba3bb16fc8afbf322a26fce7e187de52c76e2 Mon Sep 17 00:00:00 2001
From: holmesb <5072156+holmesb@users.noreply.github.com>
Date: Thu, 10 Sep 2020 11:46:02 +0100
Subject: [PATCH] Allowing resource management of metrics-server container. 
 Will allow fine-tuning of resource allocation and solving throttling issues.
 Setting defaults as per the current request & limit allocation: cpu: 43m,
 memory 55Mi for both limits & requests. (#6652)

Signed-off-by: Brendan Holmes <holmesb@users.noreply.github.com>

Co-authored-by: Brendan Holmes <holmesb@users.noreply.github.com>
---
 roles/kubernetes-apps/metrics_server/defaults/main.yml     | 4 ++++
 .../templates/metrics-server-deployment.yaml.j2            | 7 +++++++
 2 files changed, 11 insertions(+)

diff --git a/roles/kubernetes-apps/metrics_server/defaults/main.yml b/roles/kubernetes-apps/metrics_server/defaults/main.yml
index 94dcfc0d9..a7f2360d2 100644
--- a/roles/kubernetes-apps/metrics_server/defaults/main.yml
+++ b/roles/kubernetes-apps/metrics_server/defaults/main.yml
@@ -6,6 +6,10 @@ metrics_server_cpu: 40m
 metrics_server_memory: 35Mi
 metrics_server_memory_per_node: 4Mi
 metrics_server_min_cluster_size: 5
+metrics_server_limits_cpu: 43m
+metrics_server_limits_memory: 55Mi
+metrics_server_requests_cpu: 43m
+metrics_server_requests_memory: 55Mi
 addon_resizer_limits_cpu: 100m
 addon_resizer_limits_memory: 300Mi
 addon_resizer_requests_cpu: 5m
diff --git a/roles/kubernetes-apps/metrics_server/templates/metrics-server-deployment.yaml.j2 b/roles/kubernetes-apps/metrics_server/templates/metrics-server-deployment.yaml.j2
index deaa3554a..c4b698d6c 100644
--- a/roles/kubernetes-apps/metrics_server/templates/metrics-server-deployment.yaml.j2
+++ b/roles/kubernetes-apps/metrics_server/templates/metrics-server-deployment.yaml.j2
@@ -73,6 +73,13 @@ spec:
           runAsGroup: 10001
           runAsNonRoot: true
           runAsUser: 10001
+        resources:
+          limits:
+            cpu: {{ metrics_server_limits_cpu }}
+            memory: {{ metrics_server_limits_memory }}
+          requests:
+            cpu: {{ metrics_server_requests_cpu }}
+            memory: {{ metrics_server_requests_memory }}
       - name: metrics-server-nanny
         image: {{ addon_resizer_image_repo }}:{{ addon_resizer_image_tag }}
         imagePullPolicy: {{ k8s_image_pull_policy }}
-- 
GitLab