Course contentsShow
← Docker, Kubernetes & CI/CD
Lesson 543 of 8028. Security and ObservabilityFree lesson

Implementing Node Exporter for Infrastructure Metrics

Deploy Node Exporter as a DaemonSet to collect hardware and kernel-level metrics from every node in your cluster.

In this lesson, you will learn how to deploy Node Exporter as a DaemonSet to ensure every node in your Kubernetes cluster exposes essential hardware and kernel-level metrics for monitoring.

Why Node Exporter?

While Prometheus collects metrics from your applications, it needs help understanding the underlying host. Node Exporter is the standard tool designed to expose machine-level metrics—such as CPU load, memory utilization, disk I/O, and network statistics—in a format Prometheus can scrape.

The Power of the DaemonSet

In a Kubernetes cluster, we don't deploy Node Exporter as a standard Deployment because we don't need a specific number of replicas; we need exactly one instance per node.

By using a DaemonSet, Kubernetes automatically schedules a pod on every existing node (and any new nodes you join to the cluster later). This ensures that you have comprehensive observability across your entire infrastructure without manual intervention.

Example Configuration

To deploy Node Exporter, you define a DaemonSet that mounts the host’s filesystems so the exporter can "see" the host's kernel metrics:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: node-exporter
  namespace: monitoring
spec:
  selector:
    matchLabels:
      app: node-exporter
  template:
    metadata:
      labels:
        app: node-exporter
    spec:
      containers:
      - name: node-exporter
        image: prom/node-exporter:latest
        ports:
        - containerPort: 9100
        volumeMounts:
        - name: proc
          mountPath: /host/proc
          readOnly: true
        - name: sys
          mountPath: /host/sys
          readOnly: true
      volumes:
      - name: proc
        hostPath: { path: /proc }
      - name: sys
        hostPath: { path: /sys }

Integration with Prometheus

Once the DaemonSet is running, the pods listen on port 9100. Your Prometheus instance (installed via Helm as discussed in lesson 24) will then look for these pods. By using a Service and a ServiceMonitor (or static scrape configuration), Prometheus will poll these endpoints to build your infrastructure telemetry pipeline. Because this runs at the node level, it provides the "ground truth" for your cluster’s health, allowing you to correlate high application latency with physical bottlenecks like disk saturation or CPU throttling.

Key Takeaway: Deploying Node Exporter as a DaemonSet ensures uniform observability by automatically placing a metric-collecting agent on every node in your cluster.