apiVersion: apps/v1
kind: Deployment
metadata:
  name: pubsub-adapter
  labels:
    app: pubsub-adapter
    env: dev
spec:
  replicas: 1
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  selector:
    matchLabels:
      app: pubsub-adapter
  template:
    metadata:
      name: pubsub-adapter
      labels:
        app: pubsub-adapter
        env: dev
        version: "0.1.0dev"
    spec:
      containers:
        - name: pubsub-adapter
          image: eu.gcr.io/ssdc-rm-ci/rm/ssdc-rm-pubsub-adapter:latest
          imagePullPolicy: Always
          resources:
            requests:
              cpu: "0.4"
              memory: "64Mi"
            limits:
              cpu: "0.4"
              memory: "64Mi"
          readinessProbe:
            exec:
              command:
                - cat
                - $(READINESS_FILE_PATH)
            initialDelaySeconds: 1
            periodSeconds: 2
            failureThreshold: 10
            successThreshold: 1
          volumeMounts:
            - name: gcp-credentials-volume
              mountPath: /gcp-credentials
          env:
            - name: EQ_RECEIPT_TOPIC
              valueFrom:
                configMapKeyRef:
                  name: pubsub-config
                  key: receipt-topic-name
            - name: EQ_RECEIPT_SUBSCRIPTION
              valueFrom:
                configMapKeyRef:
                  name: pubsub-config
                  key: subscription-name
            - name: EQ_RECEIPT_PROJECT
              valueFrom:
                configMapKeyRef:
                  name: pubsub-config
                  key: subscription-project-id
            - name: GOOGLE_APPLICATION_CREDENTIALS
              value: "/gcp-credentials/service-account-key.json"
            - name: RABBIT_HOST
              value: "rm-rabbitmq"
            - name: RABBIT_PORT
              value: "5672"
            - name: RABBIT_USERNAME
              valueFrom:
                secretKeyRef:
                  name: rabbitmq
                  key: rabbitmq-username
            - name: RABBIT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: rabbitmq
                  key: rabbitmq-password
            - name: READINESS_FILE_PATH
              value: "/tmp/pubsub-adapter-ready"
            - name: LOG_LEVEL
              value: "INFO"
      volumes:
        - name: gcp-credentials-volume
          secret:
            secretName: pubsub-credentials