apiVersion: apps/v1
kind: Deployment
metadata:
  name: laa-court-data-ui-worker
  namespace: laa-court-data-ui-uat
spec:
  replicas: 2
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 100%
  selector:
    matchLabels:
      app: laa-court-data-ui
      tier: worker
  template:
    metadata:
      labels:
        app: laa-court-data-ui
        tier: worker
    spec:
      containers:
        - name: laa-court-data-ui-worker
          imagePullPolicy: Always
          image: 754256621582.dkr.ecr.eu-west-2.amazonaws.com/laa-get-paid/laa-court-data-ui:set-me
          command: ['bundle', 'exec', 'sidekiq']
          readinessProbe:
            exec:
              command: ['bundle', 'exec', 'rake', 'worker:healthcheck']
            initialDelaySeconds: 15
            periodSeconds: 10
          livenessProbe:
            exec:
              command: ['bundle', 'exec', 'rake', 'worker:healthcheck']
            initialDelaySeconds: 30
            periodSeconds: 30
          env:
            - name: ENV
              value: 'uat'
            - name: RACK_ENV
              value: 'production'
            - name: RAILS_ENV
              value: 'production'
            - name: DOMAIN_URL
              value: 'https://uat.view-court-data.service.justice.gov.uk'
            - name: COURT_DATA_ADAPTOR_API_URL
              value: https://laa-court-data-adaptor-uat.apps.live-1.cloud-platform.service.justice.gov.uk/api/internal/v1
            - name: RAILS_SERVE_STATIC_FILES
              value: enabled
            - name: RAILS_LOG_TO_STDOUT
              value: enabled
            - name: COURT_DATA_ADAPTOR_API_UID
              valueFrom:
                secretKeyRef:
                  name: lcdui-secrets
                  key: COURT_DATA_ADAPTOR_API_UID
            - name: COURT_DATA_ADAPTOR_API_SECRET
              valueFrom:
                secretKeyRef:
                  name: lcdui-secrets
                  key: COURT_DATA_ADAPTOR_API_SECRET
            - name: SECRET_KEY_BASE
              valueFrom:
                secretKeyRef:
                  name: lcdui-secrets
                  key: SECRET_KEY_BASE
            - name: DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: lcdui-rds
                  key: url
            - name: REDIS_URL
              valueFrom:
                secretKeyRef:
                  name: lcdui-elasticache
                  key: url
            - name: GOVUK_NOTIFY_API_KEY
              valueFrom:
                secretKeyRef:
                  name: lcdui-secrets
                  key: GOVUK_NOTIFY_API_KEY
            - name: SENTRY_DSN
              valueFrom:
                secretKeyRef:
                  name: lcdui-secrets
                  key: SENTRY_DSN
        - name: laa-court-data-ui-metrics
          image: 754256621582.dkr.ecr.eu-west-2.amazonaws.com/laa-get-paid/laa-court-data-ui:set-me
          imagePullPolicy: Always
          command: ['sh', '-c', "bundle exec prometheus_exporter --bind 0.0.0.0"]
          ports:
          - containerPort: 9394
          livenessProbe:
            httpGet:
              path: /metrics
              port: 9394
            initialDelaySeconds: 10
            periodSeconds: 60
          readinessProbe:
            httpGet:
              path: /metrics
              port: 9394
            initialDelaySeconds: 10
            periodSeconds: 60
