From 867f0ec9efcdb4fc654362ba0f05d96b82639bbe Mon Sep 17 00:00:00 2001 From: almog8k Date: Mon, 26 Feb 2024 17:21:25 +0200 Subject: [PATCH] chore: auto ingress host --- helm/templates/_helpers.tpl | 12 ++++++++++++ helm/templates/ingress.yaml | 3 ++- helm/values.yaml | 4 +++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index 052db04..172017b 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -118,3 +118,15 @@ Returns the tracing url from global if exists or from the chart's values {{- .Values.env.metrics.url -}} {{- end -}} {{- end -}} + +{{/* +Returns the full ingress host. +*/}} +{{- define "files-server.ingress.host" -}} +{{- if .Values.ingress.host }} + {{- .Values.ingress.host -}} +{{- else -}} +{{- printf "%s-%s.%s" .Release.Name .Chart.Name .Values.global.ingress.domain | indent 1 }} +{{- end -}} +{{- end -}} + diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml index c4869e6..a4045e4 100644 --- a/helm/templates/ingress.yaml +++ b/helm/templates/ingress.yaml @@ -2,6 +2,7 @@ {{- $chartName := include "files-server.name" . -}} {{- $ingressName := include "ingress.fullname" . -}} {{- $serviceName := include "service.fullname" . -}} +{{- $ingressHost := include "files-server.ingress.host" . }} {{- if and (.Values.enabled) (.Values.ingress.enabled) -}} apiVersion: networking.k8s.io/v1 kind: Ingress @@ -43,5 +44,5 @@ spec: name: {{ $serviceName }} port: number: {{ .Values.env.port }} - host: {{ .Values.ingress.host | quote }} + host: {{ $ingressHost }} {{- end -}} diff --git a/helm/values.yaml b/helm/values.yaml index 3f8cf72..b225d54 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -14,6 +14,8 @@ global: enabled: false name: "" gpkgSubPath: "" + ingress: + domain: "example.com" enabled: true environment: development @@ -112,7 +114,7 @@ ingress: enabled: false type: 'nginx-org' # supported values: 'nginx-org' | 'nginx-kubernetes path: /api/raster/v1 - host: 'localhost' + host: '' tls: enabled: true useExternal: ''