Helm-Toolkit: Make ingress manifest work for more than public endpoints

This PS enables the ingress manifest function to work for all endpoints
rather than just public.

Change-Id: I3b454bb24a763f51896e845b767fd9d28f5b07dc
Signed-off-by: Pete Birley <pete@port.direct>
This commit is contained in:
Pete Birley 2019-01-28 17:21:40 -06:00
parent 0a077f8996
commit 3eb0517fc9

View File

@ -60,7 +60,7 @@ values: |
default: 9311 default: 9311
public: 80 public: 80
usage: | usage: |
{{- include "helm-toolkit.manifests.ingress" ( dict "envAll" . "backendServiceType" "key-manager" "backendPort" "b-api" ) -}} {{- include "helm-toolkit.manifests.ingress" ( dict "envAll" . "backendServiceType" "key-manager" "backendPort" "b-api" "endpoint" "public" ) -}}
return: | return: |
--- ---
apiVersion: extensions/v1beta1 apiVersion: extensions/v1beta1
@ -158,10 +158,11 @@ return: |
{{- $backendService := index . "backendService" | default "api" -}} {{- $backendService := index . "backendService" | default "api" -}}
{{- $backendServiceType := index . "backendServiceType" -}} {{- $backendServiceType := index . "backendServiceType" -}}
{{- $backendPort := index . "backendPort" -}} {{- $backendPort := index . "backendPort" -}}
{{- $ingressName := tuple $backendServiceType "public" $envAll | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }} {{- $endpoint := index . "endpoint" | default "public" -}}
{{- $ingressName := tuple $backendServiceType $endpoint $envAll | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }}
{{- $backendName := tuple $backendServiceType "internal" $envAll | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }} {{- $backendName := tuple $backendServiceType "internal" $envAll | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }}
{{- $hostName := tuple $backendServiceType "public" $envAll | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }} {{- $hostName := tuple $backendServiceType $endpoint $envAll | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }}
{{- $hostNameFull := tuple $backendServiceType "public" $envAll | include "helm-toolkit.endpoints.hostname_fqdn_endpoint_lookup" }} {{- $hostNameFull := tuple $backendServiceType $endpoint $envAll | include "helm-toolkit.endpoints.hostname_fqdn_endpoint_lookup" }}
--- ---
apiVersion: extensions/v1beta1 apiVersion: extensions/v1beta1
kind: Ingress kind: Ingress
@ -189,12 +190,15 @@ metadata:
{{ toYaml (index $envAll.Values.network $backendService "ingress" "annotations") | indent 4 }} {{ toYaml (index $envAll.Values.network $backendService "ingress" "annotations") | indent 4 }}
spec: spec:
{{- $host := index $envAll.Values.endpoints ( $backendServiceType | replace "-" "_" ) "host_fqdn_override" }} {{- $host := index $envAll.Values.endpoints ( $backendServiceType | replace "-" "_" ) "host_fqdn_override" }}
{{- if hasKey $host "public" }} {{- if hasKey $host $endpoint }}
{{- if kindIs "map" $host.public }} {{- $endpointHost := index $host $endpoint }}
{{- if hasKey $host.public "tls" }} {{- if kindIs "map" $endpointHost }}
{{- if and $host.public.tls.key $host.public.tls.crt }} {{- if hasKey $endpointHost "tls" }}
{{- if and ( not ( empty $endpointHost.tls.key ) ) ( not ( empty $endpointHost.tls.crt ) ) }}
{{- $secretName := index $envAll.Values.secrets "tls" ( $backendServiceType | replace "-" "_" ) $backendService $endpoint }}
{{- $_ := required "You need to specify a secret in your values for the endpoint" $secretName }}
tls: tls:
- secretName: {{ index $envAll.Values.secrets "tls" ( $backendServiceType | replace "-" "_" ) $backendService "public" }} - secretName: {{ $secretName }}
hosts: hosts:
- {{ index $hostNameFullRules "vHost" }} - {{ index $hostNameFullRules "vHost" }}
{{- end }} {{- end }}