apiVersion: apps/v1
kind: Deployment
metadata:
  name: consumer
  namespace: cloud-native-events
  labels:
    app: consumer
spec:
  replicas: 1
  selector:
    matchLabels:
      app: consumer
  template:
    metadata:
      labels:
        app: consumer
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: app
                    operator: In
                    values:
                      - local
      serviceAccountName: sidecar-consumer-sa
      containers:
        - name: cloud-native-event-consumer
          image: quay.io/redhat-cne/cloud-native-event-consumer
          args:
            - "--local-api-addr=127.0.0.1:9089"
            - "--api-path=/api/cloudNotifications/v1/"
            - "--api-addr=127.0.0.1:8089"
          env:
            - name: NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: CONSUMER_TYPE
              value: "HW"
            - name: LOG_LEVEL
              value: "debug"
        - name: cloud-native-event-sidecar
          image: quay.io/redhat-cne/cloud-event-proxy
          args:
            - "--metrics-addr=127.0.0.1:9091"
            - "--store-path=/store"
            - "--transport-host=amqp://router.$(AMQP_NAMESPACE).svc.cluster.local"
            - "--api-port=8089"
          env:
            - name: AMQP_NAMESPACE
              value: "router"
            - name: NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: LOG_LEVEL
              value: "debug"
          volumeMounts:
            - name: pubsubstore
              mountPath: /store
          ports:
            - name: metrics-port
              containerPort: 9091
        - name: kube-rbac-proxy
          image: quay.io/coreos/kube-rbac-proxy:v0.5.0
          args:
            - --logtostderr
            - --secure-listen-address=:8443
            - --tls-cipher-suites=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
            - --upstream=http://127.0.0.1:9091/
            - --tls-private-key-file=/etc/metrics/tls.key
            - --tls-cert-file=/etc/metrics/tls.crt
          ports:
            - containerPort: 8443
              name: https
          resources:
            requests:
              cpu: 10m
              memory: 20Mi
          volumeMounts:
            - name: sidecar-certs
              mountPath: /etc/metrics
      volumes:
        - name: pubsubstore
          emptyDir: {}
        - name: sidecar-certs
          secret:
            secretName: sidecar-consumer-secret
