From 27b038e2d015c3e37457f8daff8bc8839e5959d5 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten-Lebbing Date: Mon, 21 Feb 2022 17:16:29 +0100 Subject: [PATCH] feat(common): add autolinking opion to ingress (#1922) * feat(common): add autolinking opion to ingress * bump --- .../common-test/ci/ingress-values.yaml | 21 +++++++++++++++++++ charts/library/common/Chart.yaml | 2 +- .../common/templates/classes/_ingress.tpl | 8 +++++++ charts/library/common/values.yaml | 3 +++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/charts/library/common-test/ci/ingress-values.yaml b/charts/library/common-test/ci/ingress-values.yaml index 9bf8cfe322e..a5a5c62dc27 100644 --- a/charts/library/common-test/ci/ingress-values.yaml +++ b/charts/library/common-test/ci/ingress-values.yaml @@ -8,6 +8,12 @@ service: ports: main: port: 8080 + autolink: + enabled: true + ports: + autolink: + enabled: true + port: 8081 args: - --port @@ -71,6 +77,21 @@ ingress: port: tls: [] + autolink: + enabled: true + fixedMiddlewares: + - chain-basic + hosts: + - host: label.chart-example.local + paths: + - path: / + pathType: Prefix + service: + name: + port: + tls: [] + autoLink: true + labellist: enabled: true nameOverride: diff --git a/charts/library/common/Chart.yaml b/charts/library/common/Chart.yaml index 151e224e319..eab8eba496f 100644 --- a/charts/library/common/Chart.yaml +++ b/charts/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 8.15.4 +version: 8.16.0 diff --git a/charts/library/common/templates/classes/_ingress.tpl b/charts/library/common/templates/classes/_ingress.tpl index 928d806b2a4..91b8cbb3c49 100644 --- a/charts/library/common/templates/classes/_ingress.tpl +++ b/charts/library/common/templates/classes/_ingress.tpl @@ -18,12 +18,20 @@ within the common library. {{- end -}} {{- $primaryService := get .Values.service (include "common.service.primary" .) -}} + {{- $autoLinkService := get .Values.service (include "common.service.primary" .) -}} {{- $defaultServiceName := $fullName -}} {{- if and (hasKey $primaryService "nameOverride") $primaryService.nameOverride -}} {{- $defaultServiceName = printf "%v-%v" $defaultServiceName $primaryService.nameOverride -}} {{- end -}} {{- $defaultServicePort := get $primaryService.ports (include "common.classes.service.ports.primary" (dict "values" $primaryService)) -}} + {{- if and (hasKey $values "nameOverride") ( $values.nameOverride ) ( $values.autoLink ) -}} + {{- $autoLinkService = get .Values.service $values.nameOverride -}} + {{- $defaultServiceName = $ingressName -}} + {{- $defaultServicePort = get $autoLinkService.ports $values.nameOverride -}} + {{- end -}} + + {{- $isStable := include "common.capabilities.ingress.isStable" . }} {{- $mddwrNamespace := "default" }} diff --git a/charts/library/common/values.yaml b/charts/library/common/values.yaml index 8617f1e09ff..a2813c04551 100644 --- a/charts/library/common/values.yaml +++ b/charts/library/common/values.yaml @@ -530,6 +530,9 @@ ingress: # -- Override the name suffix that is used for this ingress. nameOverride: + # -- Autolink the ingress to a service and port, both with the same name as the ingress. + autoLink: false + # -- disable to ignore any default middlwares enableFixedMiddlewares: true