Files
dokku/plugins/scheduler-k3s/templates/chart/ingress-route.yaml
T
Jose Diaz-Gonzalez d4b484a33a fix: replace existing port-map ingress objects with domain ingress objects
Domains cannot be reused across ingress objects, and port maps are a function of a domain, so the inversion here makes most sense (at the cost of some downtime when migrating.
2024-03-12 03:55:40 -04:00

56 lines
2.1 KiB
YAML

{{- $processName := "PROCESS_NAME" }}
{{- $config := index .Values.processes "PROCESS_NAME" }}
{{- if and $config.web.domains (eq $.Values.global.network.ingress_class "traefik") }}
{{- $mappings := dict }}
{{- range $pdx, $port_map := $config.web.port_maps }}
{{- $mappings := set $mappings $port_map.name "true" }}
{{- end }}
{{- range $pdx, $port_map := $config.web.port_maps }}
{{- if and (eq $port_map.scheme "https") (hasKey $mappings (printf "http-80-%.0f" $port_map.container_port)) }}
{{- continue }}
{{- end }}
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
annotations:
dokku.com/managed: "true"
{{ include "print.annotations" (dict "config" $.Values.global "key" "traefik_ingressroute") | indent 4 }}
{{ include "print.annotations" (dict "config" $config "key" "traefik_ingressroute") | indent 4 }}
labels:
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-{{ $processName }}
app.kubernetes.io/name: {{ $processName }}
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
{{ include "print.labels" (dict "config" $.Values.global "key" "traefik_ingressroute") | indent 4 }}
{{ include "print.labels" (dict "config" $config "key" "traefik_ingressroute") | indent 4 }}
name: {{ $.Values.global.app_name }}-{{ $processName }}-{{ $port_map.name }}
namespace: {{ $.Values.global.namespace }}
spec:
entryPoints:
{{- if $config.web.tls.enabled }}
- websecure
{{- end }}
- web
routes:
{{- range $ddx, $domain := $config.web.domains }}
- kind: Rule
match: Host(`{{ $domain.name }}`)
{{- if $config.web.tls.enabled }}
middlewares:
- name: {{ $.Values.global.app_name}}-{{ $processName }}-redirect-to-https
namespace: {{ $.Values.global.namespace }}
{{- end }}
services:
- name: {{ $.Values.global.app_name }}-{{ $processName }}
namespace: {{ $.Values.global.namespace }}
passHostHeader: true
port: {{ $port_map.name }}
scheme: http
{{- end }}
{{- if $config.web.tls.enabled }}
tls:
secretName: tls-{{ $.Values.global.app_name }}-{{ $processName }}
{{- end }}
{{- end }}
{{- end }}