apiVersion: apps/v1
kind: Deployment
metadata:
  name: aristaeus-listener
  labels:
    app: aristaeus-listener
spec:
  selector:
    matchLabels:
      app: aristaeus-listener
  template:
    metadata:
      labels:
        app: aristaeus-listener
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: elastic-node
                operator: DoesNotExist
      containers:
      - image: yomain/aristaeus:latest
        name: aristaeus-listener
        env:
        - name: AKB_SERVICE_NAME
          value: aristaeus-listener
        - name: ENV
          valueFrom:
            configMapKeyRef:
              name: env-vars-config
              key: ENV
        - name: AKB_LOG_FORMAT
          value: json

        # DATABASE CREDENTIALS
        - name: AKB_DATABASE_HOST
          valueFrom:
            secretKeyRef:
              name: env-secrets-config
              key: DATABASE_HOST
        - name: AKB_DATABASE_PORT
          valueFrom:
            secretKeyRef:
              name: env-secrets-config
              key: DATABASE_PORT
        - name: AKB_DATABASE_USER
          valueFrom:
            secretKeyRef:
              name: env-secrets-config
              key: DATABASE_USER
        - name: AKB_DATABASE_PASSWORD
          valueFrom:
            secretKeyRef:
              name: env-secrets-config
              key: DATABASE_PASSWORD
        - name: AKB_DATABASE_DBNAME
          valueFrom:
            secretKeyRef:
              name: env-secrets-config
              key: DATABASE_DBNAME

        # RBMQ CREDENTIALS
        - name: AKB_RBMQ_HOST
          valueFrom:
            secretKeyRef:
              name: env-secrets-config
              key: RBMQ_HOST
        - name: AKB_RBMQ_PORT
          valueFrom:
            secretKeyRef:
              name: env-secrets-config
              key: RBMQ_PORT
        - name: AKB_RBMQ_USER
          valueFrom:
            secretKeyRef:
              name: env-secrets-config
              key: RBMQ_USER
        - name: AKB_RBMQ_PASSWORD
          valueFrom:
            secretKeyRef:
              name: env-secrets-config
              key: RBMQ_PASSWORD
        - name: AKB_RBMQ_VHOST
          valueFrom:
            secretKeyRef:
              name: env-secrets-config
              key: RBMQ_VHOST

        command: ["python", "aristaeus/listener.py"]
        ports:
        - containerPort: 15672
        volumeMounts:
        - mountPath: /var/log/aristaeus
          name: logs

      volumes:
      - name: logs
        hostPath:
          type: DirectoryOrCreate
          path: /var/log/akingbee


