diff --git a/k8s/helm/app.yaml b/k8s/helm/app.yaml index 946a6f594..f0a7edeb2 100644 --- a/k8s/helm/app.yaml +++ b/k8s/helm/app.yaml @@ -5,7 +5,6 @@ app: # app global settings name: "my-eshop" # Override for custom app name ingress: # ingress related settings - suffix: false # if true ingress endpoints are suffixed with .Values.appName value (or .Release.Name if the 1st do not exist) entries: basket: basket-api # ingress entry for basket api catalog: catalog-api # ingress entry for catalog api diff --git a/k8s/helm/basket-api/templates/_names.tpl b/k8s/helm/basket-api/templates/_names.tpl index bbf3888d5..0611ab704 100644 --- a/k8s/helm/basket-api/templates/_names.tpl +++ b/k8s/helm/basket-api/templates/_names.tpl @@ -17,18 +17,22 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- if $ctx.Values.app.ingress.suffix -}} {{- $suffix := include "suffix-name" $ctx -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ {{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- end -}} {{- end -}} {{- end -}} {{ define "pathBase" -}} -{{- if .Values.app.ingress.suffix -}} +{{- if .Values.inf.k8s.suffix -}} {{- $suffix := include "suffix-name" . -}} {{- printf "%s-%s" .Values.pathBase $suffix -}} {{- else -}} diff --git a/k8s/helm/basket-api/templates/ingress.yaml b/k8s/helm/basket-api/templates/ingress.yaml index 9a47bb33f..f34e71680 100644 --- a/k8s/helm/basket-api/templates/ingress.yaml +++ b/k8s/helm/basket-api/templates/ingress.yaml @@ -19,20 +19,16 @@ spec: tls: {{- range .Values.ingress.tls }} - hosts: - {{- range .hosts }} - - {{ . }} - {{- end }} + - {{ .Values.inf.k8s.dns }} secretName: {{ .secretName }} {{- end }} {{- end }} rules: - {{- range .Values.ingress.hosts }} - - host: {{ . }} + - host: {{ .Values.inf.k8s.dns }} http: paths: - path: {{ $ingressPath }} backend: serviceName: {{ $fullName }} servicePort: http - {{- end }} {{- end }} diff --git a/k8s/helm/catalog-api/templates/_names.tpl b/k8s/helm/catalog-api/templates/_names.tpl index bbf3888d5..0611ab704 100644 --- a/k8s/helm/catalog-api/templates/_names.tpl +++ b/k8s/helm/catalog-api/templates/_names.tpl @@ -17,18 +17,22 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- if $ctx.Values.app.ingress.suffix -}} {{- $suffix := include "suffix-name" $ctx -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ {{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- end -}} {{- end -}} {{- end -}} {{ define "pathBase" -}} -{{- if .Values.app.ingress.suffix -}} +{{- if .Values.inf.k8s.suffix -}} {{- $suffix := include "suffix-name" . -}} {{- printf "%s-%s" .Values.pathBase $suffix -}} {{- else -}} diff --git a/k8s/helm/catalog-api/templates/ingress.yaml b/k8s/helm/catalog-api/templates/ingress.yaml index 0833fb717..3efabacac 100644 --- a/k8s/helm/catalog-api/templates/ingress.yaml +++ b/k8s/helm/catalog-api/templates/ingress.yaml @@ -19,20 +19,16 @@ spec: tls: {{- range .Values.ingress.tls }} - hosts: - {{- range .hosts }} - - {{ . }} - {{- end }} + - {{ .Values.inf.k8s.dns }} secretName: {{ .secretName }} {{- end }} {{- end }} rules: - {{- range .Values.ingress.hosts }} - - host: {{ . }} + - host: {{ .Values.inf.k8s.dns }} http: paths: - path: {{ $ingressPath }} backend: serviceName: {{ $fullName }} servicePort: http - {{- end }} {{- end }} diff --git a/k8s/helm/identity-api/templates/_names.tpl b/k8s/helm/identity-api/templates/_names.tpl index bbf3888d5..0611ab704 100644 --- a/k8s/helm/identity-api/templates/_names.tpl +++ b/k8s/helm/identity-api/templates/_names.tpl @@ -17,18 +17,22 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- if $ctx.Values.app.ingress.suffix -}} {{- $suffix := include "suffix-name" $ctx -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ {{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- end -}} {{- end -}} {{- end -}} {{ define "pathBase" -}} -{{- if .Values.app.ingress.suffix -}} +{{- if .Values.inf.k8s.suffix -}} {{- $suffix := include "suffix-name" . -}} {{- printf "%s-%s" .Values.pathBase $suffix -}} {{- else -}} diff --git a/k8s/helm/identity-api/templates/ingress.yaml b/k8s/helm/identity-api/templates/ingress.yaml index 40822737c..ff26c67b7 100644 --- a/k8s/helm/identity-api/templates/ingress.yaml +++ b/k8s/helm/identity-api/templates/ingress.yaml @@ -19,20 +19,16 @@ spec: tls: {{- range .Values.ingress.tls }} - hosts: - {{- range .hosts }} - - {{ . }} - {{- end }} + - {{ .Values.inf.k8s.dns }} secretName: {{ .secretName }} {{- end }} {{- end }} rules: - {{- range .Values.ingress.hosts }} - - host: {{ . }} + - host: {{ .Values.inf.k8s.dns }} http: paths: - path: {{ $ingressPath }} backend: serviceName: {{ $fullName }} servicePort: http - {{- end }} {{- end }} diff --git a/k8s/helm/inf.yaml b/k8s/helm/inf.yaml index 04814a97b..e112fa766 100644 --- a/k8s/helm/inf.yaml +++ b/k8s/helm/inf.yaml @@ -28,6 +28,8 @@ inf: key: "" # App insights to use k8s: # inf.k8s defines Kubernetes cluster global config dns: "" # k8s external IP or DNS. Value MUST BE PROVIDED using --set (--set inf.k8s.dns=my-cluster-dns) + dnsprefix: true # If 'true' DNS values in ingress are prefixed using values.app.name. Note that this requires "externalDNS" to be running in k8s cluster. If true "inf.k8s.suffix" is ignored. + suffix: false # If 'true' URL values in ingress are suffixed using values.app.name. That do not require anything special in cluster and still allows many apps using same ingress controller. Ignored if inf.k8s.dnsprefix is true misc: # inf.misc contains miscellaneous configuration related to infrastructure useLoadTest: false # If running under loading test or not useAzureStorage: false # If catalog api uses azure storage or not diff --git a/k8s/helm/ordering-api/templates/_names.tpl b/k8s/helm/ordering-api/templates/_names.tpl index bbf3888d5..0611ab704 100644 --- a/k8s/helm/ordering-api/templates/_names.tpl +++ b/k8s/helm/ordering-api/templates/_names.tpl @@ -17,18 +17,22 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- if $ctx.Values.app.ingress.suffix -}} {{- $suffix := include "suffix-name" $ctx -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ {{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- end -}} {{- end -}} {{- end -}} {{ define "pathBase" -}} -{{- if .Values.app.ingress.suffix -}} +{{- if .Values.inf.k8s.suffix -}} {{- $suffix := include "suffix-name" . -}} {{- printf "%s-%s" .Values.pathBase $suffix -}} {{- else -}} diff --git a/k8s/helm/ordering-api/templates/ingress.yaml b/k8s/helm/ordering-api/templates/ingress.yaml index 3bb61dbc7..ac390c7f8 100644 --- a/k8s/helm/ordering-api/templates/ingress.yaml +++ b/k8s/helm/ordering-api/templates/ingress.yaml @@ -19,20 +19,16 @@ spec: tls: {{- range .Values.ingress.tls }} - hosts: - {{- range .hosts }} - - {{ . }} - {{- end }} + - {{ .Values.inf.k8s.dns }} secretName: {{ .secretName }} {{- end }} {{- end }} rules: - {{- range .Values.ingress.hosts }} - - host: {{ . }} + - host: {{ .Values.inf.k8s.dns }} http: paths: - path: {{ $ingressPath }} backend: serviceName: {{ $fullName }} servicePort: http - {{- end }} {{- end }} diff --git a/k8s/helm/ordering-backgroundtasks/templates/_names.tpl b/k8s/helm/ordering-backgroundtasks/templates/_names.tpl index bbf3888d5..0611ab704 100644 --- a/k8s/helm/ordering-backgroundtasks/templates/_names.tpl +++ b/k8s/helm/ordering-backgroundtasks/templates/_names.tpl @@ -17,18 +17,22 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- if $ctx.Values.app.ingress.suffix -}} {{- $suffix := include "suffix-name" $ctx -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ {{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- end -}} {{- end -}} {{- end -}} {{ define "pathBase" -}} -{{- if .Values.app.ingress.suffix -}} +{{- if .Values.inf.k8s.suffix -}} {{- $suffix := include "suffix-name" . -}} {{- printf "%s-%s" .Values.pathBase $suffix -}} {{- else -}} diff --git a/k8s/helm/ordering-backgroundtasks/templates/ingress.yaml b/k8s/helm/ordering-backgroundtasks/templates/ingress.yaml index 1b2e5f66e..40a545cab 100644 --- a/k8s/helm/ordering-backgroundtasks/templates/ingress.yaml +++ b/k8s/helm/ordering-backgroundtasks/templates/ingress.yaml @@ -19,20 +19,16 @@ spec: tls: {{- range .Values.ingress.tls }} - hosts: - {{- range .hosts }} - - {{ . }} - {{- end }} + - {{ .Values.inf.k8s.dns }} secretName: {{ .secretName }} {{- end }} {{- end }} rules: - {{- range .Values.ingress.hosts }} - - host: {{ . }} + - host: {{ .Values.inf.k8s.dns }} http: paths: - path: {{ $ingressPath }} backend: serviceName: {{ $fullName }} servicePort: http - {{- end }} {{- end }}