apiVersion: apps/v1
kind: Deployment
metadata:
  name: secret-service
  namespace: oih-dev-ns
spec:
  replicas: 1
  selector:
    matchLabels:
      app: secret-service
  template:
    metadata:
      labels:
        app: secret-service
    spec:
      containers:
        - name: secret-service
          image: node:16-alpine
          command: ["/bin/sh"]
          args:
            [
              "-c",
              "apk update && apk add --no-cache python && npm install --network-timeout 9000000 --verbose --non-interactive && npm start:container",
            ]
          workingDir: /usr/src/app
          ports:
            - containerPort: 3000
          env:
            - name: NODE_ENV
              value: development
            - name: CRYPTO_DISABLED
              value: "true"
            - name: IAM_TOKEN
              valueFrom:
                secretKeyRef:
                  name: shared-secret
                  key: iamtoken
            - name: MONGODB_CONNECTION
              valueFrom:
                secretKeyRef:
                  name: shared-secret
                  key: secretServiceMongourl
            - #   value: 8ce00058-5f75-435f-9026-ad952480e15a
              # - name: IAM_OIDC_SERVICE_CLIENT_SECRET
              #   valueFrom:
              #     secretKeyRef:
              #       name: secret-service
              #       key: 'client-secret'
              name: "INTROSPECT_TYPE" # - name: IAM_OIDC_SERVICE_CLIENT_ID
              value: "basic"
            - name: "INTROSPECT_ENDPOINT_BASIC"
              value: "http://iam.oih-dev-ns.svc.cluster.local:3099/api/v1/tokens/introspect"
            - name: PORT
              value: "3000"
            - name: API_BASE
              value: "/api/v1"
            - name: LOG_LEVEL
              value: "info"
            - name: TTL_AUTHFLOW
              value: "2m"
            - name: DEBUG_MODE
              value: "true"
            - name: RABBITMQ_URI
              value: "amqp://guest:guest@rabbitmq-service.oih-dev-ns.svc.cluster.local:5672"
            - name: "ORIGINWHITELIST"
              value: "example.com,http://web-ui.example.com,http://localhost:3000"
          resources:
            limits:
              cpu: "0.1"
              memory: 1000Mi
          volumeMounts:
            - name: code
              mountPath: /usr/src/app
              subPath: services/secret-service
          livenessProbe:
            httpGet:
              port: 3000
              path: /healthcheck
            initialDelaySeconds: 2400
            timeoutSeconds: 1
          readinessProbe:
            httpGet:
              port: 3000
              path: /healthcheck
            initialDelaySeconds: 2400
            timeoutSeconds: 1
          imagePullPolicy: IfNotPresent
      volumes:
        - name: code
          persistentVolumeClaim:
            claimName: source-volume-claim
  minReadySeconds: 10
  revisionHistoryLimit: 2
