Files
dokku/plugins/scheduler-k3s/templates/chart/ingress-route.yaml
T
Jose Diaz-Gonzalez ffd5248cc3 feat: route paths to non-web processes via proxy:route
Adds proxy:route:set/remove/clear/report so users can declare path-prefix routes to non-web Procfile processes without hand-writing nginx.conf.sigil. Routes are stored on the proxy plugin as a PropertyMap of path to process:port:strip, with set semantics so each invocation produces a fully-determined state and re-application is idempotent. A proxy-supports-routes capability trigger gates the command per backend - nginx-vhosts, traefik-vhosts, caddy-vhosts, and scheduler-k3s render routes today; openresty-vhosts and haproxy-vhosts refuse until their sidecar images learn a path-prefix vocabulary (tracked in dokku/openresty-docker-proxy#137 and the haproxy sidecar). Closes #8725.
2026-11-04 14:56:38 -05:00

94 lines
3.8 KiB
YAML

{{- range $processName, $config := .Values.processes }}
{{- if not (hasKey $config "web") }}
# Skip {{ $processName }} as it doesn't have a web section
{{- continue }}
{{- end }}
{{- 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 }}
{{- range $rdx, $entryPoint := list "web" "websecure" }}
{{- if and (eq $entryPoint "websecure") (not $config.web.tls.enabled) }}
{{- 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 }}{{- if eq $entryPoint "websecure" }}-{{ $entryPoint }}{{- end }}
namespace: {{ $.Values.global.namespace }}
spec:
entryPoints:
- {{ $entryPoint }}
routes:
{{- range $ddx, $domain := $config.web.domains }}
{{- range $rdx, $route := $.Values.global.network.routes }}
- kind: Rule
match: Host(`{{ $domain.name }}`) && PathPrefix(`{{ $route.path }}`)
priority: {{ len $route.path }}
middlewares:
- name: {{ $.Values.global.app_name}}-{{ $processName }}-compression
namespace: {{ $.Values.global.namespace }}
{{- if and (eq $entryPoint "web") $config.web.tls.enabled }}
- name: {{ $.Values.global.app_name}}-{{ $processName }}-redirect-to-https
namespace: {{ $.Values.global.namespace }}
{{- end }}
{{- if $route.strip_prefix }}
- name: {{ $.Values.global.app_name }}-{{ $route.process }}-{{ $route.slug }}-strip
namespace: {{ $.Values.global.namespace }}
{{- end }}
services:
- name: {{ $.Values.global.app_name }}-{{ $route.process }}
namespace: {{ $.Values.global.namespace }}
passHostHeader: true
port: {{ $route.port }}
scheme: http
{{- end }}
- kind: Rule
match: {{ include "traefik.host.match" $domain.name }}
{{- if hasPrefix "*." $domain.name }}
priority: 1
{{- end }}
middlewares:
- name: {{ $.Values.global.app_name}}-{{ $processName }}-compression
namespace: {{ $.Values.global.namespace }}
{{- if and (eq $entryPoint "web") $config.web.tls.enabled }}
- 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 eq $entryPoint "websecure" }}
tls:
{{- if $config.web.tls.use_imported_cert }}
secretName: tls-{{ $.Values.global.app_name }}
{{- else }}
secretName: tls-{{ $.Values.global.app_name }}-{{ $processName }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}