使用node-exporter监控k8s集群内主机资源
简介
prometheus监控服务器CPU、内存、磁盘、I/O等信息,可以使用node-exporter,在虚机或物理机环境中,监控主机的步骤是,在每台主机上安装node-exporter,然后在prometheus的抓取任务中配置每一台主机的地址,每次添加主机,都需要重复去做这个操作,而在k8s环境中,我们可以通过DaemonSet类型创建node-exporter,基于Prometheus在k8s内的node类型的服务发现,可以对新扩容的主机自动部署node-exporter并纳入监控。
操作
首先了解一下DaemonSet
DaemonSet确保全部(或者一些)Node上运行一个Pod的副本。当有Node加入集群时,也会为他们新增一个Pod。当有Node从集群
移除时,这些Pod也会被回收。
简单来说,默认配置下,daemonset会在集群中每一台节点上都运行一个pod,但不包括master节点,如果想在master节点上也运行pod的话,需要在启动参数中配置tolerations
然后是在k8s环境下安装node-exporter需要注意的问题,我们查看node-exporter官方文档
The node_exporter is designed to monitor the host system. It's not recommended to deploy it as a Docker container because it
requires access to the host system. Be aware that any non-root mount points you want to monitor will need to be bind-mounted into
the container. If you start container for host mon

本文介绍了如何在Kubernetes环境下利用DaemonSet部署node-exporter,监控每台主机的CPU、内存、磁盘和I/O,实现对新节点的自动扩展监控。
最低0.47元/天 解锁文章
1384





