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

        - name: ENV
          valueFrom:
            configMapKeyRef:
              name: env-vars-config
              key: ENV

        # 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

        # EMAIL SERVER CONFIG
        - name: AKB_EMAIL_SERVER_HOST
          valueFrom:
            secretKeyRef:
              name: env-secrets-config
              key: EMAIL_SERVER_HOST
        - name: AKB_EMAIL_SERVER_PORT
          valueFrom:
            secretKeyRef:
              name: env-secrets-config
              key: EMAIL_SERVER_PORT
        - name: AKB_NOREPLY_EMAIL
          valueFrom:
            secretKeyRef:
              name: env-secrets-config
              key: NOREPLY_EMAIL
        - name: AKB_NOREPLY_EMAIL_PASSWORD
          valueFrom:
            secretKeyRef:
              name: env-secrets-config
              key: NOREPLY_EMAIL_PASSWORD

        command: ["python", "hermes/consumer.py"]
        volumeMounts:
        - name: logs
          mountPath: /var/log/hermes

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


