
node-exporter安装
发布日期:2021-05-08 06:01:22
浏览次数:19
分类:精选文章
本文共 2763 字,大约阅读时间需要 9 分钟。
Node-Exporter部署与Prometheus集成指南
1. Node-Exporter部署
node-exporter是一款强大的系统资源监控工具,在Kubernetes生态中发挥着重要作用。本文将指导你如何在Kubernetes集群中部署node-exporter,并进行基本配置。
部署步骤
部署YAML文件
创建一个名为node-exporter.yaml
的文件,填写以下内容: apiVersion: apps/v1kind: DaemonSetmetadata: name: node-exporter namespace: default labels: name: node-exporterspec: selector: matchLabels: name: node-exporter template: metadata: labels: name: node-exporter spec: hostPID: true hostIPC: true hostNetwork: true containers: - name: node-exporter image: prom/node-exporter:v1.0.1 ports: - containerPort: 9100 resources: requests: cpu: 0.15 securityContext: privileged: true args: - --path.procfs - /host/proc - --path.sysfs - /host/sys - --collector.filesystem.ignored-mount-points - '"^/(sys|proc|dev|host|etc)($|/)"' volumeMounts: - name: dev mountPath: /host/dev - name: proc mountPath: /host/proc - name: sys mountPath: /host/sys - name: rootfs mountPath: /rootfs tolerations: - key: "node-role.kubernetes.io/master" operator: "Exists" effect: "NoSchedule" volumes: - name: proc hostPath: /proc - name: dev hostPath: /dev - name: sys hostPath: /sys - name: rootfs hostPath: /
应用配置文件
使用kubectl
命令应用上述YAML文件: kubectl apply -f node-exporter.yaml
验证部署
部署完成后,可以通过以下命令查看node-exporter的运行状态:
kubectl get pods -n default -l name=node-exporter
2. 查看Node-Exporter使用的IP
要查看node-exporter服务的IP地址,可以使用以下命令:
kubectl get pods -o wide
此时会显示所有节点的IP地址,包括node-exporter的服务IP。
3. Prometheus中配置Node-Exporter
在Prometheus中配置node-exporter作为数据源,可以通过以下步骤完成:
配置Prometheus YAML文件
打开Prometheus配置文件(例如prometheus.yml
),找到scrape_configs
部分,添加以下内容: - job_name: node-exporter honor_timestamps: true scrape_interval: 30s scrape_timeout: 10s metrics_path: /metrics scheme: http static_configs: - targets: - 192.168.39.170:9100
保存并应用配置
确保配置文件路径正确,然后应用修改:kubectl apply -f prometheus.yml
注意事项
- 版本更新:node-exporter和Prometheus的版本更新非常频繁,建议在部署前查阅最新文档。
- 依赖关系:确保Prometheus和Node-Exporter的版本是兼容的。
4. 端口暴露
为了方便测试和访问,可以将Prometheus或Node-Exporter的服务端口暴露到外部。
方法一:使用Minikube Tunnel
如果使用Minikube或其他Kubernetes集群,可以通过以下命令暴露服务:
kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=prometheus -o jsonpath='{.items[0].metadata.name}') 9090:9090 &
方法二:端口转发
对于本地开发,可以使用端口转发:
kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=prometheus -o jsonpath='{.items[0].metadata.name}') 9090:9090 &
这样,你就可以通过localhost:9090
或指定IP地址访问Prometheus服务了。
发表评论
最新留言
网站不错 人气很旺了 加油
[***.192.178.218]2025年04月06日 03时30分24秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
jQuery实现轮播图效果
2019-03-05
mybatis中like的注意
2019-03-05
sqlplus的基本使用
2019-03-05
oracle删除表重复数据
2019-03-05
Oracle删除主表数据
2019-03-05
js中两种定时器,setTimeout和setInterval实现验证码发送
2019-03-05
Oracle常用SQL
2019-03-05
golang内存及GC分析简易方法
2019-03-05
技术美术面试问题整理
2019-03-05
Redis分布式锁原理
2019-03-05
【备份】求极限笔记
2019-03-05
C++学习记录 四、基于多态的企业职工系统
2019-03-05
C++学习记录 五、C++提高编程(2)
2019-03-05
面试问道nginx优化怎么做的
2019-03-05
自学linux毕业shell面试题
2019-03-05
4 Java 访问控制符号的范围
2019-03-05
第9章 - 有没有替代原因(检验证据)
2019-03-05
VUE3(八)setup与ref函数
2019-03-05
Vue之Element标签页保留用户操作缓存。
2019-03-05