feat: Add traefik-forward-auth Helm chart with deployment, service, ingress, middleware, and configuration templates

This commit is contained in:
sha
2026-04-19 13:21:22 +03:00
parent 26408964a0
commit 9d057b2f3e
8 changed files with 238 additions and 0 deletions
@@ -0,0 +1,13 @@
{{- define "tfa.middlewareName" -}}
{{- if .Values.middleware.name -}}
{{ .Values.middleware.name }}
{{- else -}}
{{ .Release.Name }}-auth
{{- end -}}
{{- end -}}
{{- define "tfa.labels" -}}
app.kubernetes.io/name: {{ .Chart.Name }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end -}}
@@ -0,0 +1,27 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-config
labels:
{{- include "tfa.labels" . | nindent 4 }}
data:
config.yaml: |
server:
hostname: {{ .Values.hostname | quote }}
tokens:
sessionLifetime: {{ .Values.tokens.sessionLifetime }}
cookies:
domain: {{ .Values.cookieDomain | quote }}
portals:
- name: {{ .Values.portal.name | quote }}
providers:
- pocketID:
endpoint: {{ .Values.pocketID.endpoint | quote }}
clientID: {{ .Values.pocketID.clientID | quote }}
clientSecretFile: "/var/run/secrets/traefik-forward-auth/client-secret"
{{- with .Values.extraConfig }}
{{ . | nindent 4 }}
{{- end }}
@@ -0,0 +1,60 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}
labels:
{{- include "tfa.labels" . | nindent 4 }}
annotations:
version-source: {{ index .Chart.Annotations "version-source" }}
version-pattern: {{ index .Chart.Annotations "version-pattern" | quote }}
spec:
replicas: 1
selector:
matchLabels:
app: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ .Release.Name }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
spec:
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 4181
protocol: TCP
volumeMounts:
- name: config
mountPath: /etc/traefik-forward-auth
readOnly: true
- name: client-secret
mountPath: /var/run/secrets/traefik-forward-auth
readOnly: true
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: config
configMap:
name: {{ .Release.Name }}-config
- name: client-secret
secret:
secretName: {{ required "existingSecret is required" .Values.existingSecret }}
items:
- key: client-secret
path: client-secret
@@ -0,0 +1,29 @@
{{- range $name, $config := .Values.ingresses }}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $.Release.Name }}-{{ $name }}
labels:
{{- include "tfa.labels" $ | nindent 4 }}
{{- with $config.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
rules:
- host: {{ $config.host }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ $.Release.Name }}
port:
number: {{ $.Values.service.port }}
{{- with $config.tls }}
tls:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
@@ -0,0 +1,16 @@
{{- if .Values.middleware.enabled }}
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: {{ include "tfa.middlewareName" . }}
labels:
{{- include "tfa.labels" . | nindent 4 }}
spec:
forwardAuth:
address: "http://{{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local/portals/{{ .Values.portal.name }}"
trustForwardHeader: {{ .Values.middleware.trustForwardHeader }}
{{- with .Values.middleware.authResponseHeaders }}
authResponseHeaders:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end }}
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}
labels:
{{- include "tfa.labels" . | nindent 4 }}
spec:
type: ClusterIP
selector:
app: {{ .Release.Name }}
ports:
- name: http
port: {{ .Values.service.port }}
targetPort: http
protocol: TCP