Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration options for Vault UI service #285

Merged
merged 3 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions templates/ui-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
{{- if ne .mode "external" }}
{{- if and (ne .mode "") (eq (.Values.global.enabled | toString) "true") }}
{{- if eq (.Values.ui.enabled | toString) "true" }}
# Headless service for Vault server DNS entries. This service should only
# 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.
# If the node can't run a Vault agent, then this service can be used to
# communicate directly to a server agent.
apiVersion: v1
kind: Service
metadata:
Expand All @@ -23,7 +18,10 @@ spec:
app.kubernetes.io/name: {{ include "vault.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
component: server
publishNotReadyAddresses: true
{{- if and (.Values.ui.activeVaultPodOnly) (eq .mode "ha") }}
vault-active: "true"
{{- end }}
publishNotReadyAddresses: {{ .Values.ui.publishNotReadyAddresses }}
ports:
- name: {{ include "vault.scheme" . }}
port: {{ .Values.ui.externalPort }}
Expand All @@ -43,5 +41,5 @@ spec:
{{- end }}
{{- end -}}

{{ end }}
{{ end }}
{{- end }}
{{- end }}
52 changes: 52 additions & 0 deletions test/unit/ui-service.bats
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,55 @@ load _helpers
yq -r '.spec.ports[0].name' | tee /dev/stderr)
[ "${actual}" = "https" ]
}

@test "ui/Service: publishNotReadyAddresses set true by default" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/ui-service.yaml \
--set 'ui.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.publishNotReadyAddresses' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "ui/Service: publishNotReadyAddresses can be set to false" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/ui-service.yaml \
--set 'ui.enabled=true' \
--set 'ui.publishNotReadyAddresses=false' \
. | tee /dev/stderr |
yq -r '.spec.publishNotReadyAddresses' | tee /dev/stderr)
[ "${actual}" = 'false' ]
}

@test "ui/Service: active pod only selector not set by default" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/ui-service.yaml \
--set 'ui.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.selector["vault-active"]' | tee /dev/stderr)
[ "${actual}" = "null" ]
}

@test "ui/Service: active pod only selector can be set on HA" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/ui-service.yaml \
--set 'ui.enabled=true' \
--set 'ui.activeVaultPodOnly=true' \
--set 'server.dev.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.selector["vault-active"]' | tee /dev/stderr)
[ "${actual}" = 'null' ]

local actual=$(helm template \
--show-only templates/ui-service.yaml \
--set 'ui.enabled=true' \
--set 'ui.activeVaultPodOnly=true' \
--set 'server.ha.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.selector["vault-active"]' | tee /dev/stderr)
[ "${actual}" = 'true' ]
}
3 changes: 3 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,9 @@ ui:
# example, setting this to "LoadBalancer" will create an external load
# balancer (for supported K8S installations) to access the UI.
enabled: false
publishNotReadyAddresses: true
# The service should only contain selectors for active Vault pod
activeVaultPodOnly: false
serviceType: "ClusterIP"
serviceNodePort: null
externalPort: 8200
Expand Down