From d0d0b28c9acb76d304206daa83fba2ffcd489e24 Mon Sep 17 00:00:00 2001 From: Laszlo Fogas Date: Tue, 27 Jul 2021 10:02:46 +0200 Subject: [PATCH] Deployment strategy is configurable; still having the single replica volume rule --- charts/onechart/templates/deployment.yaml | 7 ++++++- .../tests/deployment_volumes_test.yaml | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/charts/onechart/templates/deployment.yaml b/charts/onechart/templates/deployment.yaml index 776fa78..5255f37 100644 --- a/charts/onechart/templates/deployment.yaml +++ b/charts/onechart/templates/deployment.yaml @@ -15,10 +15,15 @@ spec: matchLabels: {{- include "helm-chart.selectorLabels" . | nindent 6 }} {{- $singleReplica := eq (.Values.replicas | int64) 1 }} - {{- if and .Values.volumes $singleReplica }} + {{- $strategyNotDefined := not .Values.strategy }} + {{- if and (and .Values.volumes $singleReplica) $strategyNotDefined}} strategy: type: Recreate {{- end }} + {{- if .Values.strategy }} + strategy: + type: {{ .Values.strategy }} + {{- end }} template: metadata: annotations: diff --git a/charts/onechart/tests/deployment_volumes_test.yaml b/charts/onechart/tests/deployment_volumes_test.yaml index 13238d9..766499f 100644 --- a/charts/onechart/tests/deployment_volumes_test.yaml +++ b/charts/onechart/tests/deployment_volumes_test.yaml @@ -42,3 +42,22 @@ tests: - equal: path: spec.strategy.type value: Recreate + - it: Should strategy take precedence + set: + volumes: + - name: data + path: /var/lib/1clickinfra/data + size: 10Gi + storageClass: default + strategy: RollingUpdate + asserts: + - equal: + path: spec.strategy.type + value: RollingUpdate + - it: Should strategy be set + set: + strategy: Dummy + asserts: + - equal: + path: spec.strategy.type + value: Dummy \ No newline at end of file