#
# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES, ALL RIGHTS RESERVED.
#
# This software product is a proprietary product of NVIDIA CORPORATION &
# AFFILIATES (the "Company") and all right, title, and interest in and to the
# software product, including all associated intellectual property rights, are
# and shall remain exclusively with the Company.
#
# This software product is governed by the End User License Agreement
# provided with the software product.
#

apiVersion: v1
kind: Pod
metadata:
  name: doca-telemetry-service
spec:
  restartPolicy: Always
  hostNetwork: true
  volumes:
  - name: telemetry-service-config
    hostPath:
      path: /opt/mellanox/doca/services/telemetry/config
      type: DirectoryOrCreate
  - name: telemetry-service-data
    hostPath:
      path: /opt/mellanox/doca/services/telemetry/data
      type: DirectoryOrCreate
  - name: telemetry-service-ipc-sockets
    hostPath:
      path: /opt/mellanox/doca/services/telemetry/ipc_sockets
      type: DirectoryOrCreate
  - name: telemetry-ipc-shm
    hostPath:
      path: /dev/shm/telemetry
      type: DirectoryOrCreate
  - name: telemetry-service-logs
    hostPath:
      path: /var/log/doca/telemetry
      type: DirectoryOrCreate
  containers:
    - name: doca-telemetry-service
      securityContext:
        capabilities:
          add: ["SYS_ADMIN"]
        seccompProfile:
          type: Unconfined
      resources:
        requests:
          memory: "400Mi"
          cpu: "200m"
        limits:
          memory: "1000Mi"
          cpu: "1"
      image: doca_telemetry:1.23.5-doca3.2.1
      volumeMounts:
      - name: telemetry-service-config
        mountPath: /config
      - name: telemetry-service-data
        mountPath: /data
      - name: telemetry-service-ipc-sockets
        mountPath: /tmp/ipc_sockets
      - name: telemetry-ipc-shm
        mountPath: /dev/shm
      - name: telemetry-service-logs
        mountPath: /var/log
      command: ["/usr/bin/telemetry-run.sh"]
  initContainers:
    - name: init-telemetry-service
      securityContext:
        privileged: true
      image: doca_telemetry:1.23.5-doca3.2.1
      volumeMounts:
      - name: telemetry-service-config
        mountPath: /config
      command: ["/bin/bash", "-c", "/usr/bin/telemetry-init.sh && /usr/bin/enable-fluent-forward.sh"]
      # Enable fluent forward with enable-fluent-forward.sh. Without required
      # arguments it will do nothing. Arguments:
      #   "-i=" to set host (required)
      #   "-p=" to set port (required)
      #   "-d="  to use predefined filter rules. Available arguments: "morpheus"

