Skip to content

Commit 519ecc5

Browse files
committed
Updating ingress templates to use .values.inf.k8s.dns value instead of values.ingress.hosts
Updating names template to allow generation of external url values using dns prefix
1 parent 84761fd commit 519ecc5

12 files changed

Lines changed: 52 additions & 51 deletions

File tree

k8s/helm/app.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
app: # app global settings
66
name: "my-eshop" # Override for custom app name
77
ingress: # ingress related settings
8-
suffix: false # if true ingress endpoints are suffixed with .Values.appName value (or .Release.Name if the 1st do not exist)
98
entries:
109
basket: basket-api # ingress entry for basket api
1110
catalog: catalog-api # ingress entry for catalog api

k8s/helm/basket-api/templates/_names.tpl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,22 @@
1717
{{- define "url-of" -}}
1818
{{- $name := first .}}
1919
{{- $ctx := last .}}
20-
{{- if $ctx.Values.app.ingress.suffix -}}
2120
{{- $suffix := include "suffix-name" $ctx -}}
22-
{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}}
21+
{{- if $ctx.Values.inf.k8s.dnsprefix -}}
22+
{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is <prefix>.<dns>/<name>
2323
{{- else -}}
24-
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}}
24+
{{- if $ctx.Values.inf.k8s.suffix -}}
25+
{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is <dns>/<name>-<sufix>
26+
{{- else -}}
27+
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just <dns>/<name>
28+
{{- end -}}
2529
{{- end -}}
2630
{{- end -}}
2731

2832

2933

3034
{{ define "pathBase" -}}
31-
{{- if .Values.app.ingress.suffix -}}
35+
{{- if .Values.inf.k8s.suffix -}}
3236
{{- $suffix := include "suffix-name" . -}}
3337
{{- printf "%s-%s" .Values.pathBase $suffix -}}
3438
{{- else -}}

k8s/helm/basket-api/templates/ingress.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,16 @@ spec:
1919
tls:
2020
{{- range .Values.ingress.tls }}
2121
- hosts:
22-
{{- range .hosts }}
23-
- {{ . }}
24-
{{- end }}
22+
- {{ .Values.inf.k8s.dns }}
2523
secretName: {{ .secretName }}
2624
{{- end }}
2725
{{- end }}
2826
rules:
29-
{{- range .Values.ingress.hosts }}
30-
- host: {{ . }}
27+
- host: {{ .Values.inf.k8s.dns }}
3128
http:
3229
paths:
3330
- path: {{ $ingressPath }}
3431
backend:
3532
serviceName: {{ $fullName }}
3633
servicePort: http
37-
{{- end }}
3834
{{- end }}

k8s/helm/catalog-api/templates/_names.tpl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,22 @@
1717
{{- define "url-of" -}}
1818
{{- $name := first .}}
1919
{{- $ctx := last .}}
20-
{{- if $ctx.Values.app.ingress.suffix -}}
2120
{{- $suffix := include "suffix-name" $ctx -}}
22-
{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}}
21+
{{- if $ctx.Values.inf.k8s.dnsprefix -}}
22+
{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is <prefix>.<dns>/<name>
2323
{{- else -}}
24-
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}}
24+
{{- if $ctx.Values.inf.k8s.suffix -}}
25+
{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is <dns>/<name>-<sufix>
26+
{{- else -}}
27+
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just <dns>/<name>
28+
{{- end -}}
2529
{{- end -}}
2630
{{- end -}}
2731

2832

2933

3034
{{ define "pathBase" -}}
31-
{{- if .Values.app.ingress.suffix -}}
35+
{{- if .Values.inf.k8s.suffix -}}
3236
{{- $suffix := include "suffix-name" . -}}
3337
{{- printf "%s-%s" .Values.pathBase $suffix -}}
3438
{{- else -}}

k8s/helm/catalog-api/templates/ingress.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,16 @@ spec:
1919
tls:
2020
{{- range .Values.ingress.tls }}
2121
- hosts:
22-
{{- range .hosts }}
23-
- {{ . }}
24-
{{- end }}
22+
- {{ .Values.inf.k8s.dns }}
2523
secretName: {{ .secretName }}
2624
{{- end }}
2725
{{- end }}
2826
rules:
29-
{{- range .Values.ingress.hosts }}
30-
- host: {{ . }}
27+
- host: {{ .Values.inf.k8s.dns }}
3128
http:
3229
paths:
3330
- path: {{ $ingressPath }}
3431
backend:
3532
serviceName: {{ $fullName }}
3633
servicePort: http
37-
{{- end }}
3834
{{- end }}

k8s/helm/identity-api/templates/_names.tpl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,22 @@
1717
{{- define "url-of" -}}
1818
{{- $name := first .}}
1919
{{- $ctx := last .}}
20-
{{- if $ctx.Values.app.ingress.suffix -}}
2120
{{- $suffix := include "suffix-name" $ctx -}}
22-
{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}}
21+
{{- if $ctx.Values.inf.k8s.dnsprefix -}}
22+
{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is <prefix>.<dns>/<name>
2323
{{- else -}}
24-
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}}
24+
{{- if $ctx.Values.inf.k8s.suffix -}}
25+
{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is <dns>/<name>-<sufix>
26+
{{- else -}}
27+
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just <dns>/<name>
28+
{{- end -}}
2529
{{- end -}}
2630
{{- end -}}
2731

2832

2933

3034
{{ define "pathBase" -}}
31-
{{- if .Values.app.ingress.suffix -}}
35+
{{- if .Values.inf.k8s.suffix -}}
3236
{{- $suffix := include "suffix-name" . -}}
3337
{{- printf "%s-%s" .Values.pathBase $suffix -}}
3438
{{- else -}}

k8s/helm/identity-api/templates/ingress.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,16 @@ spec:
1919
tls:
2020
{{- range .Values.ingress.tls }}
2121
- hosts:
22-
{{- range .hosts }}
23-
- {{ . }}
24-
{{- end }}
22+
- {{ .Values.inf.k8s.dns }}
2523
secretName: {{ .secretName }}
2624
{{- end }}
2725
{{- end }}
2826
rules:
29-
{{- range .Values.ingress.hosts }}
30-
- host: {{ . }}
27+
- host: {{ .Values.inf.k8s.dns }}
3128
http:
3229
paths:
3330
- path: {{ $ingressPath }}
3431
backend:
3532
serviceName: {{ $fullName }}
3633
servicePort: http
37-
{{- end }}
3834
{{- end }}

k8s/helm/inf.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ inf:
2828
key: "" # App insights to use
2929
k8s: # inf.k8s defines Kubernetes cluster global config
3030
dns: "" # k8s external IP or DNS. Value MUST BE PROVIDED using --set (--set inf.k8s.dns=my-cluster-dns)
31+
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.
32+
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
3133
misc: # inf.misc contains miscellaneous configuration related to infrastructure
3234
useLoadTest: false # If running under loading test or not
3335
useAzureStorage: false # If catalog api uses azure storage or not

k8s/helm/ordering-api/templates/_names.tpl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,22 @@
1717
{{- define "url-of" -}}
1818
{{- $name := first .}}
1919
{{- $ctx := last .}}
20-
{{- if $ctx.Values.app.ingress.suffix -}}
2120
{{- $suffix := include "suffix-name" $ctx -}}
22-
{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}}
21+
{{- if $ctx.Values.inf.k8s.dnsprefix -}}
22+
{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is <prefix>.<dns>/<name>
2323
{{- else -}}
24-
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}}
24+
{{- if $ctx.Values.inf.k8s.suffix -}}
25+
{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is <dns>/<name>-<sufix>
26+
{{- else -}}
27+
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just <dns>/<name>
28+
{{- end -}}
2529
{{- end -}}
2630
{{- end -}}
2731

2832

2933

3034
{{ define "pathBase" -}}
31-
{{- if .Values.app.ingress.suffix -}}
35+
{{- if .Values.inf.k8s.suffix -}}
3236
{{- $suffix := include "suffix-name" . -}}
3337
{{- printf "%s-%s" .Values.pathBase $suffix -}}
3438
{{- else -}}

k8s/helm/ordering-api/templates/ingress.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,16 @@ spec:
1919
tls:
2020
{{- range .Values.ingress.tls }}
2121
- hosts:
22-
{{- range .hosts }}
23-
- {{ . }}
24-
{{- end }}
22+
- {{ .Values.inf.k8s.dns }}
2523
secretName: {{ .secretName }}
2624
{{- end }}
2725
{{- end }}
2826
rules:
29-
{{- range .Values.ingress.hosts }}
30-
- host: {{ . }}
27+
- host: {{ .Values.inf.k8s.dns }}
3128
http:
3229
paths:
3330
- path: {{ $ingressPath }}
3431
backend:
3532
serviceName: {{ $fullName }}
3633
servicePort: http
37-
{{- end }}
3834
{{- end }}

0 commit comments

Comments
 (0)