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
This commit is contained in:
eiximenis 2018-06-21 10:47:39 +02:00
parent 84761fd7af
commit 519ecc5897
12 changed files with 52 additions and 51 deletions

View File

@ -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

View File

@ -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 <prefix>.<dns>/<name>
{{- 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 <dns>/<name>-<sufix>
{{- else -}}
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just <dns>/<name>
{{- 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 -}}

View File

@ -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 }}

View File

@ -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 <prefix>.<dns>/<name>
{{- 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 <dns>/<name>-<sufix>
{{- else -}}
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just <dns>/<name>
{{- 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 -}}

View File

@ -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 }}

View File

@ -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 <prefix>.<dns>/<name>
{{- 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 <dns>/<name>-<sufix>
{{- else -}}
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just <dns>/<name>
{{- 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 -}}

View File

@ -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 }}

View File

@ -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

View File

@ -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 <prefix>.<dns>/<name>
{{- 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 <dns>/<name>-<sufix>
{{- else -}}
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just <dns>/<name>
{{- 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 -}}

View File

@ -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 }}

View File

@ -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 <prefix>.<dns>/<name>
{{- 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 <dns>/<name>-<sufix>
{{- else -}}
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just <dns>/<name>
{{- 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 -}}

View File

@ -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 }}