apiVersion: apps/v1
kind: Deployment
metadata:
  name: webhooks
  namespace: oih-dev-ns
  labels:
    app: webhooks
spec:
  replicas: 1
  selector:
    matchLabels:
      app: webhooks
  template:
    metadata:
      name: webhooks
      labels:
        app: webhooks
    spec:
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      serviceAccountName: component-orchestrator-account
      containers:
        - name: webhooks
          image: node:16-alpine
          command: ["/bin/sh"]
          args: ["-c", "npm run start:container -w services/webhooks"]
          #npm ci --verbose --non-interactive -w services/webhooks &&
          workingDir: /usr/src/app/
          env:
            - name: IAM_TOKEN
              valueFrom:
                secretKeyRef:
                  name: shared-secret
                  key: iamtoken
            - name: MONGODB_URI
              valueFrom:
                secretKeyRef:
                  name: shared-secret
                  key: webhooksMongourl
            - 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: RABBITMQ_URI
              value: >-
                amqp://guest:guest@rabbitmq-service.oih-dev-ns.svc.cluster.local
            - name: LISTEN_PORT
              value: "1234"
            - name: IAM_BASE_URL
              value: "http://iam.oih-dev-ns.svc.cluster.local:3099"
            - name: SECRET_SERVICE_URL
              value: "http://skm.example.com"
            - name: LOG_LEVEL
              value: trace
            - name: NODE_ENV
              value: development
          resources:
            limits:
              cpu: "0.1"
              memory: 1000Mi
          volumeMounts:
            - name: code
              mountPath: /usr/src/app
              #subPath: services/webhooks
          livenessProbe:
            httpGet:
              port: 1234
              path: /healthcheck
          readinessProbe:
            httpGet:
              port: 1234
              path: /healthcheck
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: false
      volumes:
        - name: code
          persistentVolumeClaim:
            claimName: source-volume-claim
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
