apiVersion: apps/v1 # for Kubernetes versions before 1.9.0 use apps/v1beta2
kind: DaemonSet
metadata:
  name: cadvisor
  namespace: default
  annotations:
    seccomp.security.alpha.kubernetes.io/pod: 'docker/default'
spec:
  selector:
    matchLabels:
      name: cadvisor
  template:
    metadata:
      labels:
        name: cadvisor
      annotations:
        prometheus.io/scrape: 'true'
        scheduler.alpha.kubernetes.io/critical-pod: ''
    spec:
      containers:
      - name: cadvisor
        image: gcr.io/cadvisor/cadvisor:v0.38.8
        args:
          - --housekeeping_interval=60s
          - --max_housekeeping_interval=75s
          - --event_storage_event_limit=default=0
          - --event_storage_age_limit=default=0
          # Note: tcp,udp stats are very expensive.
          # Enable only network, diskIO, cpu, memory.
          - --disable_metrics=percpu,tcp,udp
          # Only show stats for docker containers.
          - --docker_only
        resources:
          requests:
            memory: 200Mi
            cpu: 150m
          limits:
            cpu: 300m
        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
      automountServiceAccountToken: false
      terminationGracePeriodSeconds: 30
      tolerations:
      - key: "outbound-ip"
        operator: "Equal"
        value: "static"
        effect: "NoSchedule"
      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
