Support UI service annotations (#19)
* support ui service annotations * Update templates/ui-service.yaml Co-Authored-By: Dat Truong <mr.anhdat@gmail.com> * fix service annotation indent and write unit tests
This commit is contained in:
parent
a049b48379
commit
e312f00a03
4 changed files with 54 additions and 1 deletions
|
@ -240,7 +240,7 @@ Set's the node selector for pod placement when running in standalone and HA mode
|
||||||
|
|
||||||
|
|
||||||
{{/*
|
{{/*
|
||||||
Set's extra pod annotations
|
Sets extra pod annotations
|
||||||
*/}}
|
*/}}
|
||||||
{{- define "vault.annotations" -}}
|
{{- define "vault.annotations" -}}
|
||||||
{{- if and (ne .mode "dev") .Values.server.annotations }}
|
{{- if and (ne .mode "dev") .Values.server.annotations }}
|
||||||
|
@ -249,6 +249,17 @@ Set's extra pod annotations
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Sets extra ui service annotations
|
||||||
|
*/}}
|
||||||
|
{{- define "vault.ui.annotations" -}}
|
||||||
|
{{- if and (ne .mode "dev") .Values.ui.annotations }}
|
||||||
|
annotations:
|
||||||
|
{{- toYaml .Values.ui.annotations | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
|
||||||
{{/*
|
{{/*
|
||||||
Set's the container resources if the user has set any.
|
Set's the container resources if the user has set any.
|
||||||
*/}}
|
*/}}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
{{ template "vault.mode" . }}
|
||||||
|
{{- if and (ne .mode "") (eq (.Values.global.enabled | toString) "true") }}
|
||||||
# Headless service for Vault server DNS entries. This service should only
|
# Headless service for Vault server DNS entries. This service should only
|
||||||
# point to Vault servers. For access to an agent, one should assume that
|
# point to Vault servers. For access to an agent, one should assume that
|
||||||
# the agent is installed locally on the node and the NODE_IP should be used.
|
# the agent is installed locally on the node and the NODE_IP should be used.
|
||||||
|
@ -14,6 +16,7 @@ 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 }}
|
||||||
app.kubernetes.io/version: {{ .Chart.Version | quote }}
|
app.kubernetes.io/version: {{ .Chart.Version | quote }}
|
||||||
|
{{- template "vault.ui.annotations" . }}
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
app.kubernetes.io/name: {{ include "vault.name" . }}
|
app.kubernetes.io/name: {{ include "vault.name" . }}
|
||||||
|
@ -25,3 +28,5 @@ spec:
|
||||||
targetPort: 8200
|
targetPort: 8200
|
||||||
type: {{ .Values.ui.serviceType | default "ClusterIP" }}
|
type: {{ .Values.ui.serviceType | default "ClusterIP" }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
{{ end }}
|
||||||
|
|
|
@ -136,3 +136,35 @@ load _helpers
|
||||||
yq -r '.spec.type' | tee /dev/stderr)
|
yq -r '.spec.type' | tee /dev/stderr)
|
||||||
[ "${actual}" = "LoadBalancer" ]
|
[ "${actual}" = "LoadBalancer" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "ui/Service: specify annotations" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
-x templates/ui-service.yaml \
|
||||||
|
--set 'server.dev.enabled=true' \
|
||||||
|
--set 'ui.serviceType=LoadBalancer' \
|
||||||
|
--set 'ui.enabled=true' \
|
||||||
|
--set 'ui.annotations.foo=bar' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.metadata.annotations["foo"]' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "null" ]
|
||||||
|
|
||||||
|
local actual=$(helm template \
|
||||||
|
-x templates/ui-service.yaml \
|
||||||
|
--set 'server.ha.enabled=true' \
|
||||||
|
--set 'ui.serviceType=LoadBalancer' \
|
||||||
|
--set 'ui.enabled=true' \
|
||||||
|
--set 'ui.annotations.foo=bar' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.metadata.annotations["foo"]' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "bar" ]
|
||||||
|
|
||||||
|
local actual=$(helm template \
|
||||||
|
-x templates/ui-service.yaml \
|
||||||
|
--set 'server.ha.enabled=true' \
|
||||||
|
--set 'ui.serviceType=LoadBalancer' \
|
||||||
|
--set 'ui.enabled=true' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.metadata.annotations["foo"]' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "null" ]
|
||||||
|
}
|
|
@ -212,3 +212,8 @@ ui:
|
||||||
# balancer (for supported K8S installations) to access the UI.
|
# balancer (for supported K8S installations) to access the UI.
|
||||||
enabled: false
|
enabled: false
|
||||||
serviceType: "ClusterIP"
|
serviceType: "ClusterIP"
|
||||||
|
|
||||||
|
# Extra annotations to attach to the ui service
|
||||||
|
# This should be a multi-line string mapping directly to the a map of
|
||||||
|
# the annotations to apply to the ui service
|
||||||
|
annotations: {}
|
||||||
|
|
Loading…
Reference in a new issue