apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: parliamentary-questions-sidekiq
  name: parliamentary-questions-sidekiq
spec:
  replicas: 2
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 1
  selector:
    matchLabels:
      app: parliamentary-questions-sidekiq
  template:
    metadata:
      labels:
        app: parliamentary-questions-sidekiq
    spec:
      containers:
        - name: parliamentary-questions-rails-jobs
          command: ["./docker/entrypoint-background-jobs.sh"]
          env:
            - name: DB_HOST
              valueFrom:
                secretKeyRef:
                  key: rds_instance_address
                  name: parliamentary-questions-staging-rds
            - name: PGPASSWORD
              valueFrom:
                secretKeyRef:
                  key: database_password
                  name: parliamentary-questions-staging-rds
            - name: PGUSER
              valueFrom:
                secretKeyRef:
                  key: database_username
                  name: parliamentary-questions-staging-rds
            - name: REDIS_URL
              valueFrom:
                secretKeyRef:
                  name: parliamentary-questions-elasticache-redis-output
                  key: url
            - name: REDIS_AUTH_TOKEN
              valueFrom:
                secretKeyRef:
                  name: parliamentary-questions-elasticache-redis-output
                  key: auth_token
          envFrom:
            - configMapRef:
                name: environment-variables
            - secretRef:
                name: pq-secrets
          readinessProbe:
            exec:
              command:
                - /bin/sh
                - -c
                - 'sidekiqmon | grep "parliamentary-questions"'
            initialDelaySeconds: 40
            periodSeconds: 60
          livenessProbe:
            exec:
              command:
                - /bin/sh
                - -c
                - 'sidekiqmon | grep "parliamentary-questions"'
            initialDelaySeconds: 40
            periodSeconds: 60
