apiVersion: apps/v1 #extensions/v1beta1
kind: DaemonSet
metadata:
  name: node-exporter
  labels:
    app: node-exporter
spec:
  selector:
    matchLabels:
      app: node-exporter
  updateStrategy:
    type: OnDelete
  template:
    metadata:
      labels:
        app: node-exporter
    spec:
      serviceAccountName: node-exporter
      containers:
        - name: node-exporter
          # Use the `quay.io/prometheus/node-exporter:v0.17.0` image
          image: quay.io/prometheus/node-exporter:v0.17.0
          imagePullPolicy: Always
          args:
            - --path.procfs=/host/proc
            - --path.sysfs=/host/sys
          ports:
            # Expose metrics for scraping on port `9100`
            - name: metrics
              containerPort: 9100
              hostPort: 9100
          # The `proc` and `sys` Node paths are mounted into the Pod at `/host/proc` and `/host/sys` respectively.
          # To learn more about `proc` and `sys`, pseudo file systems that are used to provide information about the Node, 
          # consult http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/proc.html from the Linux Documentation Project 
          # and https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt from the Linux Kernel's documentation. 
          volumeMounts:
            - name: proc
              mountPath: /host/proc
              readOnly:  true
            - name: sys
              mountPath: /host/sys
              readOnly: true
          # Resource limits and requests of `10m` of CPU and `50Mi` of memory
          resources:
            limits:
              cpu: 10m
              memory: 50Mi
            requests:
              cpu: 10m
              memory: 50Mi
      # The `hostNetwork` and `hostPID` Pod Security parameters are set to `true` to allow `node-exporter` 
      # to  access the host process ID namespace and Node network namespace, which are required for scraping Node metrics
      hostNetwork: true
      hostPID: true
      volumes:
        - name: proc
          hostPath:
            path: /proc
        - name: sys
          hostPath:
            path: /sys
