apiVersion: apps/v1
kind: Deployment
metadata:
  name: ${AKS_DEPLOYMENT_NAME}
  namespace: ${AKS_NAMESPACE}
  labels:
    app: ${AKS_NAMESPACE}
spec:
  replicas: 3
  selector:
    matchLabels:
      app: ${AKS_NAMESPACE}
  template:
    metadata:
      labels:
        app: ${AKS_NAMESPACE}
    spec:
      serviceAccountName: "${AKS_SERVICE_ACCOUNT}"
      containers:
        - name: ${AKS_NAMESPACE}
          image: ateso.azurecr.io/edcenter-single:latest
          ports:
            - containerPort: 80
          volumeMounts:
            - name: secrets-store01-inline
              mountPath: "/mnt/secrets-store"
              readOnly: true
          env:
            - name: EDC_MYSQL_HOST
              valueFrom:
                secretKeyRef:
                  name: edcenter-secret
                  key: EDCMYSQLHOST
            - name: EDC_MYSQL_DB
              value: "edc_production"
            - name: EDC_MYSQL_USER
              valueFrom:
                secretKeyRef:
                  name: edcenter-secret
                  key: EDCMYSQLUSER
            - name: EDC_MYSQL_PW
              valueFrom:
                secretKeyRef:
                  name: edcenter-secret
                  key: EDCMYSQLPASS
            - name: EDC_SMTP_HOST
              valueFrom:
                secretKeyRef:
                  name: edcenter-secret
                  key: EDCSMTPHOST
            - name: EDC_SMTP_PORT
              valueFrom:
                secretKeyRef:
                  name: edcenter-secret
                  key: EDCSMTPPORT
            - name: EDC_SMTP_USER
              valueFrom:
                secretKeyRef:
                  name: edcenter-secret
                  key: EDCSMTPUSER
            - name: EDC_SMTP_PASS
              valueFrom:
                secretKeyRef:
                  name: edcenter-secret
                  key: EDCSMTPPASS
            - name: EDC_SMTP_FROM_EMAIL
              valueFrom:
                secretKeyRef:
                  name: edcenter-secret
                  key: EDCSMTPFROMEMAIL
            - name: EDC_SMTP_FROM_NAME
              valueFrom:
                secretKeyRef:
                  name: edcenter-secret
                  key: EDCSMTPFROMNAME
            - name: EDC_ENTRA_CLIENTID
              value: "3b6a5214-c98e-46b6-bf37-10261473406d"
            - name: EDC_ENTRA_AUTHORITY
              value: "https://login.microsoftonline.com/cb7fcac2-c96c-45ef-b2b3-281a15c71205"
            - name: EDC_ENTRA_REDIRECTURI
              value: "http://52.230.147.82"
            - name: EDC_ENTRA_BASECOMID
              value: "20"
      volumes:
        - name: secrets-store01-inline
          csi:
            driver: secrets-store.csi.k8s.io
            readOnly: true
            volumeAttributes:
              secretProviderClass: ${AKS_SERVICE_PROVIDER}