diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 593c10ed7..b6dc5c554 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -282,6 +282,21 @@ Sets extra pod annotations {{- end }} {{- end -}} +{{/* +Sets extra injector pod annotations +*/}} +{{- define "injector.annotations" -}} + {{- if .Values.injector.annotations }} + annotations: + {{- $tp := typeOf .Values.injector.annotations }} + {{- if eq $tp "string" }} + {{- tpl .Values.injector.annotations . | nindent 8 }} + {{- else }} + {{- toYaml .Values.injector.annotations | nindent 8 }} + {{- end }} + {{- end }} +{{- end -}} + {{/* Sets extra ui service annotations */}} diff --git a/templates/injector-deployment.yaml b/templates/injector-deployment.yaml index 17f28b571..849418ab3 100644 --- a/templates/injector-deployment.yaml +++ b/templates/injector-deployment.yaml @@ -23,6 +23,7 @@ spec: app.kubernetes.io/name: {{ template "vault.name" . }}-agent-injector app.kubernetes.io/instance: {{ .Release.Name }} component: webhook + {{ template "injector.annotations" . }} spec: {{ template "injector.affinity" . }} {{ template "injector.tolerations" . }} diff --git a/test/unit/injector-deployment.bats b/test/unit/injector-deployment.bats index 30cd2dfaf..44af01c71 100755 --- a/test/unit/injector-deployment.bats +++ b/test/unit/injector-deployment.bats @@ -390,6 +390,38 @@ load _helpers [ "${actual}" = "sanitized" ] } +#-------------------------------------------------------------------- +# extra annotations + +@test "injector/deployment: default annotations" { + cd `chart_dir` + local actual=$(helm template \ + --show-only templates/injector-deployment.yaml \ + . | tee /dev/stderr | + yq -r '.spec.template.metadata.annotations' | tee /dev/stderr) + [ "${actual}" = "null" ] +} + +@test "injector/deployment: specify annotations yaml" { + cd `chart_dir` + local actual=$(helm template \ + --show-only templates/injector-deployment.yaml \ + --set 'injector.annotations.foo=bar' \ + . | tee /dev/stderr | + yq -r '.spec.template.metadata.annotations.foo' | tee /dev/stderr) + [ "${actual}" = "bar" ] +} + +@test "injector/deployment: specify annotations yaml string" { + cd `chart_dir` + local actual=$(helm template \ + --show-only templates/injector-deployment.yaml \ + --set 'injector.annotations=foo: bar' \ + . | tee /dev/stderr | + yq -r '.spec.template.metadata.annotations.foo' | tee /dev/stderr) + [ "${actual}" = "bar" ] +} + #-------------------------------------------------------------------- # affinity diff --git a/values.yaml b/values.yaml index ebee71a65..538cb3a4f 100644 --- a/values.yaml +++ b/values.yaml @@ -122,6 +122,11 @@ injector: # Priority class for injector pods priorityClassName: "" + # Extra annotations to attach to the injector pods + # This can either be YAML or a YAML-formatted multi-line templated string map + # of the annotations to apply to the injector pods + 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.