apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    name: resource-watch-manager
  name: resource-watch-manager
  namespace: rw
spec:
  minReadySeconds: 30
  progressDeadlineSeconds: 2147483647
  revisionHistoryLimit: 0
  selector:
    matchLabels:
      name: resource-watch-manager
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        name: resource-watch-manager
      namespace: rw
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: type
                    operator: In
                    values:
                      - apps
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - podAffinityTerm:
                labelSelector:
                  matchExpressions:
                    - key: name
                      operator: In
                      values:
                        - resource-watch-manager
                topologyKey: kubernetes.io/hostname
              weight: 100
      containers:
        - args:
            - start
          env:
            - name: CONTACT_EMAIL
              value: tiago.garcia@vizzuality.com
            - name: SENDGRID_DOMAIN
              value: vizzuality.com
            - name: SENDGRID_API_KEY
              valueFrom:
                secretKeyRef:
                  key: RW_SENDGRID_API_KEY
                  name: appsecrets
            - name: SENDGRID_USERNAME
              valueFrom:
                secretKeyRef:
                  key: RW_SENDGRID_USERNAME
                  name: appsecrets
            - name: SENDGRID_PASSWORD
              valueFrom:
                secretKeyRef:
                  key: RW_SENDGRID_PASSWORD
                  name: appsecrets
            - name: RAILS_LOG_TO_STDOUT
              value: "true"
            - name: APIGATEWAY_URL
              value: https://staging-api.globalforestwatch.org
            - name: RW_API_URL
              value: https://staging-api.globalforestwatch.org
            - name: RAILS_SERVE_STATIC_FILES
              value: "true"
            - name: DATABASE_URL
              valueFrom:
                secretKeyRef:
                  key: RESOURCE_WATCH_MANAGER_POSTGRESDB
                  name: dbsecrets
            - name: S3_BUCKET_NAME
              value: wri-api-backups
            - name: S3_PATH
              value: resourcewatch/test
            - name: AWS_REGION
              value: us-east-1
            - name: AWS_ACCESS_KEY_ID
              valueFrom:
                secretKeyRef:
                  key: S3_ACCESS_KEY_ID
                  name: mssecrets
            - name: AWS_SECRET_ACCESS_KEY
              valueFrom:
                secretKeyRef:
                  key: S3_SECRET_ACCESS_KEY
                  name: mssecrets
            - name: CT_URL
              valueFrom:
                secretKeyRef:
                  key: CT_URL
                  name: mssecrets
            - name: CT_TOKEN
              valueFrom:
                secretKeyRef:
                  key: CT_TOKEN
                  name: mssecrets
            - name: LOCAL_URL
              value: http://resource-watch-manager.rw.svc.cluster.local:3000
            - name: RAILS_ENV
              value: production
          image: gfwdockerhub/resource-watch-manager
          imagePullPolicy: Always
          livenessProbe:
            failureThreshold: 3
            httpGet:
              path: /health
              port: 3000
              scheme: HTTP
            initialDelaySeconds: 30
            periodSeconds: 15
            successThreshold: 1
            timeoutSeconds: 5
          name: resource-watch-manager
          ports:
            - containerPort: 3000
              protocol: TCP
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /health
              port: 3000
              scheme: HTTP
            initialDelaySeconds: 30
            periodSeconds: 15
            successThreshold: 1
            timeoutSeconds: 5
          resources:
            limits:
              cpu: "1"
              memory: 512Mi
            requests:
              cpu: 250m
              memory: 128Mi
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      imagePullSecrets:
        - name: regcred
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status: {}
