Add injector.webhookAnnotations chart option (#584)

This commit is contained in:
Theron Voran 2021-08-16 13:49:26 -07:00 committed by GitHub
parent 277317524a
commit f7ab37fd50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 3 deletions

View file

@ -353,6 +353,21 @@ Sets extra injector service annotations
{{- end }} {{- end }}
{{- end -}} {{- end -}}
{{/*
Sets extra injector webhook annotations
*/}}
{{- define "injector.webhookAnnotations" -}}
{{- if .Values.injector.webhookAnnotations }}
annotations:
{{- $tp := typeOf .Values.injector.webhookAnnotations }}
{{- if eq $tp "string" }}
{{- tpl .Values.injector.webhookAnnotations . | nindent 4 }}
{{- else }}
{{- toYaml .Values.injector.webhookAnnotations | nindent 4 }}
{{- end }}
{{- end }}
{{- end -}}
{{/* {{/*
Sets extra ui service annotations Sets extra ui service annotations
*/}} */}}

View file

@ -11,6 +11,7 @@ metadata:
app.kubernetes.io/name: {{ include "vault.name" . }}-agent-injector app.kubernetes.io/name: {{ include "vault.name" . }}-agent-injector
app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- template "injector.webhookAnnotations" . }}
webhooks: webhooks:
- name: vault.hashicorp.com - name: vault.hashicorp.com
sideEffects: None sideEffects: None

View file

@ -121,3 +121,35 @@ load _helpers
[ "${actual}" = "\"Fail\"" ] [ "${actual}" = "\"Fail\"" ]
} }
#--------------------------------------------------------------------
# annotations
@test "injector/MutatingWebhookConfiguration: default annotations" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/injector-mutating-webhook.yaml \
. | tee /dev/stderr |
yq -r '.metadata.annotations' | tee /dev/stderr)
[ "${actual}" = "null" ]
}
@test "injector/MutatingWebhookConfiguration: specify annotations yaml" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/injector-mutating-webhook.yaml \
--set 'injector.webhookAnnotations.foo=bar' \
. | tee /dev/stderr |
yq -r '.metadata.annotations.foo' | tee /dev/stderr)
[ "${actual}" = "bar" ]
}
@test "injector/MutatingWebhookConfiguration: specify annotations yaml string" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/injector-mutating-webhook.yaml \
--set 'injector.webhookAnnotations=foo: bar' \
. | tee /dev/stderr |
yq -r '.metadata.annotations.foo' | tee /dev/stderr)
[ "${actual}" = "bar" ]
}

View file

@ -357,6 +357,12 @@
"array", "array",
"string" "string"
] ]
},
"webhookAnnotations": {
"type": [
"object",
"string"
]
} }
} }
}, },

View file

@ -119,6 +119,9 @@ injector:
# #
failurePolicy: Ignore failurePolicy: Ignore
# Extra annotations to attach to the webhook
webhookAnnotations: {}
certs: certs:
# secretName is the name of the secret that has the TLS certificate and # secretName is the name of the secret that has the TLS certificate and
# private key to serve the injector webhook. If this is null, then the # private key to serve the injector webhook. If this is null, then the
@ -126,9 +129,10 @@ injector:
# a service account to the injector to generate its own certificates. # a service account to the injector to generate its own certificates.
secretName: null secretName: null
# caBundle is a base64-encoded PEM-encoded certificate bundle for the # caBundle is a base64-encoded PEM-encoded certificate bundle for the CA
# CA that signed the TLS certificate that the webhook serves. This must # that signed the TLS certificate that the webhook serves. This must be set
# be set if secretName is non-null. # if secretName is non-null, unless an external service like cert-manager is
# keeping the caBundle updated.
caBundle: "" caBundle: ""
# certName and keyName are the names of the files within the secret for # certName and keyName are the names of the files within the secret for