apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: climate-watch
  labels:
    name: climate-watch-indonesia-platform
  name: climate-watch-indonesia-platform
spec:
  progressDeadlineSeconds: 2147483647
  replicas: 1
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      name: climate-watch-indonesia-platform
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        name: climate-watch-indonesia-platform
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: type
                    operator: In
                    values:
                      - webapps
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - podAffinityTerm:
                labelSelector:
                  matchExpressions:
                    - key: name
                      operator: In
                      values:
                        - climate-watch-indonesia-platform
                topologyKey: kubernetes.io/hostname
              weight: 100
      containers:
        - env:
            - name: CW_FILES_PREFIX
              value: climatewatch.org/www.climatewatch.org/indonesia/
            - name: RACK_ENV
              value: production
            - name: RAILS_ENV
              value: production
            - name: PORT
              value: "3000"
            - name: RAILS_SERVE_STATIC_FILES
              value: "true"
            - name: PASSWORD_PROTECT
              value: "false"
            - name: RAILS_LOG_TO_STDOUT
              value: "true"
            - name: HTTP_AUTH_USERNAME
              valueFrom:
                secretKeyRef:
                  key: CW_AUTH_USERNAME
                  name: appsecrets
            - name: HTTP_AUTH_PASSWORD
              valueFrom:
                secretKeyRef:
                  key: CW_AUTH_PASSWORD
                  name: appsecrets
            - name: POSTGRES_URL
              valueFrom:
                secretKeyRef:
                  key: CW_INDONESIA_POSTGRES_URL
                  name: dbsecrets
            - name: SHARED_POSTGRES_URL
              valueFrom:
                secretKeyRef:
                  key: climate_watch_shared_db_production
                  name: dbsecrets
            - name: S3_BUCKET_NAME
              value: wri-sites
            - name: AWS_REGION
              value: eu-west-1
            - name: AWS_ACCESS_KEY_ID
              valueFrom:
                secretKeyRef:
                  key: CW_PLATFORMS_S3_ACCESS_KEY
                  name: appsecrets
            - name: AWS_SECRET_ACCESS_KEY
              valueFrom:
                secretKeyRef:
                  key: CW_PLATFORMS_S3_SECRET_ACCESS_KEY
                  name: appsecrets
          image: vizzuality/climate-watch-indonesia-platform
          imagePullPolicy: Always
          name: climate-watch-indonesia-platform
          ports:
            - containerPort: 3000
              protocol: TCP
          resources:
            requests:
              memory: 128Mi
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      imagePullSecrets:
        - name: regcred
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: { }
      terminationGracePeriodSeconds: 30
