Update templates/traefik.yaml

This commit is contained in:
ties 2024-08-29 09:35:33 +00:00
parent 462ae64b0f
commit 489e31d7f0

View File

@ -15,7 +15,14 @@ spec:
- name: {{ .Values.expose.service.name }}
port: {{ .Values.expose.service.port }}
namespace: {{ .Values.namespace }}
{{ if has "authentik" .Values.expose.middlewares }}
{{- $authentikMiddleware := false }}
{{- range .Values.expose.middlewares }}
{{- if eq .name "authentik" }}
{{- $authentikMiddleware = true }}
{{- end }}
{{- end }}
{{- if $authentikMiddleware }}
---
apiVersion: traefik.io/v1alpha1
kind: Middleware
@ -26,7 +33,7 @@ spec:
forwardAuth:
{{- $regexArray := mustRegexFindAll "Host[(]`[^`]+`[)]" .Values.expose.match -1 }}
{{- $firstHost := index $regexArray 0 }}
{{- $hostname := regexReplaceAll ".+`([^`]+)`.+" $firstHost "$1"}}
{{- $hostname := regexReplaceAll ".+`([^`]+)`.?" $firstHost "$1"}}
address: https://{{ $hostname }}/outpost.goauthentik.io/auth/traefik
authResponseHeaders:
- X-authentik-username
@ -41,4 +48,4 @@ spec:
- X-authentik-meta-app
- X-authentik-meta-version
trustForwardHeader: true
{{ end }}
{{- end }}