---
apiVersion: apps.openshift.io/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: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
  name: greenwave-fedmsg-consumers
  labels:
    app: greenwave
    service: fedmsg-consumers
spec:
  replicas: 0
  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:
        - "/src/docker/docker-entrypoint.sh"
        args:
        - "fedora-messaging"
        - "consume"
        volumeMounts:
        - name: config-volume
          mountPath: /etc/greenwave
          readOnly: true
        - name: fedora-messaging-config-volume
          mountPath: /etc/fedora-messaging
          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
        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: fedora-messaging-config-volume
        configMap:
          name: fedora-messaging-configmap
      # And... this secret volume gets set up in the playbook
      - name: fedora-messaging-ca-volume
        secret:
          secretName: greenwave-fedora-messaging-ca
      - name: fedora-messaging-key-volume
        secret:
          secretName: greenwave-fedora-messaging-key
      - name: fedora-messaging-crt-volume
        secret:
          secretName: greenwave-fedora-messaging-crt
  triggers:
  - type: ImageChange
    imageChangeParams:
      automatic: true
      containerNames:
      - fedmsg-consumers
      from:
        kind: ImageStreamTag
        name: greenwave:latest
  - type: ConfigChange
---
# For memcached
apiVersion: apps.openshift.io/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: memcached:1.5
        ports:
        - containerPort: 11211
        resources:
          limits:
            memory: 384Mi
  triggers:
  - type: ConfigChange
