All tools / Kubernetes examples
Node Exporter on Kubernetes
A DaemonSet that runs Prometheus Node Exporter on every node, including control-plane nodes, with a Service Prometheus discovers automatically.
node-exporter.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: node-exporter
namespace: monitoring
labels:
app: node-exporter
spec:
selector:
matchLabels:
app: node-exporter
template:
metadata:
labels:
app: node-exporter
spec:
hostNetwork: true
hostPID: true
securityContext:
runAsNonRoot: true
runAsUser: 65534
tolerations:
- operator: Exists
containers:
- name: node-exporter
image: prom/node-exporter:v1.9.1
args:
- --path.procfs=/host/proc
- --path.sysfs=/host/sys
- --path.rootfs=/host/root
- --collector.filesystem.mount-points-exclude=^/(dev|proc|sys|var/lib/docker/.+|var/lib/kubelet/.+)($|/)
ports:
- name: metrics
containerPort: 9100
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
memory: 128Mi
volumeMounts:
- name: proc
mountPath: /host/proc
readOnly: true
- name: sys
mountPath: /host/sys
readOnly: true
- name: root
mountPath: /host/root
mountPropagation: HostToContainer
readOnly: true
volumes:
- name: proc
hostPath:
path: /proc
- name: sys
hostPath:
path: /sys
- name: root
hostPath:
path: /
---
apiVersion: v1
kind: Service
metadata:
name: node-exporter
namespace: monitoring
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9100"
spec:
clusterIP: None
selector:
app: node-exporter
ports:
- name: metrics
port: 9100
targetPort: metrics
How to use it
Commands
kubectl create namespace monitoring --dry-run=client -o yaml | kubectl apply -f - kubectl apply -f node-exporter.yaml kubectl -n monitoring get pods -w
- The Service carries prometheus.io/scrape annotations, so the Prometheus template on this site picks it up with no extra config.
Prefer Docker Compose? See the Node Exporter Docker Compose version.