{{- if .Values.httpProxy.enabled -}} {{- if .Values.createContourGateway -}} {{- if or ( eq "contour-internal" .Values.ingress.ingressClassName ) ( eq "contour-external" .Values.ingress.ingressClassName ) ( eq "contour-internal-0" .Values.ingress.ingressClassName ) ( eq "contour-internal-1" .Values.ingress.ingressClassName ) ( eq "contour-external-0" .Values.ingress.ingressClassName ) ( eq "contour-external-1" .Values.ingress.ingressClassName ) }} {{- $servicePortNumber := .Values.ingress.servicePortNumber | default 80 -}} {{- $servicePort := .Values.ingress.servicePort -}} {{- $pathType := .Values.ingress.pathType -}} {{- $namespace := .Values.namespace -}} {{- $ingressClassName := .Values.ingress.ingressClassName -}} {{ $count := 0 | int }} {{- range .Values.ingress.hosts }} {{- $hasName := hasKey . "name" -}} {{- $proxyName := ternary .name (printf "%s-%d" $namespace $count) (hasKey . "name") -}} {{- $childProxyName := $namespace -}} apiVersion: projectcontour.io/v1 kind: HTTPProxy metadata: namespace: {{ $namespace }} name: {{ $proxyName }} labels: {{- include "bifrost.labels" $ | nindent 4 }} annotations: projectcontour.io/ingress.class: {{ $.Values.ingress.ingressClassName }} spec: ingressClassName: {{ $ingressClassName }} virtualhost: fqdn: "{{ .host }}" {{- /* 1) Weighted paths render here as routes with services */}} routes: {{- range .paths }} {{- if hasKey . "backends" }} - conditions: {{- if or ( eq ( lower .pathType ) "prefix" ) ( eq ( lower .pathType ) "implementationspecific") }} - prefix: {{ .path }} {{- end }} {{- if ( eq ( lower .pathType ) "exact" ) }} - exact: {{ .path }} {{- end }} {{- if ( eq ( lower .pathType ) "regex" ) }} - regex: {{ .path }} {{- end }} {{- if ( eq ( lower .pathType ) "header" ) }} - header: name: {{ (split "___" .path)._0 }} {{ (split "___" .path)._1 }}: {{ (split "___" .path)._2 }} {{- end }} {{- if ( eq ( lower .pathType ) "prefixheader" ) }} - prefix: {{ (split "___" .path)._0 }} - header: name: {{ (split "___" .path)._1 }} {{ (split "___" .path)._2 }}: {{ (split "___" .path)._3 }} {{- end }} services: {{ range .backends }} {{- $svc := .service -}} {{- $hasSlash := contains "/" $svc -}} {{- $svcName := ternary (split "/" $svc)._1 $svc $hasSlash -}} {{- $targetNs := ternary .namespace (ternary (split "/" $svc)._0 $.Values.namespace $hasSlash) (hasKey . "namespace") -}} {{- $useAlias := ne $targetNs $.Values.namespace -}} {{- $aliasName := printf "%s-xns-%s" $svcName $targetNs | trunc 63 | trimSuffix "-" -}} - name: {{ ternary $aliasName $svcName $useAlias }} port: {{ $servicePortNumber }} {{- if .weight }} weight: {{ .weight }} {{- end }} {{- if $.Values.ingress.slowStart.enabled }} slowStartPolicy: window: {{ $.Values.ingress.slowStart.window }} aggression: {{ $.Values.ingress.slowStart.aggression | float64 | squote }} minWeightPercent: {{ $.Values.ingress.slowStart.minPercent }} {{- end }} {{ end }} {{- end }} {{- end }} {{- /* 2) Non-weighted paths keep using includes to your upstreams */}} includes: {{- range .paths }} {{- if not (hasKey . "backends") }} - conditions: {{- if or ( eq ( lower .pathType ) "prefix" ) ( eq ( lower .pathType ) "implementationspecific") }} - prefix: {{ .path }} {{- end }} {{- if ( eq ( lower .pathType ) "exact" ) }} - exact: {{ .path }} {{- end }} {{- if ( eq ( lower .pathType ) "regex" ) }} - regex: {{ .path }} {{- end }} {{- if ( eq ( lower .pathType ) "header" ) }} - header: name: {{ (split "___" .path)._0 }} {{ (split "___" .path)._1 }}: {{ (split "___" .path)._2 }} {{- end }} {{- if ( eq ( lower .pathType ) "prefixheader" ) }} - prefix: {{ (split "___" .path)._0 }} - header: name: {{ (split "___" .path)._1 }} {{ (split "___" .path)._2 }}: {{ (split "___" .path)._3 }} {{- end }} {{- if .targetService }} name: {{ .targetService | replace "/" "-" }} namespace: {{ (split "/" .targetService)._0 }} {{- else }} name: {{ $childProxyName }} namespace: {{ $namespace }} {{- end }} {{- end }} {{- end }} --- {{- if not $hasName }} {{ $count = add1 $count }} {{- /* Child HTTPProxy - routes with services */}} apiVersion: projectcontour.io/v1 kind: HTTPProxy metadata: namespace: {{ $namespace }} name: {{ $childProxyName }} labels: {{- include "bifrost.labels" $ | nindent 4 }} annotations: projectcontour.io/ingress.class: {{ $ingressClassName }} spec: ingressClassName: {{ $ingressClassName }} routes: - services: - name: {{ $namespace }} port: {{ $servicePortNumber | default "80" }} {{- if $.Values.ingress.slowStart.enabled }} slowStartPolicy: window: {{ $.Values.ingress.slowStart.window }} aggression: {{ $.Values.ingress.slowStart.aggression | float64 | squote }} minWeightPercent: {{ $.Values.ingress.slowStart.minPercent }} {{- end }} {{- if $.Values.ingress.enableWebsocket }} enableWebsockets: true {{- end }} {{- if $.Values.contourResponseTimeout }} timeoutPolicy: response: {{ $.Values.contourResponseTimeout }} {{- end }} --- {{- else }} {{ $count = add1 $count }} {{- end }} {{ end }} {{- end -}} {{- end -}} {{- end -}}