apiVersion: apps/v1
kind: Deployment
metadata:
  name: track-a-query
spec:
  replicas: 4
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 1
  selector:
    matchLabels:
      app: track-a-query
  template:
    metadata:
      labels:
        app: track-a-query
    spec:
      containers:
        - name: webapp
          image: 754256621582.dkr.ecr.eu-west-2.amazonaws.com/correspondence/track-a-query-ecr:latest
          ports:
          - containerPort: 3000
          command: ["./config/docker/entrypoint-webapp.sh"]
          env:
            - name: DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: track-a-query-rds-output
                  key: url
            - name: CORRESPONDENCE_PLATFORM_DATABASE_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: track-a-query-rds-output
                  key: database_password
            - name: REDIS_URL
              valueFrom:
                secretKeyRef:
                  name: track-a-query-elasticache-redis-output
                  key: url
            - name: REDIS_AUTH_TOKEN
              valueFrom:
                secretKeyRef:
                  name: track-a-query-elasticache-redis-output
                  key: auth_token
            - name: SETTINGS__CASE_UPLOADS_S3_BUCKET
              valueFrom:
                secretKeyRef:
                  name: track-a-query-s3-output
                  key: bucket_name
            - name: AWS_ACCESS_KEY_ID
              valueFrom:
                secretKeyRef:
                  name: track-a-query-s3-output
                  key: access_key_id
            - name: AWS_SECRET_ACCESS_KEY
              valueFrom:
                secretKeyRef:
                  name: track-a-query-s3-output
                  key: secret_access_key
          envFrom:
            - configMapRef:
                name: environment-variables
            - secretRef:
                name: app-secrets
          readinessProbe:
            httpGet:
              path: /healthcheck
              port: 3000
              httpHeaders:
                - name: X-Forwarded-Proto
                  value: https
                - name: X-Forwarded-Ssl
                  value: "on"
            initialDelaySeconds: 40
            periodSeconds: 60
          livenessProbe:
            httpGet:
              path: /healthcheck
              port: 3000
              httpHeaders:
                - name: X-Forwarded-Proto
                  value: https
                - name: X-Forwarded-Ssl
                  value: "on"
            initialDelaySeconds: 40
            periodSeconds: 60
        - name: quickjobs
          image: 754256621582.dkr.ecr.eu-west-2.amazonaws.com/correspondence/track-a-query-ecr:latest
          command: ["./config/docker/entrypoint-quick-jobs.sh"]
          env:
            - name: DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: track-a-query-rds-output
                  key: url
            - name: CORRESPONDENCE_PLATFORM_DATABASE_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: track-a-query-rds-output
                  key: database_password
            - name: REDIS_URL
              valueFrom:
                secretKeyRef:
                  name: track-a-query-elasticache-redis-output
                  key: url
            - name: REDIS_AUTH_TOKEN
              valueFrom:
                secretKeyRef:
                  name: track-a-query-elasticache-redis-output
                  key: auth_token
            - name: SETTINGS__CASE_UPLOADS_S3_BUCKET
              valueFrom:
                secretKeyRef:
                  name: track-a-query-s3-output
                  key: bucket_name
            - name: AWS_ACCESS_KEY_ID
              valueFrom:
                secretKeyRef:
                  name: track-a-query-s3-output
                  key: access_key_id
            - name: AWS_SECRET_ACCESS_KEY
              valueFrom:
                secretKeyRef:
                  name: track-a-query-s3-output
                  key: secret_access_key
          envFrom:
            - configMapRef:
                name: environment-variables
            - secretRef:
                name: app-secrets
        - name: uploads
          image: 754256621582.dkr.ecr.eu-west-2.amazonaws.com/correspondence/track-a-query-ecr:latest
          command: ["./config/docker/entrypoint-uploads.sh"]
          env:
            - name: DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: track-a-query-rds-output
                  key: url
            - name: CORRESPONDENCE_PLATFORM_DATABASE_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: track-a-query-rds-output
                  key: database_password
            - name: REDIS_URL
              valueFrom:
                secretKeyRef:
                  name: track-a-query-elasticache-redis-output
                  key: url
            - name: REDIS_AUTH_TOKEN
              valueFrom:
                secretKeyRef:
                  name: track-a-query-elasticache-redis-output
                  key: auth_token
            - name: SETTINGS__CASE_UPLOADS_S3_BUCKET
              valueFrom:
                secretKeyRef:
                  name: track-a-query-s3-output
                  key: bucket_name
            - name: AWS_ACCESS_KEY_ID
              valueFrom:
                secretKeyRef:
                  name: track-a-query-s3-output
                  key: access_key_id
            - name: AWS_SECRET_ACCESS_KEY
              valueFrom:
                secretKeyRef:
                  name: track-a-query-s3-output
                  key: secret_access_key
          envFrom:
            - configMapRef:
                name: environment-variables
            - secretRef:
                name: app-secrets
