From a11a75d1b509f81886fc2ab10c9b299af468d4a3 Mon Sep 17 00:00:00 2001 From: Logi Date: Mon, 7 Dec 2020 16:28:06 +0000 Subject: [PATCH] support extraLabels for vault-agent-injector (#428) * support extraLabels for vault-agent-injector * added unit test for extraLabels * fix test * added injector.extraLabels as empty map to values file --- templates/injector-deployment.yaml | 3 +++ test/unit/injector-deployment.bats | 12 ++++++++++++ values.yaml | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/templates/injector-deployment.yaml b/templates/injector-deployment.yaml index 849418a..2f67dad 100644 --- a/templates/injector-deployment.yaml +++ b/templates/injector-deployment.yaml @@ -23,6 +23,9 @@ spec: app.kubernetes.io/name: {{ template "vault.name" . }}-agent-injector app.kubernetes.io/instance: {{ .Release.Name }} component: webhook + {{- if .Values.injector.extraLabels -}} + {{- toYaml .Values.injector.extraLabels | nindent 8 -}} + {{- end -}} {{ template "injector.annotations" . }} spec: {{ template "injector.affinity" . }} diff --git a/test/unit/injector-deployment.bats b/test/unit/injector-deployment.bats index 44af01c..4c25e6a 100755 --- a/test/unit/injector-deployment.bats +++ b/test/unit/injector-deployment.bats @@ -531,3 +531,15 @@ load _helpers yq '.spec.template.spec.securityContext.runAsGroup | length > 0' | tee /dev/stderr) [ "${actual}" = "false" ] } +#-------------------------------------------------------------------- +# extra labels + +@test "injector/deployment: specify extraLabels" { + cd `chart_dir` + local actual=$(helm template \ + --show-only templates/injector-deployment.yaml \ + --set 'injector.extraLabels.foo=bar' \ + . | tee /dev/stderr | + yq -r '.spec.template.metadata.labels.foo' | tee /dev/stderr) + [ "${actual}" = "bar" ] +} diff --git a/values.yaml b/values.yaml index a859f3b..f95b995 100644 --- a/values.yaml +++ b/values.yaml @@ -134,6 +134,10 @@ injector: # of the annotations to apply to the injector pods annotations: {} + # Extra labels to attach to the agent-injector + # This should be a YAML map of the labels to apply to the injector + extraLabels: {} + # Injector service specific config service: # Extra annotations to attach to the injector service