Files
2026-08-26 03:39:42 +05:30

143 lines
5.5 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 ) }}
{{- $servicePortNumber := .Values.ingress.servicePortNumber | default 80 -}}
{{- $servicePort := .Values.ingress.servicePort -}}
{{- $pathType := .Values.ingress.pathType -}}
{{- $namespace := .Values.namespace | default .Release.Namespace -}}
{{- $ingressClassName := .Values.ingress.ingressClassName -}}
{{ $count := 0 | int }}
{{- range .Values.ingress.hosts }}
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
namespace: {{ $namespace }}
name: {{ $namespace }}-{{ $count }}
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 -}}
{{- $releaseNs := $.Values.namespace | default $.Release.Namespace -}}
{{- $targetNs := ternary .namespace (ternary (split "/" $svc)._0 $releaseNs $hasSlash) (hasKey . "namespace") -}}
{{- $useAlias := ne $targetNs $releaseNs -}}
{{- $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: {{ $namespace }}
namespace: {{ $namespace }}
{{- end }}
{{- end }}
{{- end }}
---
{{ $count = add1 $count }}
{{- /* Child HTTPProxy - routes with services */}}
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
namespace: {{ $namespace }}
name: {{ $namespace }}
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 }}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}