31 lines
862 B
YAML
31 lines
862 B
YAML
|
{{- range $index, $middlewareData := .Values.middlewares.basicAuth -}}
|
||
|
|
||
|
{{- $users := list -}}
|
||
|
{{- range $index, $userdata := $middlewareData.users -}}
|
||
|
{{- $users = append $users (htpasswd $userdata.username $userdata.password) -}}
|
||
|
{{- end }}
|
||
|
|
||
|
---
|
||
|
apiVersion: v1
|
||
|
kind: Secret
|
||
|
metadata:
|
||
|
name: {{ printf "%v-%v" $middlewareData.name "secret" }}
|
||
|
namespace: {{ $.Release.Namespace }}
|
||
|
type: Opaque
|
||
|
stringData:
|
||
|
users: |
|
||
|
{{- range $index, $user := $users }}
|
||
|
{{ printf "%s" $user }}
|
||
|
{{- end }}
|
||
|
---
|
||
|
# Declaring the user list
|
||
|
apiVersion: traefik.io/v1alpha1
|
||
|
kind: Middleware
|
||
|
metadata:
|
||
|
name: {{ ternary (printf "%v-%v" $.Release.Name $middlewareData.name) $middlewareData.name $.Values.ingressClass.enabled }}
|
||
|
namespace: {{ $.Release.Namespace }}
|
||
|
spec:
|
||
|
basicAuth:
|
||
|
secret: {{ printf "%v-%v" $middlewareData.name "secret" }}
|
||
|
{{- end -}}
|