---
apiVersion: v1
kind: DeploymentConfig
metadata:
  name: greenwave-web
  labels:
    app: greenwave
    service: web
spec:
  replicas: 2
  selector:
    app: greenwave
    service: web
  template:
    metadata:
      labels:
        app: greenwave
        service: web
    spec:
      containers:
      - name: web
        image: registry/greenwave:latest
        ports:
        - containerPort: 8080
        volumeMounts:
        - name: config-volume
          mountPath: /etc/greenwave
          readOnly: true
        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: greenwave-configmap
  triggers:
  - type: ImageChange
    imageChangeParams:
      automatic: true
      containerNames:
      - web
      from:
        kind: ImageStreamTag
        name: greenwave:latest
  - type: ConfigChange
---
# For fedmsg consumers
apiVersion: v1
kind: DeploymentConfig
metadata:
  name: greenwave-fedmsg-consumers
  labels:
    app: greenwave
    service: fedmsg-consumers
spec:
  replicas: 1
  selector:
    service: fedmsg-consumers
  template:
    metadata:
      labels:
        app: greenwave
        service: fedmsg-consumers
    spec:
      containers:
      - name: fedmsg-consumers
        image: registry/greenwave:latest
        ports:
        - containerPort: 8081
        command:
        - '/usr/bin/fedmsg-hub-3'
        volumeMounts:
        - name: config-volume
          mountPath: /etc/greenwave
          readOnly: true
        - name: fedmsg-config-volume
          mountPath: /etc/fedmsg-greenwave.d
          readOnly: true
        - name: fedmsg-key-volume
          mountPath: /etc/pki/fedmsg/key
          readOnly: true
        - name: fedmsg-crt-volume
          mountPath: /etc/pki/fedmsg/crt
          readOnly: true
        resources:
          limits:
            memory: 384Mi
      volumes:
      # Give the fedmsg-consumer container access to the general config
      - name: config-volume
        configMap:
          name: greenwave-configmap
      # But *also* access to the fedmsg-specific config
      - name: fedmsg-config-volume
        configMap:
          name: greenwave-fedmsg-configmap
      # And... this secret volume gets set up in the playbook
      - name: fedmsg-key-volume
        secret:
          secretName: greenwave-fedmsg-key
      - name: fedmsg-crt-volume
        secret:
          secretName: greenwave-fedmsg-crt
  triggers:
  - type: ImageChange
    imageChangeParams:
      automatic: true
      containerNames:
      - fedmsg-consumers
      from:
        kind: ImageStreamTag
        name: greenwave:latest
  - type: ConfigChange
---
# For memcached
apiVersion: v1
kind: DeploymentConfig
metadata:
  name: greenwave-memcached
  labels:
    app: greenwave
    service: greenwave-memcached
spec:
  replicas: 1
  selector:
    service: greenwave-memcached
  template:
    metadata:
      labels:
        app: greenwave
        service: greenwave-memcached
    spec:
      containers:
      - name: greenwave-memcached
        image: registry.fedoraproject.org/f28/memcached
        ports:
        - containerPort: 11211
        resources:
          limits:
            memory: 384Mi
  triggers:
  - type: ConfigChange
