diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index c3373b801..4123e3676 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -369,6 +369,21 @@ Sets PodSecurityPolicy annotations {{- end }} {{- end -}} +{{/* +Sets extra statefulset annotations +*/}} +{{- define "vault.statefulSet.annotations" -}} + {{- if .Values.server.statefulSet.annotations }} + annotations: + {{- $tp := typeOf .Values.server.statefulSet.annotations }} + {{- if eq $tp "string" }} + {{- tpl .Values.server.statefulSet.annotations . | nindent 4 }} + {{- else }} + {{- toYaml .Values.server.statefulSet.annotations | nindent 4 }} + {{- end }} + {{- end }} +{{- end -}} + {{/* Set's the container resources if the user has set any. */}} diff --git a/templates/server-statefulset.yaml b/templates/server-statefulset.yaml index 7db704cc3..aeb1667fa 100644 --- a/templates/server-statefulset.yaml +++ b/templates/server-statefulset.yaml @@ -11,6 +11,7 @@ metadata: app.kubernetes.io/name: {{ include "vault.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- template "vault.statefulSet.annotations" . }} spec: serviceName: {{ template "vault.fullname" . }}-internal podManagementPolicy: Parallel diff --git a/test/unit/server-statefulset.bats b/test/unit/server-statefulset.bats index d67722afb..2b3a2dab0 100755 --- a/test/unit/server-statefulset.bats +++ b/test/unit/server-statefulset.bats @@ -850,6 +850,36 @@ load _helpers [ "${actual}" = "bar" ] } +# extra annotations + +@test "server/standalone-StatefulSet: default statefulSet.annotations" { + cd `chart_dir` + local actual=$(helm template \ + --show-only templates/server-statefulset.yaml \ + . | tee /dev/stderr | + yq -r '.metadata.annotations' | tee /dev/stderr) + [ "${actual}" = "null" ] +} + +@test "server/standalone-StatefulSet: specify statefulSet.annotations yaml" { + cd `chart_dir` + local actual=$(helm template \ + --show-only templates/server-statefulset.yaml \ + --set 'server.statefulSet.annotations.foo=bar' \ + . | tee /dev/stderr | + yq -r '.metadata.annotations.foo' | tee /dev/stderr) + [ "${actual}" = "bar" ] +} + +@test "server/standalone-StatefulSet: specify statefulSet.annotations yaml string" { + cd `chart_dir` + local actual=$(helm template \ + --show-only templates/server-statefulset.yaml \ + --set 'server.statefulSet.annotations=foo: bar' \ + . | tee /dev/stderr | + yq -r '.metadata.annotations.foo' | tee /dev/stderr) + [ "${actual}" = "bar" ] +} #-------------------------------------------------------------------- # Security Contexts diff --git a/values.yaml b/values.yaml index 23f12801e..ef76997bd 100644 --- a/values.yaml +++ b/values.yaml @@ -501,6 +501,13 @@ server: # annotations to apply to the serviceAccount. annotations: {} + # Settings for the statefulSet used to run Vault. + statefulSet: + # Extra annotations for the statefulSet. This can either be YAML or a + # YAML-formatted multi-line templated string map of the annotations to apply + # to the statefulSet. + annotations: {} + # Vault UI ui: # True if you want to create a Service entry for the Vault UI.