From fba699574ef1296b44f745a08b6df1d9d34fa764 Mon Sep 17 00:00:00 2001 From: George Kaz Date: Tue, 21 Apr 2020 22:53:31 +0100 Subject: [PATCH 1/3] Use active service on ingress when ha fix a missing : revert values as requested --- templates/server-ingress.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/server-ingress.yaml b/templates/server-ingress.yaml index b17eb5cd9..e6a8fdba7 100644 --- a/templates/server-ingress.yaml +++ b/templates/server-ingress.yaml @@ -2,6 +2,9 @@ {{- if ne .mode "external" }} {{- if .Values.server.ingress.enabled -}} {{- $serviceName := include "vault.fullname" . -}} +{{- if and (eq .mode "ha" ) (and (eq (.Values.server.service.enabled | toString) "true" ) (eq (.Values.global.enabled | toString) "true")) }} +{{- $serviceName := printf "%s-%s" $serviceName "active" -}} +{{- end }} {{- $servicePort := .Values.server.service.port -}} {{ if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" }} apiVersion: networking.k8s.io/v1beta1 From 46a84587941b843092d8ef891664cc46f6f2bd83 Mon Sep 17 00:00:00 2001 From: georgekaz Date: Wed, 27 May 2020 18:06:12 +0100 Subject: [PATCH 2/3] Update templates/server-ingress.yaml Co-authored-by: Theron Voran --- templates/server-ingress.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/server-ingress.yaml b/templates/server-ingress.yaml index e6a8fdba7..9b3d112d0 100644 --- a/templates/server-ingress.yaml +++ b/templates/server-ingress.yaml @@ -3,7 +3,7 @@ {{- if .Values.server.ingress.enabled -}} {{- $serviceName := include "vault.fullname" . -}} {{- if and (eq .mode "ha" ) (and (eq (.Values.server.service.enabled | toString) "true" ) (eq (.Values.global.enabled | toString) "true")) }} -{{- $serviceName := printf "%s-%s" $serviceName "active" -}} +{{- $serviceName = printf "%s-%s" $serviceName "active" -}} {{- end }} {{- $servicePort := .Values.server.service.port -}} {{ if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" }} From 1bd6cc8cb44ba23b11256cfcc7233c09118ecf99 Mon Sep 17 00:00:00 2001 From: George Kaz Date: Thu, 28 May 2020 01:02:49 +0100 Subject: [PATCH 3/3] added unit test for active service when ha --- test/unit/server-ingress.bats | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/unit/server-ingress.bats b/test/unit/server-ingress.bats index 8660920da..5af493847 100755 --- a/test/unit/server-ingress.bats +++ b/test/unit/server-ingress.bats @@ -93,3 +93,31 @@ load _helpers yq -r '.metadata.annotations["kubernetes.io/ingress.class"]' | tee /dev/stderr) [ "${actual}" = "nginx" ] } + +@test "server/ingress: uses active service when ha - yaml" { + cd `chart_dir` + + local actual=$(helm template \ + --show-only templates/server-ingress.yaml \ + --set 'server.ingress.enabled=true' \ + --set 'server.dev.enabled=false' \ + --set 'server.ha.enabled=true' \ + --set 'server.service.enabled=true' \ + . | tee /dev/stderr | + yq -r '.spec.rules[0].http.paths[0].backend.serviceName' | tee /dev/stderr) + [ "${actual}" = "RELEASE-NAME-vault-active" ] +} + +@test "server/ingress: uses regular service when not ha - yaml" { + cd `chart_dir` + + local actual=$(helm template \ + --show-only templates/server-ingress.yaml \ + --set 'server.ingress.enabled=true' \ + --set 'server.dev.enabled=false' \ + --set 'server.ha.enabled=false' \ + --set 'server.service.enabled=true' \ + . | tee /dev/stderr | + yq -r '.spec.rules[0].http.paths[0].backend.serviceName' | tee /dev/stderr) + [ "${actual}" = "RELEASE-NAME-vault" ] +} \ No newline at end of file