apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: parliamentary-questions
  name: parliamentary-questions
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 1
  selector:
    matchLabels:
      app: parliamentary-questions
  template:
    metadata:
      labels:
        app: parliamentary-questions
    spec:
      containers:
        - command:
            - sh
            - "-c"
            - "bundle exec puma -p 3000"
          env:
            - name: CREATE_USER_FROM_TEST
              valueFrom:
                secretKeyRef:
                  key: CREATE_USER_FROM_TEST
                  name: pq-secrets
            - name: DB_HOST
              valueFrom:
                secretKeyRef:
                  key: rds_instance_address
                  name: parliamentary-questions-development-rds
            - name: DEVISE_SECRET
              valueFrom:
                secretKeyRef:
                  key: DEVISE_SECRET
                  name: pq-secrets
            - name: DEVISE_SENDER
              valueFrom:
                secretKeyRef:
                  key: DEVISE_SENDER
                  name: pq-secrets
            - name: GOVUK_NOTIFY_API_KEY
              valueFrom:
                secretKeyRef:
                  key: GOVUK_NOTIFY_API_KEY
                  name: pq-secrets
            - name: PGPASSWORD
              valueFrom:
                secretKeyRef:
                  key: database_password
                  name: parliamentary-questions-development-rds
            - name: PGUSER
              valueFrom:
                secretKeyRef:
                  key: database_username
                  name: parliamentary-questions-development-rds
            - name: PQ_REST_API_HOST
              valueFrom:
                secretKeyRef:
                  key: PQ_REST_API_HOST
                  name: pq-secrets
            - name: PQ_REST_API_PASSWORD
              valueFrom:
                secretKeyRef:
                  key: PQ_REST_API_PASSWORD
                  name: pq-secrets
            - name: PQ_REST_API_URL
              valueFrom:
                secretKeyRef:
                  key: PQ_REST_API_URL
                  name: pq-secrets
            - name: PQ_REST_API_USERNAME
              valueFrom:
                secretKeyRef:
                  key: PQ_REST_API_USERNAME
                  name: pq-secrets
            - name: TEST_USER
              valueFrom:
                secretKeyRef:
                  key: TEST_USER
                  name: pq-secrets
            - name: TEST_USER_PASS
              valueFrom:
                secretKeyRef:
                  key: TEST_USER_PASS
                  name: pq-secrets
          envFrom:
            - configMapRef:
                name: environment-variables
            - secretRef:
                name: pq-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
          imagePullPolicy: Always
          name: parliamentary-questions-rails-app
          ports:
            - containerPort: 3000
