From 1b77d45b86202e3ccc58b1abf88426a144f4ffee Mon Sep 17 00:00:00 2001 From: Kenichi Omichi Date: Tue, 28 Sep 2021 11:15:16 -0700 Subject: [PATCH] Add metrics_server_resizer option (#8018) (#8031) The addon-resizer container can reduce resource limits of cpu and memory of metrics-server container in the pod, and that caused OOMKilled. In addition, the original metrics-server manifest doesn't contain the addon-resizer container as [1]. So this adds metrics_server_resizer option to control the addon-resizer container deployment and the default value is false to make it stable for most environments. This is a cherry-pick of 8d3961edbed4dc20c1629e846a197977d4d2dffe [1]: https://github.com/kubernetes-sigs/metrics-server/blob/527679e5e8a103919c935d0575c20741796bc25d/manifests/base/deployment.yaml --- inventory/sample/group_vars/k8s_cluster/addons.yml | 1 + roles/kubernetes-apps/metrics_server/defaults/main.yml | 1 + .../metrics_server/templates/metrics-server-deployment.yaml.j2 | 2 ++ 3 files changed, 4 insertions(+) diff --git a/inventory/sample/group_vars/k8s_cluster/addons.yml b/inventory/sample/group_vars/k8s_cluster/addons.yml index 6c5ed80cb83..d816bbe786b 100644 --- a/inventory/sample/group_vars/k8s_cluster/addons.yml +++ b/inventory/sample/group_vars/k8s_cluster/addons.yml @@ -14,6 +14,7 @@ registry_enabled: false # Metrics Server deployment metrics_server_enabled: false +# metrics_server_resizer: false # metrics_server_kubelet_insecure_tls: true # metrics_server_metric_resolution: 15s # metrics_server_kubelet_preferred_address_types: "InternalIP" diff --git a/roles/kubernetes-apps/metrics_server/defaults/main.yml b/roles/kubernetes-apps/metrics_server/defaults/main.yml index 812de3172b9..9206095ce2c 100644 --- a/roles/kubernetes-apps/metrics_server/defaults/main.yml +++ b/roles/kubernetes-apps/metrics_server/defaults/main.yml @@ -1,4 +1,5 @@ --- +metrics_server_resizer: false metrics_server_kubelet_insecure_tls: true metrics_server_kubelet_preferred_address_types: "InternalIP" metrics_server_metric_resolution: 15s 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 aa70c5caedc..68cf3f357ef 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 @@ -82,6 +82,7 @@ spec: requests: cpu: {{ metrics_server_requests_cpu }} memory: {{ metrics_server_requests_memory }} +{% if metrics_server_resizer %} - name: metrics-server-nanny image: {{ addon_resizer_image_repo }}:{{ addon_resizer_image_tag }} imagePullPolicy: {{ k8s_image_pull_policy }} @@ -119,6 +120,7 @@ spec: # Specifies the smallest cluster (defined in number of nodes) # resources will be scaled to. - --minClusterSize={{ metrics_server_min_cluster_size }} +{% endif %} volumes: - name: metrics-server-config-volume configMap: