From 297b5c87e1a5d2950848e7b8d2bbf2357155d1bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rodr=C3=ADguez?= Date: Thu, 12 Oct 2023 18:24:55 -0400 Subject: [PATCH] Support multiple paths per webservice ingress --- .../charts/webservice/templates/_datamodel.tpl | 18 ++++++++++++------ .../charts/webservice/templates/_ingress.tpl | 4 +++- charts/gitlab/charts/webservice/values.yaml | 7 ++++--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/charts/gitlab/charts/webservice/templates/_datamodel.tpl b/charts/gitlab/charts/webservice/templates/_datamodel.tpl index 26ee271746..bb2e335a3e 100644 --- a/charts/gitlab/charts/webservice/templates/_datamodel.tpl +++ b/charts/gitlab/charts/webservice/templates/_datamodel.tpl @@ -14,8 +14,7 @@ item, ensuring presence of all keys. {{/* make sure we always have at least one */}} {{- if not $.Values.deployments -}} {{- $blank := fromYaml (include "webservice.datamodel.blank" $) -}} -{{- $_ := set $blank.ingress "path" (coalesce $.Values.ingress.path $.Values.global.ingress.path) -}} -{{- $_ := set $blank.extraIngress "path" (coalesce $.Values.extraIngress.path $.Values.global.ingress.path) -}} +{{- $_ := set $blank.ingress "paths" (list (coalesce $.Values.ingress.path $.Values.global.ingress.path)) -}} {{- $_ := set $.Values "deployments" (dict "default" (dict)) -}} {{- $_ := set $.Values.deployments "default" $blank -}} {{- end -}} @@ -28,13 +27,20 @@ item, ensuring presence of all keys. {{/* - $_ := mergeOverwrite $filledValues $values - */}} {{- $_ := set $filledValues "name" $deployment -}} {{- $_ := set $filledValues "fullname" $fullname -}} +{{/* move top level `path` to the `paths` list */}} +{{- if $filledValues.ingress.path -}} +{{- $_ := prepend $filledValues.ingress.paths $filledValues.ingress.path -}} +{{- $_ := unset $filledValues.ingress "path" -}} +{{- end -}} {{- $_ := set $.Values.deployments $deployment $filledValues -}} -{{- if has ($filledValues.ingress.path | toString ) (list "/" "/*") -}} -{{- $_ := set $checks "hasBasePath" true -}} +{{- range $path := $filledValues.ingress.paths -}} +{{- if has ($path | toString ) (list "/" "/*") -}} +{{- $_ := set $checks "hasBasePath" true -}} +{{- end -}} {{- end -}} {{- end -}} {{- if and (not $.Values.ingress.requireBaseBath) (not $checks.hasBasePath) -}} -{{- fail "FATAL: Webservice: no deployment with ingress.path '/' or '/*' specified." -}} +{{- fail "FATAL: Webservice: no deployment with ingress.paths '/' or '/*' specified." -}} {{- end -}} {{- end -}} @@ -50,7 +56,7 @@ This is output as YAML, it can be read back in as a dict via `toYaml`. {{- define "webservice.datamodel.blank" -}} {{- range $k, $v := (dict "ingress" .Values.ingress "extraIngress" .Values.extraIngress) }} {{ $k }}: - path: # intentionally not setting a value. User must set. + paths: [] # intentionally not setting a value. User must set. pathType: Prefix annotations: {{- $v.annotations | toYaml | nindent 4 }} diff --git a/charts/gitlab/charts/webservice/templates/_ingress.tpl b/charts/gitlab/charts/webservice/templates/_ingress.tpl index 283b90a95c..ee0c8f9153 100644 --- a/charts/gitlab/charts/webservice/templates/_ingress.tpl +++ b/charts/gitlab/charts/webservice/templates/_ingress.tpl @@ -57,7 +57,8 @@ spec: - host: {{ .host }} http: paths: - - path: {{ .deployment.ingress.path }} + {{- range $path := .deployment.ingress.paths }} + - path: {{ $path }} {{ if or (.root.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress") (eq $global.ingress.apiVersion "networking.k8s.io/v1") -}} pathType: {{ default .deployment.ingress.pathType $global.ingress.pathType }} backend: @@ -70,6 +71,7 @@ spec: serviceName: {{ template "webservice.fullname.withSuffix" .deployment }} servicePort: {{ .root.Values.service.workhorseExternalPort }} {{- end -}} + {{- end }} {{- if (and .tlsSecret (eq (include "gitlab.ingress.tls.enabled" .root) "true" )) }} tls: - hosts: diff --git a/charts/gitlab/charts/webservice/values.yaml b/charts/gitlab/charts/webservice/values.yaml index 951a44d0d7..6fc91a0dc9 100644 --- a/charts/gitlab/charts/webservice/values.yaml +++ b/charts/gitlab/charts/webservice/values.yaml @@ -123,7 +123,7 @@ extraIngress: proxyConnectTimeout: 15 proxyReadTimeout: 600 proxyBodySize: "512m" - # hostname: + # hostname: tls: {} # secretName: # smartcardSecretName: @@ -479,12 +479,13 @@ priorityClassName: "" # resource for tracking. # https://docs.gitlab.com/charts/charts/gitlab/webservice/#deployments deployments: {} - # There must always be at least one, with `xyz.ingress.path: /` + # There must always be at least one, with `xyz.ingress.paths: ["/"]` # unless `ingress.requireBasePath: false` # # default: # ingress: - # path: / + # paths: + # - / affinity: podAntiAffinity: -- GitLab