apiVersion: apps/v1
kind: Deployment
metadata:
  name: iam
  namespace: oih-dev-ns
spec:
  replicas: 1
  selector:
    matchLabels:
      app: iam
  minReadySeconds: 10
  revisionHistoryLimit: 2
  template:
    metadata:
      labels:
        app: iam
    spec:
      containers:
        - name: iam
          imagePullPolicy: IfNotPresent
          image: node:12-alpine #openintegrationhub/iam:latest #
          workingDir: /usr/src/app/
          command: ["/bin/sh"]
          args: ["-c","yarn install --non-interactive && yarn start:container"]
          env:
            - name: LOG_LEVEL
              value: error
            - name: RABBITMQ_URI
              value: amqp://guest:guest@rabbitmq-service.oih-dev-ns.svc.cluster.local
            - name: IAM_MONGODB_CONNECTION
              valueFrom:
                secretKeyRef:
                  name: iam
                  key: mongourl
            - name: IAM_AUTH_TYPE
              value: basic
            - name: IAM_PORT
              value: "3099"
            - name: IAM_BASEURL
              value: "http://iam.oih-dev-ns.svc.cluster.local:3099"
            - name: IAM_ORIGINWHITELIST
              value: "http://localhost:3000,localoih.com,127.0.0.1,.oih-dev-ns.svc.cluster.local"
            - name: NODE_ENV
              value: development
            - name: IAM_JWT_SECRET
              valueFrom:
                secretKeyRef:
                  name: iam
                  key: jwtsecret
            - name: IAM_SESSION_COOKIE_SECRET
              valueFrom:
                secretKeyRef:
                  name: iam
                  key: cookiesecret
            - name: IAM_JWT_AUDIENCE
              value: openintegrationhub.com
            - name: IAM_JWT_COOKIENAME
              value: oih-iam
            - name: IAM_ACC_ADMIN_USERNAME
              value: admin@openintegrationhub.com
            - name: IAM_ACC_ADMIN_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: iam
                  key: admin_password
            - name: IAM_ACC_SERVICE_ACCOUNT_USERNAME
              value: service-oih-iam@openintegrationhub.com
            - name: IAM_ACC_SERVICE_ACCOUNT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: iam
                  key: serviceacc_password
            - name: IAM_SERVICE_CLIENT_ID
              value: 8ce00058-5f75-435f-9026-ad952480e15a
            - name: IAM_SERVICE_CLIENT_SECRET
              valueFrom:
                secretKeyRef:
                  name: iam
                  key: oidc_client_secret
          volumeMounts:
            - name: code
              mountPath: /usr/src/app
              subPath: services/iam
              #readOnly: true
          ports:
            - containerPort: 3099
          livenessProbe:
            httpGet:
              path: /healthcheck
              port: 3099
            initialDelaySeconds: 300
            timeoutSeconds: 1
          readinessProbe:
            httpGet:
              path: /healthcheck
              port: 3099
            initialDelaySeconds: 120
            timeoutSeconds: 1
      volumes:
        - name: code
          persistentVolumeClaim:
            claimName: source-volume-claim
