Allow additional annotations for standby and active services via config (#896)
* Allow additional annotations for standby and active services via config Co-authored-by: Kyle Schochenmaier <kschoche@gmail.com>
This commit is contained in:
parent
0f47d83f36
commit
7728f8c650
7 changed files with 114 additions and 4 deletions
|
@ -710,6 +710,33 @@ Sets extra vault server Service annotations
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Sets extra vault server Service (active) annotations
|
||||||
|
*/}}
|
||||||
|
{{- define "vault.service.active.annotations" -}}
|
||||||
|
{{- if .Values.server.service.active.annotations }}
|
||||||
|
{{- $tp := typeOf .Values.server.service.active.annotations }}
|
||||||
|
{{- if eq $tp "string" }}
|
||||||
|
{{- tpl .Values.server.service.active.annotations . | nindent 4 }}
|
||||||
|
{{- else }}
|
||||||
|
{{- toYaml .Values.server.service.active.annotations | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end -}}
|
||||||
|
{{/*
|
||||||
|
Sets extra vault server Service annotations
|
||||||
|
*/}}
|
||||||
|
{{- define "vault.service.standby.annotations" -}}
|
||||||
|
{{- if .Values.server.service.standby.annotations }}
|
||||||
|
{{- $tp := typeOf .Values.server.service.standby.annotations }}
|
||||||
|
{{- if eq $tp "string" }}
|
||||||
|
{{- tpl .Values.server.service.standby.annotations . | nindent 4 }}
|
||||||
|
{{- else }}
|
||||||
|
{{- toYaml .Values.server.service.standby.annotations | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
{{/*
|
{{/*
|
||||||
Sets PodSecurityPolicy annotations
|
Sets PodSecurityPolicy annotations
|
||||||
*/}}
|
*/}}
|
||||||
|
|
|
@ -22,7 +22,8 @@ metadata:
|
||||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||||
vault-active: "true"
|
vault-active: "true"
|
||||||
annotations:
|
annotations:
|
||||||
{{ template "vault.service.annotations" .}}
|
{{- template "vault.service.active.annotations" . }}
|
||||||
|
{{- template "vault.service.annotations" . }}
|
||||||
spec:
|
spec:
|
||||||
{{- if .Values.server.service.type}}
|
{{- if .Values.server.service.type}}
|
||||||
type: {{ .Values.server.service.type }}
|
type: {{ .Values.server.service.type }}
|
||||||
|
|
|
@ -21,7 +21,8 @@ metadata:
|
||||||
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 }}
|
||||||
annotations:
|
annotations:
|
||||||
{{ template "vault.service.annotations" .}}
|
{{- template "vault.service.standby.annotations" . }}
|
||||||
|
{{- template "vault.service.annotations" . }}
|
||||||
spec:
|
spec:
|
||||||
{{- if .Values.server.service.type}}
|
{{- if .Values.server.service.type}}
|
||||||
type: {{ .Values.server.service.type }}
|
type: {{ .Values.server.service.type }}
|
||||||
|
|
|
@ -13,6 +13,31 @@ load _helpers
|
||||||
[ "${actual}" = "true" ]
|
[ "${actual}" = "true" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "server/ha-active-Service: with active annotations" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
--show-only templates/server-ha-active-service.yaml \
|
||||||
|
--set 'server.ha.enabled=true' \
|
||||||
|
--set 'server.service.active.annotations=vaultIsAwesome: true' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.metadata.annotations["vaultIsAwesome"]' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
}
|
||||||
|
@test "server/ha-active-Service: with both annotations set" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local object=$(helm template \
|
||||||
|
--show-only templates/server-ha-active-service.yaml \
|
||||||
|
--set 'server.ha.enabled=true' \
|
||||||
|
--set 'server.service.active.annotations=vaultIsAwesome: true' \
|
||||||
|
--set 'server.service.annotations=vaultIsNotAwesome: false' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.metadata' | tee /dev/stderr)
|
||||||
|
|
||||||
|
local actual=$(echo "$object" | yq '.annotations["vaultIsAwesome"]' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
actual=$(echo "$object" | yq '.annotations["vaultIsNotAwesome"]' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "false" ]
|
||||||
|
}
|
||||||
@test "server/ha-active-Service: disable with ha.enabled false" {
|
@test "server/ha-active-Service: disable with ha.enabled false" {
|
||||||
cd `chart_dir`
|
cd `chart_dir`
|
||||||
local actual=$( (helm template \
|
local actual=$( (helm template \
|
||||||
|
|
|
@ -24,6 +24,42 @@ load _helpers
|
||||||
[ "${actual}" = "true" ]
|
[ "${actual}" = "true" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "server/ha-standby-Service: with standby annotations string" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
--show-only templates/server-ha-standby-service.yaml \
|
||||||
|
--set 'server.ha.enabled=true' \
|
||||||
|
--set 'server.service.standby.annotations=vaultIsAwesome: true' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.metadata.annotations["vaultIsAwesome"]' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "server/ha-standby-Service: with standby annotations yaml" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
--show-only templates/server-ha-standby-service.yaml \
|
||||||
|
--set 'server.ha.enabled=true' \
|
||||||
|
--set 'server.service.standby.annotations.vaultIsAwesome=true' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.metadata.annotations["vaultIsAwesome"]' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
}
|
||||||
|
@test "server/ha-standby-Service: with both annotations set" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local object=$(helm template \
|
||||||
|
--show-only templates/server-ha-standby-service.yaml \
|
||||||
|
--set 'server.ha.enabled=true' \
|
||||||
|
--set 'server.service.standby.annotations=vaultIsAwesome: true' \
|
||||||
|
--set 'server.service.annotations=vaultIsNotAwesome: false' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.metadata' | tee /dev/stderr)
|
||||||
|
|
||||||
|
local actual=$(echo "$object" | yq '.annotations["vaultIsAwesome"]' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
actual=$(echo "$object" | yq '.annotations["vaultIsNotAwesome"]' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "false" ]
|
||||||
|
}
|
||||||
@test "server/ha-standby-Service: disable with ha.enabled false" {
|
@test "server/ha-standby-Service: disable with ha.enabled false" {
|
||||||
cd `chart_dir`
|
cd `chart_dir`
|
||||||
local actual=$( (helm template \
|
local actual=$( (helm template \
|
||||||
|
|
|
@ -922,6 +922,12 @@
|
||||||
"properties": {
|
"properties": {
|
||||||
"enabled": {
|
"enabled": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"type": [
|
||||||
|
"object",
|
||||||
|
"string"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -956,6 +962,12 @@
|
||||||
"properties": {
|
"properties": {
|
||||||
"enabled": {
|
"enabled": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"type": [
|
||||||
|
"object",
|
||||||
|
"string"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
12
values.yaml
12
values.yaml
|
@ -658,13 +658,21 @@ server:
|
||||||
service:
|
service:
|
||||||
enabled: true
|
enabled: true
|
||||||
# Enable or disable the vault-active service, which selects Vault pods that
|
# Enable or disable the vault-active service, which selects Vault pods that
|
||||||
# have labelled themselves as the cluster leader with `vault-active: "true"`
|
# have labeled themselves as the cluster leader with `vault-active: "true"`.
|
||||||
active:
|
active:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
# Extra annotations for the service definition. This can either be YAML or a
|
||||||
|
# YAML-formatted multi-line templated string map of the annotations to apply
|
||||||
|
# to the active service.
|
||||||
|
annotations: {}
|
||||||
# Enable or disable the vault-standby service, which selects Vault pods that
|
# Enable or disable the vault-standby service, which selects Vault pods that
|
||||||
# have labelled themselves as a cluster follower with `vault-active: "false"`
|
# have labeled themselves as a cluster follower with `vault-active: "false"`.
|
||||||
standby:
|
standby:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
# Extra annotations for the service definition. This can either be YAML or a
|
||||||
|
# YAML-formatted multi-line templated string map of the annotations to apply
|
||||||
|
# to the standby service.
|
||||||
|
annotations: {}
|
||||||
# If enabled, the service selectors will include `app.kubernetes.io/instance: {{ .Release.Name }}`
|
# If enabled, the service selectors will include `app.kubernetes.io/instance: {{ .Release.Name }}`
|
||||||
# When disabled, services may select Vault pods not deployed from the chart.
|
# When disabled, services may select Vault pods not deployed from the chart.
|
||||||
# Does not affect the headless vault-internal service with `ClusterIP: None`
|
# Does not affect the headless vault-internal service with `ClusterIP: None`
|
||||||
|
|
Loading…
Reference in a new issue