apiVersion: apps/v1
kind: Deployment
metadata:
  name: erabliereapi-deployment
  labels:
    app: erabliereapi
spec:
  replicas: 2
  selector:
    matchLabels:
      app: erabliereapi
  template:
    metadata:
      labels:
        app: erabliereapi
    spec:
      volumes:
      - name: email-config-secret
        secret:
          secretName: erabliereapi-email-config
      - name: erabliere-iu-oidc-config
        configMap:
          name: erabliere-iu-oidc
      - name: k8s-startup-config
        configMap:
          name: k8s-startup
          defaultMode: 0744
      containers:
      - name: erabliereapi
        image: erabliereapi/erabliereapi:v2
        imagePullPolicy: Always
        command: ["/app/k8s-startup/k8s-startup.sh"]
        ports:
        - containerPort: 80
        readinessProbe:
          tcpSocket:
            port: 80
          initialDelaySeconds: 20
          periodSeconds: 60
        livenessProbe:
          httpGet:
            path: /health
            port: 80
          initialDelaySeconds: 20
          periodSeconds: 60
        volumeMounts:
        - name: email-config-secret
          mountPath: /app/mountsecret
        - name: erabliere-iu-oidc-config
          mountPath: /app/mountconfig
        - name: k8s-startup-config
          mountPath: /app/k8s-startup
        env:
        - name: ASPNETCORE_ENVIRONMENT
          value: "Production"
        - name: USE_CORS
          value: "False"
        - name: CORS_ORIGINS
          value: "*"
        - name: CORS_HEADERS
          value: "*"
        - name: CORS_METHODS
          value: "*"
        - name: Forwarded_headers
          value: "true"
        - name: USE_SCHEMA_FROM_PROXY
          value: "true"
        - name: Forwarded_headers.Debug_headers
          value: "false"
        - name: USE_SQL
          value: "true"
        - name: SQL_CONNEXION_STRING
          value: "Data Source=erabliere-db-service;Initial Catalog=ErabliereAPI;User ID=SA;Password=<SA-PASSWORD>"
        - name: SQL_USE_STARTUP_MIGRATION
          value: "true"
        - name: DEBUG_HEADERS
          value: "false"
        - name: LOG_SQL
          value: "-"
        - name: USE_AUTHENTICATION
          value: "true"
        - name: USE_SWAGGER_AUTHORIZATIONCODE_WORKFLOW
          value: "true"
        - name: USE_SWAGGER_PKCE
          value: "true"
        - name: SWAGGER_AUTHORIZATION_URL
          value: "https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/authorize"
        - name: SWAGGER_TOKEN_URL
          value: "https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token"
        - name: OIDC_CLIENT_ID
          value: "<swagger-client-id>"
        - name: OIDC_CLIENT_PASSWORD
          value: ""
        - name: OAUTH2_REDIRECT_URL
          value: "https://<domain>/api/oauth2-redirect.html"
        - name: OIDC_AUDIENCE
          value: "api://<client-id>"
        - name: OIDC_AUTHORITY
          value: "https://login.microsoftonline.com/<tenant-id>/"
        - name: OIDC_SCOPES
          value: "api://<client-id>/ErabliereAPI"
        - name: AzureAD__ClientId
          value: "<client-id>"
        - name: AzureAD__TenantId
          value: "<tenant-id>"
        - name: EMAIL_CONFIG_PATH
          value: "/app/secret/emailConfig.json"
        