From 0679d9c8e940885174db6cd9dcd8ccd9351d1505 Mon Sep 17 00:00:00 2001 From: Max Gautier Date: Mon, 23 Sep 2024 15:42:24 +0200 Subject: [PATCH] metrics-server: proper defaults, cleaner deploy template --- .../metrics_server/defaults/main.yml | 6 +++--- .../templates/metrics-server-deployment.yaml.j2 | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/roles/kubernetes-apps/metrics_server/defaults/main.yml b/roles/kubernetes-apps/metrics_server/defaults/main.yml index 934e67b75..ed43734bb 100644 --- a/roles/kubernetes-apps/metrics_server/defaults/main.yml +++ b/roles/kubernetes-apps/metrics_server/defaults/main.yml @@ -9,6 +9,6 @@ metrics_server_requests_cpu: 100m metrics_server_requests_memory: 200Mi metrics_server_host_network: false metrics_server_replicas: 1 -# metrics_server_extra_tolerations: [] -# metrics_server_extra_affinity: {} -# metrics_server_nodeselector: {} +metrics_server_extra_tolerations: [] +metrics_server_extra_affinity: {} +metrics_server_nodeselector: {} 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 a7052f9be..528e23a13 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 @@ -88,9 +88,9 @@ spec: tolerations: - key: node-role.kubernetes.io/control-plane effect: NoSchedule -{% if metrics_server_extra_tolerations is defined %} +{% if metrics_server_extra_tolerations %} {{ metrics_server_extra_tolerations | list | to_nice_yaml(indent=2) | indent(8) }} -{% endif %} +{%- endif %} affinity: podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: @@ -105,10 +105,10 @@ spec: topologyKey: kubernetes.io/hostname namespaces: - kube-system -{% if metrics_server_extra_affinity is defined %} - {{ metrics_server_extra_affinity | to_nice_yaml | indent(width=8) }} -{% endif %} -{% if metrics_server_nodeselector is defined %} +{% if metrics_server_extra_affinity %} + {{ metrics_server_extra_affinity | to_nice_yaml(indent=2) | indent(8) }} +{%- endif %} +{% if metrics_server_nodeselector %} nodeSelector: - {{ metrics_server_nodeselector | to_nice_yaml | indent(width=8) }} -{% endif %} + {{ metrics_server_nodeselector | to_nice_yaml(indent=2) | indent(8) }} +{%- endif %}