node-exporter yaml
docker pull prom/node-exporter
node-exporter.yaml
apiVersion: apps/v1
kind: DaemonSet #daemonset会保证每个node都有这个pod
metadata:
name: node-exporter
namespace: promtest
spec:
selector:
matchLabels:
app: node-exporter
template:
metadata:
labels:
app: node-exporter
spec:
hostPID: true
hostIPC: true
hostNetwork: true
containers:
- name: node-exporter
image: prom/node-exporter
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9100
hostPort: 9100
resources:
requests:
cpu: 100m
memory: 100Mi
limits:
cpu: 2000m
memory: 2Gi
securityContext:
privileged: true
args:
- --path.procfs
- /host/proc
- --path.sysfs
- /host/sys
- --path.rootfs
- /host/root
- --collector.filesystem.ignored-mount-points
- '"^/(sys|proc|dev|host|etc)($|/)"'
- "--collector.processes"
volumeMounts:
- name: dev
mountPath: /host/dev
- name: proc
mountPath: /host/proc
- name: sys
mountPath: /host/sys
- name: rootfs
mountPath: /host/root
tolerations: #污点容忍
- key: "node-role.kubernetes.io/master"
operator: "Exists"
effect: "NoSchedule"
volumes:
- name: proc
hostPath:
path: /proc
- name: dev
hostPath:
path: /dev
- name: sys
hostPath:
path: /sys
- name: rootfs
hostPath:
path: /
#如果要在容器环境中部署node-exporter,需要将主机的根节点绑定到容器环境,不然在查询磁盘等参数时,数据是不准确的
node-ser.yaml
kind: Service
apiVersion: v1
metadata:
name: node-ser
namespace: promtest
labels:
app: node-exporter
spec:
ports:
- name: metricsa
port: 9100
protocol: TCP
targetPort: 9100
selector:
app: node-exporter
评论已关闭