# Copyright 2020 Cambricon, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: cambricon-mlu-monitor
  namespace: kube-system
  labels:
    app: mlu-monitoring
spec:
  selector:
    matchLabels:
      app: mlu-monitoring
  template:
    metadata:
      labels:
        app: mlu-monitoring
    spec:
      containers:
      - name: cambricon-mlu-monitor
        image: cambricon-mlu-exporter:v1.5.3
        imagePullPolicy: IfNotPresent
        command:
        - /usr/bin/mlu-exporter
        - --metrics-config=/etc/mlu-exporter/metrics.yaml
        - --metrics-path=/metrics
        - --port=30108
        - --collector=cndev
        - --collector=podresources
        #- --collector=host
        #- --collector=cnpapi
        - --metrics-prefix=ai 
        env:
        - name: ENV_NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        securityContext:
          privileged: true
        volumeMounts:
        - mountPath: /var/lib/kubelet/pod-resources/
          name: pod-resources
        - mountPath: /etc/mlu-exporter
          name: mlu-exporter
      volumes:
      - name: pod-resources
        hostPath:
          path: /var/lib/kubelet/pod-resources/
      - name: mlu-exporter
        configMap:
          defaultMode: 420
          name: cambricon-mlu-exporter
      tolerations:
      - effect: NoExecute
        key: node.kubernetes.io/not-ready
        operator: Exists
      - effect: NoExecute
        key: node.kubernetes.io/unreachable
        operator: Exists
      - effect: NoSchedule
        key: node.kubernetes.io/disk-pressure
        operator: Exists
      - effect: NoSchedule
        key: node.kubernetes.io/memory-pressure
        operator: Exists
      - effect: NoSchedule
        key: node.kubernetes.io/unschedulable
        operator: Exists
      - effect: NoSchedule
        key: node.kubernetes.io/network-unavailable
        operator: Exists
