
apiVersion: 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, -i, -c, "waiverdb wait-for-db && waiverdb db upgrade" ]
          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
{% if env == 'staging' %}
        - 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
{% else %}
        - name: fedmsg-key-volume
          mountPath: /etc/pki/fedmsg/key
          readOnly: true
        - name: fedmsg-crt-volume
          mountPath: /etc/pki/fedmsg/crt
          readOnly: true
        - name: fedmsg-config-volume
          mountPath: /etc/fedmsg-waiverdb.d
          readOnly: true
{% endif %}
        env:
        - 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
{% if env == 'staging' %}
      - name: fedora-messaging-certs-volume
        configMap:
          name: fedora-messaging-configmap
      - name: fedora-messaging-ca-volume
        secret:
          secretName: waiverdb-fedora-messaging-ca
      - name: fedora-messaging-cert-volume
        secret:
          secretName: waiverdb-fedora-messaging-crt
      - name: fedora-messaging-key-volume
        secret:
          secretName: waiverdb-fedora-messaging-key
{% else %}
      - name: fedmsg-config-volume
        configMap:
          name: waiverdb-fedmsg-configmap
      - name: fedmsg-key-volume
        secret:
          secretName: waiverdb-fedmsg-key
      - name: fedmsg-crt-volume
        secret:
          secretName: waiverdb-fedmsg-crt
{% endif %}
  triggers:
  - type: ImageChange
    imageChangeParams:
      automatic: true
      containerNames:
      - web
      from:
        kind: ImageStreamTag
        name: waiverdb:latest
  - type: ConfigChange
