diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 16f2aba..9789324 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -293,6 +293,21 @@ Sets extra injector pod annotations {{- end }} {{- end -}} +{{/* +Sets extra injector service annotations +*/}} +{{- define "injector.service.annotations" -}} + {{- if .Values.injector.service.annotations }} + annotations: + {{- $tp := typeOf .Values.injector.service.annotations }} + {{- if eq $tp "string" }} + {{- tpl .Values.injector.service.annotations . | nindent 4 }} + {{- else }} + {{- toYaml .Values.injector.service.annotations | nindent 4 }} + {{- end }} + {{- end }} +{{- end -}} + {{/* Sets extra ui service annotations */}} diff --git a/templates/injector-service.yaml b/templates/injector-service.yaml index 79d818f..0e51727 100644 --- a/templates/injector-service.yaml +++ b/templates/injector-service.yaml @@ -8,6 +8,7 @@ metadata: app.kubernetes.io/name: {{ include "vault.name" . }}-agent-injector app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} + {{ template "injector.service.annotations" . }} spec: ports: - port: 443 diff --git a/test/unit/injector-service.bats b/test/unit/injector-service.bats index af8787d..f9d8722 100755 --- a/test/unit/injector-service.bats +++ b/test/unit/injector-service.bats @@ -35,3 +35,13 @@ load _helpers yq 'length > 0' | tee /dev/stderr) [ "${actual}" = "false" ] } + +@test "injector/Service: generic annotations" { + cd `chart_dir` + local actual=$(helm template \ + --show-only templates/injector-service.yaml \ + --set 'injector.service.annotations=vaultIsAwesome: true' \ + . | tee /dev/stderr | + yq -r '.metadata.annotations["vaultIsAwesome"]' | tee /dev/stderr) + [ "${actual}" = "true" ] +} diff --git a/values.yaml b/values.yaml index 4293cf4..a859f3b 100644 --- a/values.yaml +++ b/values.yaml @@ -134,6 +134,11 @@ injector: # of the annotations to apply to the injector pods annotations: {} + # Injector service specific config + service: + # Extra annotations to attach to the injector service + annotations: {} + server: # Resource requests, limits, etc. for the server cluster placement. This # should map directly to the value of the resources field for a PodSpec.