From ce4065bda8ad6a084a6cf4b8fd7a0260f0d80966 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Fri, 6 Dec 2024 23:57:09 +0100 Subject: [PATCH] fix(deployment): template affinity --- .../deployment.yaml | 4 +++ unittests/deployment/deployment.yaml | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/templates/prometheus-postgres-exporter/deployment.yaml b/templates/prometheus-postgres-exporter/deployment.yaml index db16687..6effd80 100644 --- a/templates/prometheus-postgres-exporter/deployment.yaml +++ b/templates/prometheus-postgres-exporter/deployment.yaml @@ -21,6 +21,10 @@ spec: labels: {{- include "prometheus-postgres-exporter.pod.labels" . | nindent 8 }} spec: + {{- with .Values.deployment.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} containers: - name: postgres-exporter args: diff --git a/unittests/deployment/deployment.yaml b/unittests/deployment/deployment.yaml index ab7c582..dc06335 100644 --- a/unittests/deployment/deployment.yaml +++ b/unittests/deployment/deployment.yaml @@ -30,6 +30,8 @@ tests: - equal: path: spec.replicas value: 1 + - notExists: + path: spec.template.spec.affinity - contains: path: spec.template.spec.containers[0].envFrom content: @@ -102,6 +104,32 @@ tests: path: spec.replicas value: 3 +- it: Test custom affinity + set: + deployment.affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: topology.kubernetes.io/zone + operator: In + values: + - antarctica-east1 + - antarctica-west1 + asserts: + - equal: + path: spec.template.spec.affinity + value: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: topology.kubernetes.io/zone + operator: In + values: + - antarctica-east1 + - antarctica-west1 + - it: Test additional arguments set: deployment.postgresExporter.args: