35 lines
997 B
YAML
35 lines
997 B
YAML
|
{{- $values := .Values }}
|
||
|
{{- $namespace := ( printf "ix-%s" .Release.Name ) }}
|
||
|
{{- if or ( not .Values.ingressClass.enabled ) ( and ( .Values.ingressClass.enabled ) ( .Values.ingressClass.isDefaultClass ) ) }}
|
||
|
{{- $namespace = "default" }}
|
||
|
{{- end }}
|
||
|
{{ 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: {{ $namespace }}
|
||
|
type: Opaque
|
||
|
stringData:
|
||
|
users: |
|
||
|
{{- range $index, $user := $users }}
|
||
|
{{ printf "%s" $user }}
|
||
|
{{- end }}
|
||
|
---
|
||
|
# Declaring the user list
|
||
|
apiVersion: traefik.containo.us/v1alpha1
|
||
|
kind: Middleware
|
||
|
metadata:
|
||
|
name: {{ $middlewareData.name }}
|
||
|
namespace: {{ $namespace }}
|
||
|
spec:
|
||
|
basicAuth:
|
||
|
secret: {{printf "%v-%v" $middlewareData.name "secret" }}
|
||
|
{{ end }}
|