apiVersion: apps/v1
kind: Deployment
metadata:
  name: decision-logger-deployment
  namespace: hm
spec:
  replicas: 1
  selector:
    matchLabels:
      component: decision-logger
  template:
    metadata:
      labels:
        component: decision-logger
    spec:
      containers:
        - name: decision-logger
          image: hongbomiao/hm-decision-logger:latest
          env:
            - name: APP_ENV
              valueFrom:
                configMapKeyRef:
                  name: decision-logger-configmap
                  key: app_env
            - name: PORT
              valueFrom:
                configMapKeyRef:
                  name: decision-logger-configmap
                  key: port

            # ---- ELASTIC APM BEGIN ----
            - name: ELASTIC_APM_SERVICE_NAME
              valueFrom:
                configMapKeyRef:
                  name: decision-logger-configmap
                  key: elastic_apm_service_name
            - name: ELASTIC_APM_SERVER_URL
              valueFrom:
                configMapKeyRef:
                  name: elastic-apm-configmap
                  key: elastic_apm_server_url
            - name: ELASTIC_APM_ENVIRONMENT
              valueFrom:
                configMapKeyRef:
                  name: elastic-apm-configmap
                  key: elastic_apm_environment
            - name: ELASTIC_APM_SECRET_TOKEN
              valueFrom:
                secretKeyRef:
                  name: hm-elastic-apm
                  key: token
            - name: ELASTIC_APM_VERIFY_SERVER_CERT
              valueFrom:
                configMapKeyRef:
                  name: elastic-apm-configmap
                  key: elastic_apm_verify_server_cert
            - name: ELASTIC_APM_SERVER_CERT
              valueFrom:
                configMapKeyRef:
                  name: elastic-apm-configmap
                  key: elastic_apm_server_cert
            - name: ELASTIC_APM_LOG_LEVEL
              valueFrom:
                configMapKeyRef:
                  name: elastic-apm-configmap
                  key: elastic_apm_log_level
            - name: ELASTIC_APM_LOG_FILE
              valueFrom:
                configMapKeyRef:
                  name: elastic-apm-configmap
                  key: elastic_apm_log_file
            # ---- ELASTIC APM END ----

          ports:
            - name: decision-logger
              protocol: TCP
              containerPort: 41797

          # ---- ELASTIC APM BEGIN ----
          volumeMounts:
            - mountPath: /data/elastic-apm
              name: elastic-apm-volume
          # ---- ELASTIC APM END ----

      # ---- ELASTIC APM BEGIN ----
      volumes:
        - name: elastic-apm-volume
          persistentVolumeClaim:
            claimName: elastic-apm-pvc
      # ---- ELASTIC APM END ----
