---
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
  name: waiverdb-web
  labels:
    app: waiverdb
    service: web
spec:
  replicas: 2
  selector:
    app: waiverdb
    service: web
  strategy:
    type: Rolling
    rollingParams:
      pre:
        failurePolicy: Abort
        execNewPod:
          containerName: web
          command:
            - /bin/sh
            - -c
            - >-
              if [ -f /app/entrypoint.sh ];
              then /app/entrypoint.sh waiverdb db upgrade;
              else waiverdb db upgrade;
              fi
          volumes:
          - config-volume
          - secret-volume
  template:
    metadata:
      labels:
        app: waiverdb
        service: web
    spec:
      containers:
      - name: web
        image: waiverdb
        ports:
        - containerPort: 8080
        volumeMounts:
        - name: config-volume
          mountPath: /etc/waiverdb
          readOnly: true
        - name: secret-volume
          mountPath: /etc/secret
          readOnly: true
        - name: fedora-messaging-ca-volume
          mountPath: /etc/pki/rabbitmq/ca
          readOnly: true
        - name: fedora-messaging-key-volume
          mountPath: /etc/pki/rabbitmq/key
          readOnly: true
        - name: fedora-messaging-crt-volume
          mountPath: /etc/pki/rabbitmq/crt
          readOnly: true
        - name: fedora-messaging-config-volume
          mountPath: /etc/fedora-messaging
          readOnly: true
        env:
        - name: GUNICORN_CMD_ARGS
          value: >-
            --workers=3
            --threads=6
            --timeout=90
        - name: DATABASE_PASSWORD
          valueFrom:
            secretKeyRef:
              name: waiverdb-secret
              key: database-password
        - name: SECRET_KEY
          valueFrom:
            secretKeyRef:
              name: waiverdb-secret
              key: flask-secret-key
        readinessProbe:
          timeoutSeconds: 1
          initialDelaySeconds: 5
          httpGet:
            path: /healthcheck
            port: 8080
        livenessProbe:
          timeoutSeconds: 1
          initialDelaySeconds: 30
          httpGet:
            path: /healthcheck
            port: 8080
        resources:
          limits:
            memory: 384Mi
      volumes:
      - name: config-volume
        configMap:
          name: waiverdb-configmap
      - name: secret-volume
        secret:
          secretName: waiverdb-secret
      - name: fedora-messaging-config-volume
        configMap:
          name: fedora-messaging-configmap
      - name: fedora-messaging-ca-volume
        secret:
          secretName: waiverdb-fedora-messaging-ca
      - name: fedora-messaging-crt-volume
        secret:
          secretName: waiverdb-fedora-messaging-crt
      - name: fedora-messaging-key-volume
        secret:
          secretName: waiverdb-fedora-messaging-key
  triggers:
  - type: ImageChange
    imageChangeParams:
      automatic: true
      containerNames:
      - web
      from:
        kind: ImageStreamTag
        name: waiverdb:latest
  - type: ConfigChange
