142 lines
5.4 KiB
YAML
142 lines
5.4 KiB
YAML
{{- 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 ) }}
|
|
{{- $ctx := dict "helm" . -}}
|
|
{{- $fullname := include "vm.fullname" $ctx -}}
|
|
{{- $servicePortNumber := .Values.ingress.servicePortNumber | default 8080 -}}
|
|
{{- $namespace := .Release.Namespace -}}
|
|
{{- $ingressClassName := .Values.ingress.ingressClassName -}}
|
|
{{ $count := 0 | int }}
|
|
{{- range .Values.ingress.hosts }}
|
|
apiVersion: projectcontour.io/v1
|
|
kind: HTTPProxy
|
|
metadata:
|
|
namespace: {{ $namespace }}
|
|
name: {{ $fullname }}-{{ $count }}
|
|
labels:
|
|
{{- include "vm.labels" (dict "helm" $) | 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 $.Release.Namespace $hasSlash) (hasKey . "namespace") -}}
|
|
{{- $useAlias := ne $targetNs $.Release.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: {{ $fullname }}
|
|
namespace: {{ $namespace }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
---
|
|
{{ $count = add1 $count }}
|
|
{{- /* Child HTTPProxy - routes with services */}}
|
|
apiVersion: projectcontour.io/v1
|
|
kind: HTTPProxy
|
|
metadata:
|
|
namespace: {{ $namespace }}
|
|
name: {{ $fullname }}
|
|
labels:
|
|
{{- include "vm.labels" (dict "helm" $) | nindent 4 }}
|
|
annotations:
|
|
projectcontour.io/ingress.class: {{ $ingressClassName }}
|
|
spec:
|
|
ingressClassName: {{ $ingressClassName }}
|
|
routes:
|
|
- services:
|
|
- name: {{ $fullname }}
|
|
port: {{ $servicePortNumber }}
|
|
{{- 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 }}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|