From bdfd58158eb2810e718aedc668248d30121fdc49 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Tue, 26 Sep 2023 12:36:10 +0200 Subject: [PATCH 1/2] feat(acp): adding affinity with unittest --- .../templates/statefulset.yaml | 4 +++ .../tests/affinity_test.yaml | 27 +++++++++++++++++++ .../tests/defaults_test.yaml | 15 +++++++++-- 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 charts/artifact-caching-proxy/tests/affinity_test.yaml diff --git a/charts/artifact-caching-proxy/templates/statefulset.yaml b/charts/artifact-caching-proxy/templates/statefulset.yaml index 73a08c7d8..2851ea471 100644 --- a/charts/artifact-caching-proxy/templates/statefulset.yaml +++ b/charts/artifact-caching-proxy/templates/statefulset.yaml @@ -7,6 +7,10 @@ metadata: spec: serviceName: {{ include "artifact-caching-proxy.fullname" . }} replicas: {{ .Values.replicaCount }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 4 }} + {{- end }} selector: matchLabels: {{- include "artifact-caching-proxy.selectorLabels" . | nindent 6 }} diff --git a/charts/artifact-caching-proxy/tests/affinity_test.yaml b/charts/artifact-caching-proxy/tests/affinity_test.yaml new file mode 100644 index 000000000..745129d2c --- /dev/null +++ b/charts/artifact-caching-proxy/tests/affinity_test.yaml @@ -0,0 +1,27 @@ +suite: Tests using Affinity +templates: + - statefulset.yaml + - nginx-default-configmap.yaml + - nginx-proxy-configmap.yaml +tests: + - it: Should include affinity + template: statefulset.yaml + set: + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: "app.kubernetes.io/name" + operator: In + values: + - artifact-caching-proxy + topologyKey: "kubernetes.io/hostname" + asserts: + - hasDocuments: + count: 1 + - isKind: + of: StatefulSet + - equal: + path: spec.affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution[0].topologyKey + value: "kubernetes.io/hostname" diff --git a/charts/artifact-caching-proxy/tests/defaults_test.yaml b/charts/artifact-caching-proxy/tests/defaults_test.yaml index e1c2820a4..a9cbdd25d 100644 --- a/charts/artifact-caching-proxy/tests/defaults_test.yaml +++ b/charts/artifact-caching-proxy/tests/defaults_test.yaml @@ -3,6 +3,8 @@ templates: - ingress.yaml - ingress-health.yaml - nginx-proxy-configmap.yaml + - nginx-default-configmap.yaml + - statefulset.yaml tests: - it: should not generate any ingress with default values template: ingress.yaml @@ -21,7 +23,16 @@ tests: count: 1 - isKind: of: ConfigMap - - isNotNull: + - isNotNullOrEmpty: path: data["vhost-proxy.conf"] - - isNotNull: + - isNotNullOrEmpty: path: data["vhost-status.conf"] + - it: Should generate a statefulset with the default values + template: statefulset.yaml + asserts: + - hasDocuments: + count: 1 + - isKind: + of: StatefulSet + - notExists: + path: spec.affinity From b9b9b60a59f90f5b4dd369919afd9b20acebbca8 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Tue, 26 Sep 2023 12:39:13 +0200 Subject: [PATCH 2/2] bump version --- charts/artifact-caching-proxy/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/artifact-caching-proxy/Chart.yaml b/charts/artifact-caching-proxy/Chart.yaml index 113aa850c..7450319dd 100644 --- a/charts/artifact-caching-proxy/Chart.yaml +++ b/charts/artifact-caching-proxy/Chart.yaml @@ -2,4 +2,4 @@ apiVersion: v2 description: artifact-caching-proxy is a Nginx caching proxy in front of repo.jenkins-ci.org name: artifact-caching-proxy type: application -version: 0.13.0 +version: 0.14.0