From 0ab15dfb844b1b88377ef1167acc3d45fee1baa4 Mon Sep 17 00:00:00 2001 From: mehmetsalgar Date: Tue, 18 May 2021 02:14:19 +0200 Subject: [PATCH] [Issue-520] tolerations for csi-daemonset (#521) Co-authored-by: Theron Voran --- templates/_helpers.tpl | 10 ++++++++++ templates/csi-daemonset.yaml | 1 + test/unit/csi-daemonset.bats | 21 +++++++++++++++++++++ values.yaml | 6 ++++++ 4 files changed, 38 insertions(+) diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index ca57fa1..505275b 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -502,6 +502,16 @@ Sets extra CSI daemonset annotations {{- end }} {{- end -}} +{{/* +Sets the injector toleration for pod placement +*/}} +{{- define "csi.pod.tolerations" -}} + {{- if .Values.csi.pod.tolerations }} + tolerations: + {{ tpl .Values.csi.pod.tolerations . | nindent 8 | trim }} + {{- end }} +{{- end -}} + {{/* Sets extra CSI provider pod annotations */}} diff --git a/templates/csi-daemonset.yaml b/templates/csi-daemonset.yaml index 94b765d..b505d14 100644 --- a/templates/csi-daemonset.yaml +++ b/templates/csi-daemonset.yaml @@ -28,6 +28,7 @@ spec: {{ template "csi.pod.annotations" . }} spec: serviceAccountName: {{ template "vault.fullname" . }}-csi-provider + {{- template "csi.pod.tolerations" . }} containers: - name: {{ include "vault.name" . }}-csi-provider {{ template "csi.resources" . }} diff --git a/test/unit/csi-daemonset.bats b/test/unit/csi-daemonset.bats index 992d1cf..d2156ee 100644 --- a/test/unit/csi-daemonset.bats +++ b/test/unit/csi-daemonset.bats @@ -206,6 +206,27 @@ load _helpers [ "${actual}" = "bar" ] } +@test "csi/daemonset: tolerations not set by default" { + cd `chart_dir` + local actual=$(helm template \ + --show-only templates/csi-daemonset.yaml \ + --set 'csi.enabled=true' \ + . | tee /dev/stderr | + yq '.spec.template.spec | .tolerations? == null' | tee /dev/stderr) + [ "${actual}" = "true" ] +} + +@test "csi/daemonset: tolerations can be set" { + cd `chart_dir` + local actual=$(helm template \ + --show-only templates/csi-daemonset.yaml \ + --set 'csi.enabled=true' \ + --set 'csi.pod.tolerations=foobar' \ + . | tee /dev/stderr | + yq '.spec.template.spec.tolerations == "foobar"' | tee /dev/stderr) + [ "${actual}" = "true" ] +} + #-------------------------------------------------------------------- # volumes diff --git a/values.yaml b/values.yaml index f31d132..32975bc 100644 --- a/values.yaml +++ b/values.yaml @@ -728,12 +728,18 @@ csi: # YAML-formatted multi-line templated string map of the annotations to apply # to the daemonSet. annotations: {} + pod: # Extra annotations for the provider pods. This can either be YAML or a # YAML-formatted multi-line templated string map of the annotations to apply # to the pod. annotations: {} + # Toleration Settings for provider pods + # This should be a multi-line string matching the Toleration array + # in a PodSpec. + tolerations: null + serviceAccount: # Extra annotations for the serviceAccount definition. This can either be # YAML or a YAML-formatted multi-line templated string map of the