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 route subdomain support #779

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 4 additions & 0 deletions templates/server-route.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ metadata:
{{- end }}
{{- template "vault.route.annotations" . }}
spec:
{{- if .Values.server.route.subdomain }}
subdomain: {{ .Values.server.route.subdomain }}
{{- else if .Values.server.route.host }}
host: {{ .Values.server.route.host }}
{{- end }}
to:
kind: Service
name: {{ $serviceName }}
Expand Down
46 changes: 46 additions & 0 deletions test/unit/server-route.bats
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,52 @@ load _helpers
[ "${actual}" = 'test.com' ]
}

@test "server/route: OpenShift - checking subdomain entry takes precedence over any host entry" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-route.yaml \
--set 'global.openshift=true' \
--set 'server.route.enabled=true' \
--set 'server.route.host=test.com' \
--set 'server.route.subdomain=vault' \
. | tee /dev/stderr |
yq -r '.spec.host' | tee /dev/stderr)
[ "${actual}" = "null" ]

local actual=$(helm template \
--show-only templates/server-route.yaml \
--set 'global.openshift=true' \
--set 'server.route.enabled=true' \
--set 'server.route.host=test.com' \
--set 'server.route.subdomain=vault' \
. | tee /dev/stderr |
yq -r '.spec.subdomain' | tee /dev/stderr)
[ "${actual}" = "vault" ]
}

@test "server/route: OpenShift - checking when subdomain and host are both null" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-route.yaml \
--set 'global.openshift=true' \
--set 'server.route.enabled=true' \
--set 'server.route.host=null' \
--set 'server.route.subdomain=null' \
. | tee /dev/stderr |
yq -r '.spec.subdomain' | tee /dev/stderr)
[ "${actual}" = 'null' ]

local actual=$(helm template \
--show-only templates/server-route.yaml \
--set 'global.openshift=true' \
--set 'server.route.enabled=true' \
--set 'server.route.host=null' \
--set 'server.route.subdomain=null' \
. | tee /dev/stderr |
yq -r '.spec.host' | tee /dev/stderr)
[ "${actual}" = 'null' ]
}

@test "server/route: OpenShift - vault backend should be added when I specify a path" {
cd `chart_dir`

Expand Down
6 changes: 6 additions & 0 deletions values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,12 @@
"host": {
"type": "string"
},
"subdomain": {
"type": [
"null",
"string"
]
},
"labels": {
"type": "object"
},
Expand Down
7 changes: 7 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,13 @@ server:
labels: {}
annotations: {}
host: chart-example.local

# subdomain is unset by default. if set it will take precedence over whatever host:
# subdomains are DNS subdomains that are then requested within the ingress
# controller's domain. So setting:
# "subdomain: foo" will create "foo.apps.mycluster.com" as the final host route
subdomain: null

# tls will be passed directly to the route's TLS config, which
# can be used to configure other termination methods that terminate
# TLS at the router
Expand Down
Loading