---
apiVersion: v1
kind: DeploymentConfig
metadata:
  labels:
    app: elections
    service: elections
  name: elections
spec:
  replicas: 1
  selector:
    app: elections
    deploymentconfig: elections
  strategy:
    type: Recreate
    recreateParams:
      mid:
        failurePolicy: Abort
        execNewPod:
          containerName: elections
          command: ["/opt/app-root/src/alembic_upgrade.sh"]
          env:
          - name: PYTHONPATH
            value: /opt/app-root/src
          - name: KRB5_CONFIG
            value: /etc/ipa/krb5.conf
          volumes:
            - config-volume
            - elections-secret-volume
            - ipa-config-volume
            - keytab-volume
  template:
    metadata:
      labels:
        app: elections
        deploymentconfig: elections
    spec:
      containers:
      - name: elections
        image: elections:latest
        ports:
        - containerPort: 8000
        resources: {}
        env:
        - name: KRB5_CONFIG
          value: /etc/ipa/krb5.conf
        - name: GUNICORN_CMD_ARGS
          value: "--bind=0.0.0.0:8000"
        volumeMounts:
        - name: config-volume
          mountPath: /opt/app-root/config/
          readOnly: true
        - name: elections-secret-volume
          mountPath: /opt/app-root/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-cert-volume
          mountPath: /etc/pki/rabbitmq/cert
          readOnly: true
        - name: ipa-config-volume
          mountPath: /etc/ipa
          readOnly: true
        - name: keytab-volume
          mountPath: /etc/keytabs
          readOnly: true
        readinessProbe:
          timeoutSeconds: 1
          initialDelaySeconds: 5
          httpGet:
            path: /
            port: 8000
        livenessProbe:
          timeoutSeconds: 1
          initialDelaySeconds: 30
          httpGet:
            path: /
            port: 8000
      volumes:
      - name: config-volume
        configMap:
          name: elections-configmap
      - name: elections-secret-volume
        secret:
          secretName: elections-secret
      - name: fedora-messaging-ca-volume
        secret:
          secretName: elections-fedora-messaging-ca
      - name: fedora-messaging-key-volume
        secret:
         secretName: elections-fedora-messaging-key
      - name: fedora-messaging-cert-volume
        secret:
          secretName: elections-fedora-messaging-crt
      - name: ipa-config-volume
        configMap:
          name: ipa-client-config
      - name: keytab-volume
        secret:
          secretName: elections-keytab

  triggers:
  - type: ConfigChange
  - type: ImageChange
    imageChangeParams:
      automatic: true
      containerNames:
      - elections
      from:
        kind: ImageStreamTag
        name: elections:latest
