|
| 1 | +{{- if .Values.httproute.enabled -}} |
| 2 | +--- |
| 3 | +{{- $fullName := include "py-app.fullname" . -}} |
| 4 | +{{- $svcPort := .Values.service.port -}} |
| 5 | +{{- $gatewayName := required "httproute.gatewayName is required and cannot be empty" .Values.httproute.gatewayName -}} |
| 6 | + |
| 7 | +apiVersion: gateway.networking.k8s.io/v1 |
| 8 | +kind: HTTPRoute |
| 9 | +metadata: |
| 10 | + name: {{ $fullName }} |
| 11 | + namespace: {{ .Release.Namespace }} |
| 12 | + {{- with .Values.httproute.annotations }} |
| 13 | + annotations: {{ toYaml . | nindent 4 }} |
| 14 | + {{- end }} |
| 15 | + labels: {{- include "py-app.labels" $ | nindent 4 }} |
| 16 | + {{- with .Values.httproute.labels }} |
| 17 | + {{- toYaml . | nindent 4 }} |
| 18 | + {{- end }} |
| 19 | +spec: |
| 20 | + parentRefs: |
| 21 | + - name: {{ $gatewayName }} |
| 22 | + {{- with .Values.httproute.gatewayNamespace }} |
| 23 | + namespace: {{ . }} |
| 24 | + {{- end }} |
| 25 | + kind: Gateway |
| 26 | + group: gateway.networking.k8s.io |
| 27 | + sectionName: {{ .Values.httproute.httpsListenerName }} |
| 28 | + {{- with .Values.httproute.hostnames }} |
| 29 | + hostnames: {{ tpl (toYaml .) $ | nindent 4 }} |
| 30 | + {{- end -}} |
| 31 | + {{ range .Values.httproute.rules }} |
| 32 | + rules: |
| 33 | + - backendRefs: |
| 34 | + - name: {{ $fullName }} |
| 35 | + port: {{ $svcPort }} |
| 36 | + {{- with .filters }} |
| 37 | + filters: {{ toYaml . | nindent 8 }} |
| 38 | + {{- end }} |
| 39 | + {{- with .matches }} |
| 40 | + matches: {{ toYaml . | nindent 8 }} |
| 41 | + {{- end }} |
| 42 | + {{- end}} |
| 43 | +--- |
| 44 | +{{- if .Values.httproute.httpsRedirect.enabled }} |
| 45 | +apiVersion: gateway.networking.k8s.io/v1 |
| 46 | +kind: HTTPRoute |
| 47 | +metadata: |
| 48 | + name: {{ $fullName }}-https-redirect |
| 49 | + namespace: {{ .Release.Namespace }} |
| 50 | + {{- with .Values.httproute.annotations }} |
| 51 | + annotations: {{ toYaml . | nindent 4 }} |
| 52 | + {{- end }} |
| 53 | + labels: {{- include "py-app.labels" $ | nindent 4 }} |
| 54 | + {{- with .Values.httproute.labels }} |
| 55 | + {{- toYaml . | nindent 4 }} |
| 56 | + {{- end }} |
| 57 | +spec: |
| 58 | + {{- with .Values.httproute.hostnames }} |
| 59 | + hostnames: {{ tpl (toYaml .) $ | nindent 4 }} |
| 60 | + {{- end }} |
| 61 | + parentRefs: |
| 62 | + - name: {{ $gatewayName }} |
| 63 | + {{- with .Values.httproute.gatewayNamespace }} |
| 64 | + namespace: {{ . }} |
| 65 | + {{- end }} |
| 66 | + kind: Gateway |
| 67 | + group: gateway.networking.k8s.io |
| 68 | + sectionName: {{ .Values.httproute.httpListenerName }} |
| 69 | + rules: |
| 70 | + - filters: |
| 71 | + - type: RequestRedirect |
| 72 | + requestRedirect: |
| 73 | + scheme: https |
| 74 | + statusCode: 301 |
| 75 | +{{- end }} |
| 76 | +{{- end }} |
0 commit comments