Skip to content

Commit

Permalink
Support to add annotations in injector serviceaccount (hashicorp#753)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunopadz authored Jul 11, 2022
1 parent 44a07b8 commit 6c14d9d
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
15 changes: 15 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,21 @@ Sets extra injector service annotations
{{- end }}
{{- end -}}

{{/*
Sets extra injector service account annotations
*/}}
{{- define "injector.serviceAccount.annotations" -}}
{{- if and (ne .mode "dev") .Values.injector.serviceAccount.annotations }}
annotations:
{{- $tp := typeOf .Values.injector.serviceAccount.annotations }}
{{- if eq $tp "string" }}
{{- tpl .Values.injector.serviceAccount.annotations . | nindent 4 }}
{{- else }}
{{- toYaml .Values.injector.serviceAccount.annotations | nindent 4 }}
{{- end }}
{{- end }}
{{- end -}}

{{/*
Sets extra injector webhook annotations
*/}}
Expand Down
1 change: 1 addition & 0 deletions templates/injector-serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ 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.serviceAccount.annotations" . }}
{{ end }}
10 changes: 10 additions & 0 deletions test/unit/injector-serviceaccount.bats
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ load _helpers
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "false" ]
}

@test "injector/ServiceAccount: generic annotations" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/injector-serviceaccount.yaml \
--set 'injector.serviceAccount.annotations=vaultIsAwesome: true' \
. | tee /dev/stderr |
yq -r '.metadata.annotations["vaultIsAwesome"]' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
11 changes: 11 additions & 0 deletions values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,17 @@
}
}
},
"serviceAccount": {
"type": "object",
"properties": {
"annotations": {
"type": [
"object",
"string"
]
}
}
},
"strategy": {
"type": [
"object",
Expand Down
5 changes: 5 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ injector:
# Extra annotations to attach to the injector service
annotations: {}

# Injector serviceAccount specific config
serviceAccount:
# Extra annotations to attach to the injector serviceAccount
annotations: {}

# A disruption budget limits the number of pods of a replicated application
# that are down simultaneously from voluntary disruptions
podDisruptionBudget: {}
Expand Down

0 comments on commit 6c14d9d

Please sign in to comment.