#docker run -d --hostname my-rabbit --name some-rabbit -p 8080:15672 -p 5672:5672 rabbitmq:3-management

---
kind: Service
apiVersion: v1
metadata:
  name: metric-analyzer-master
  namespace: imxc
spec:
#  clusterIP: None  # We need a headless service to allow the pods to discover each
  ports:           # other during autodiscover phase for cluster creation.
   - name: http    # A ClusterIP will prevent resolving dns requests for other pods
     protocol: TCP # under the same service.
     port: 15672
     targetPort: 15672
#     nodePort: 30001
   - name: amqp
     protocol: TCP
     port: 5672
     targetPort: 5672
#     nodePort: 30002
  selector:
    app: metric-analyzer-master
#  type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: metric-analyzer-master
  name: metric-analyzer-master
  namespace: imxc
spec:
  replicas: 1
  selector:
    matchLabels:
      app: metric-analyzer-master
  template:
    metadata:
      labels:
        app: metric-analyzer-master
    spec:
      imagePullSecrets:
      - name: {{ .Values.global.imagepullsecrets }}
      containers:
      - image: {{ .Values.global.IMXC_IN_REGISTRY }}/metric_analyzer:{{ .Values.global.METRIC_ANALYZER_MASTER_VERSION }}
        imagePullPolicy: IfNotPresent
        name: master
#        volumeMounts:
#          - mountPath: /etc/localtime
#            name: timezone-config
        env:
          - name: BROKER
            value: base-rabbitmq
          - name: IMXC_RABBITMQ_CLIENT_ID
            value: "user"
          - name: IMXC_RABBITMQ_CLIENT_PASSWORD
            value: "eorbahrhkswp"
          - name: POSTGRES_SERVER
            value: postgres
          - name: POSTGRES_USER
            value: admin
          - name: POSTGRES_PW
            value: eorbahrhkswp
          - name: POSTGRES_DB
            value: postgresdb
          - name: PROMETHEUS_URL
            value: http://base-cortex-nginx/prometheus
          - name: POSTGRES_PORT
            value: "5432"
          - name: ES_SERVER
            value: elasticsearch
          - name: ES_PORT
            value: "9200"
          - name: ES_ID
            value: "elastic"
          - name: ES_PWD
            value: "elastic"
          - name: LOG_LEVEL
            value: INFO
          - name: AI_TYPE
            value: BASELINE
          - name: BASELINE_SIZE
            value: "3"
          - name: CHECK_DAY
            value: "2"
        resources:
          requests:
            memory: "100Mi"
