apiVersion: apps/v1 # for Kubernetes versions before 1.9.0 use apps/v1beta2
kind: DaemonSet
metadata:
  name: cadvisor
  namespace: monitoring
  annotations:
      seccomp.security.alpha.kubernetes.io/pod: 'docker/default'
spec:
  selector:
    matchLabels:
      name: monitoring-node-cadvisor
      app: monitoring-node-cadvisor
  template:
    metadata:
      labels:
        name: monitoring-node-cadvisor
        app: monitoring-node-cadvisor
    spec:
      serviceAccountName: cadvisor
      containers:
      - command:
          - /usr/bin/cadvisor
          - --housekeeping_interval=10s                           # kubernetes default args
          - --max_housekeeping_interval=15s
          - --event_storage_event_limit=default=0
          - --event_storage_age_limit=default=0
          - --logtostderr=true  #将日志打到控制台
          - --store_container_labels=false
          - --docker_only=true
          - --disable_root_cgroup_stats=false
          - --whitelisted_container_labels=io.kubernetes.container.name,io.kubernetes.pod.name,io.kubernetes.pod.namespace
          - --disable_metrics=percpu,hugetlb,sched,tcp,udp,advtcp,process,network,disk,accelerator,memory_numa,referenced_memory
        name: cadvisor
        image: registry-jinan-lab.inspurcloud.cn/service/lma/cadvisor:test
        volumeMounts:
        - name: rootfs
          mountPath: /rootfs
          readOnly: true
        - name: var-run
          mountPath: /var/run
          readOnly: true
        - name: sys
          mountPath: /sys
          readOnly: true
        - name: docker
          mountPath: /var/lib/docker
          readOnly: true
        - name: disk
          mountPath: /dev/disk
          readOnly: true
        ports:
          - name: http
            containerPort: 8080
            protocol: TCP
        securityContext:
          privileged: true
          procMount: Default
      automountServiceAccountToken: false
      terminationGracePeriodSeconds: 30
      volumes:
      - name: rootfs
        hostPath:
          path: /
      - name: var-run
        hostPath:
          path: /var/run
      - name: sys
        hostPath:
          path: /sys
      - name: docker
        hostPath:
          path: /var/lib/docker
      - name: disk
        hostPath:
          path: /dev/disk
