apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
  name: transtats-web
  labels:
    app: transtats
    service: web
spec:
  replicas: 2
  selector:
    app: transtats
    service: web
  template:
    metadata:
      labels:
        app: transtats
        service: web
    spec:
      containers:
      - name: web
        image: transtats
        ports:
        - containerPort: 8080
        env:
        - name: GUNICORN_CMD_ARGS
          value: "--workers 3 --bind 0.0.0.0:8080 --timeout 500"
        - name: DATABASE_ENGINE
          value: postgresql
        - name: DATABASE_NAME
          valueFrom:
            secretKeyRef:
              name: transtats-secret
              key: database-name
        - name: DATABASE_HOST
          valueFrom:
            secretKeyRef:
              name: transtats-secret
              key: database-host
        - name: DATABASE_USER
          valueFrom:
            secretKeyRef:
              name: transtats-secret
              key: database-user
        - name: DATABASE_PASSWORD
          valueFrom:
            secretKeyRef:
              name: transtats-secret
              key: database-password
        readinessProbe:
          timeoutSeconds: 1
          initialDelaySeconds: 5
          httpGet:
            path: /health
            port: 8080
        livenessProbe:
          timeoutSeconds: 1
          initialDelaySeconds: 30
          httpGet:
            path: /health
            port: 8080
        # TODO: re-evaluate these limits once we know how much memory is actually needed
        resources:
          requests:
            cpu: 500m
            memory: 1024Mi
          limits:
            cpu: 2000m
            memory: 2048Mi
  triggers:
  - type: ImageChange
    imageChangeParams:
      automatic: true
      containerNames:
      - web
      from:
        kind: ImageStreamTag
        name: transtats:latest
  - type: ConfigChange
