Kubernetes之kubeadm集群监控篇—node-exporter部署

本文介绍了如何在Kubernetes中使用node-exporterYAML文件进行部署,包括创建命名空间、定义DaemonSet、配置容器参数和检查Pod状态。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

编写node-exporter yaml文件

# cat node-exporter.yaml 
apiVersion: v1
kind: Namespace
metadata:
  name: kube-prom
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: node-exporter
  namespace: kube-prom
  labels:
    k8s-app: node-exporter
spec:
  selector:
    matchLabels:
      k8s-app: node-exporter
  template:
    metadata:
      labels:
        k8s-app: node-exporter
    spec:
      hostPID: true
      hostIPC: true
      hostNetwork: true
      tolerations:
      - key: node-role.kubernetes.io/master
        operator: Exists
        effect: NoSchedule
      restartPolicy: Always
      containers:
      - image: registry.cn-beijing.aliyuncs.com/mayaping/node-exporter:v1.0.1
        imagePullPolicy: IfNotPresent
        name: node-exporter
        args:
        - --path.procfs
        - /host/proc
        - --path.sysfs
        - /host/sys
        - --collector.filesystem.ignored-mount-points
        - '"^/(sys|proc|dev|host|etc)($|/)"'
        ports:
        - containerPort: 9100
          protocol: TCP
          name: http
        securityContext:
          privileged: true
        volumeMounts:
        - name: dev
          mountPath: /host/dev
        - name: proc
          mountPath: /host/proc
        - name: sys
          mountPath: /host/sys
        - name: rootfs
          mountPath: /rootfs
      volumes:
      - name: proc
        hostPath:
          path: /proc
      - name: dev
        hostPath:
          path: /dev
      - name: sys
        hostPath:
          path: /sys
      - name: rootfs
        hostPath:
          path: /

部署node-exporter

# kubectl apply -f node-exporter.yaml 
namespace/kube-prom unchanged
daemonset.apps/node-exporter created

查看pod容器情况

# kubectl get pods --namespace kube-prom 
NAME                          READY   STATUS    RESTARTS   AGE
node-exporter-7fh6k           1/1     Running   0          3m19s
node-exporter-dws9d           1/1     Running   0          3m19s
node-exporter-q29ll           1/1     Running   0          3m19s
prometheus-7749bcdfd8-44p9p   1/1     Running   0          134m
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

杰哥的技术杂货铺

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值