apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: job-exporter-amd64
  namespace: kube-system
spec:
  selector:
    matchLabels:
      app: job-exporter
  template:
    metadata:
      labels:
        app: job-exporter
        task: monitoring
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/path: "/metrics"
        prometheus.io/port: "9102"
      name: job-exporter-amd64
    spec:
      nodeSelector:
        archType: amd64
      containers:
      - image: harbor.apulis.cn:8443/aiarts_v1.5.0_rc8/apulistech/job-exporter:1.9

        imagePullPolicy: Always
        livenessProbe: # in case job-exporter hangs
          httpGet:
            path: '/healthz'
            port: 9102
          initialDelaySeconds: 30
          periodSeconds: 30
          timeoutSeconds: 10
        command:
        - "python"
        - "/job_exporter/main.py"
        - "--port"
        - "9102"
        - "--interval"
        - "30"
        - "--interface"
        - "eth0"
        resources:
          limits:
            memory: "512Mi"
        securityContext:
          privileged: true # this is required since job-exporter will call setns to other containers
        env:
        - name: HOST_IP
          valueFrom:
            fieldRef:
              fieldPath: status.hostIP
        - name: LOGGING_LEVEL
          value: INFO
        - name: NV_DRIVER
          value: /var/drivers/nvidia/current
        - name: NVIDIA_VISIBLE_DEVICES
          value: all
        - name: LD_LIBRARY_PATH
          value: $LD_LIBRARY_PATH:/usr/local/HiAI/add-ons:/usr/local/HiAI/driver/lib64:/usr/local/HiAI/runtime/lib64:/usr/local/HiAI/toolchain/lib64  
        volumeMounts:
        - mountPath: /var/run/docker.sock
          name: docker-socket
        - mountPath: /dev
          name: device-mount
        - mountPath: /var/drivers/nvidia/current
          name: driver-path
        - name: hiai
          mountPath: /usr/local/HiAI
        - name: npu-smi
          mountPath: /usr/local/sbin/
        - name: npu-info 
          mountPath: /var/log/npu/npu_smi
        name: job-exporter
        ports:
        - containerPort: 9102
          hostPort: 9102
          name: main
      volumes:
        - name: docker-socket
          hostPath:
            path: /var/run/docker.sock
        - name: device-mount
          hostPath:
            path: /dev
        - name: driver-path
          hostPath:
            path: /var/drivers/nvidia/current
        - name: hiai
          hostPath:
            path: /usr/local/HiAI
        - name: npu-smi
          hostPath:
            path: /usr/local/sbin/
        - name: npu-info
          hostPath:
            path: /var/log/npu/npu_smi
      hostNetwork: true
      hostPID: true # This is required since job-exporter should get list of pid in container
      tolerations:
      - key: node.kubernetes.io/memory-pressure
        operator: "Exists"
      - key: node.kubernetes.io/disk-pressure
        operator: "Exists"
      - key: node-role.kubernetes.io/master
        operator: "Exists"
