apiVersion: apps/v1
kind: Deployment
metadata:
  name: authelia
spec:
  replicas: {{ .Values.replicaCount }}
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: authelia
  template:
    metadata:
      labels:
        app: authelia
    spec:
      enableServiceLinks: false
      containers:
        - name: authelia
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - name: http
              containerPort: 9091
          env:
            - name: AUTHELIA_IDENTITY_VALIDATION_RESET_PASSWORD_JWT_SECRET
              valueFrom:
                secretKeyRef:
                  name: authelia-secrets
                  key: jwt_secret
            - name: AUTHELIA_SESSION_SECRET
              valueFrom:
                secretKeyRef:
                  name: authelia-secrets
                  key: session_secret
            - name: AUTHELIA_STORAGE_ENCRYPTION_KEY
              valueFrom:
                secretKeyRef:
                  name: authelia-secrets
                  key: storage_encryption_key
            - name: AUTHELIA_NOTIFIER_SMTP_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: authelia-secrets
                  key: smtp_password
          volumeMounts:
            - name: config
              mountPath: /config
            - name: data
              mountPath: /var/lib/authelia
          livenessProbe:
            httpGet:
              path: /api/health
              port: http
          readinessProbe:
            httpGet:
              path: /api/health
              port: http
      volumes:
        - name: config
          projected:
            sources:
              - configMap:
                  name: authelia-config
              - secret:
                  name: authelia-secrets
                  items:
                    - key: users_database.yml
                      path: users_database.yml
        - name: data
          persistentVolumeClaim:
            claimName: authelia-data
