k8s编排部署的方式部署Prometheus、node_exporter、cadvisor、grafana
- 1. 拉取google/cadvisor官方镜像
- 2. 将cadvsior镜像运行为容器
- 3. 修改Prometheus的配置文件
1. 拉取google/cadvisor官方镜像
[root@node1 ~]# docker pull google/cadvisor
Using default tag: latest
latest: Pulling from google/cadvisor
ff3a5c916c92: Pull complete
44a45bb65cdf: Pull complete
0bbe1a2fe2a6: Pull complete
Digest: sha256:815386ebbe9a3490f38785ab11bda34ec8dacf4634af77b8912832d4f85dca04
Status: Downloaded newer image for google/cadvisor:latest
docker.io/google/cadvisor:latest
2. 将cadvsior镜像运行为容器
[root@node1 ~]# docker run \
> --volume=/:/rootfs:ro \
> --volume=/var/run:/var/run:ro \
> --volume=/sys:/sys:ro \
> --volume=/var/lib/docker/:/var/lib/docker:ro \
> --volume=/dev/disk/:/dev/disk:ro \
> --publish=8080:8080 \
> --detach=true \
> --name=cadvisor \
> --privileged \
> --device=/dev/kmsg \
> google/cadvisor
e6d917eac1f94459cbe0403af37f17a08fef4d42012bd6cba22c6c37a6b55ff8[root@node1 ~]# docker ps | grep cadvisor
e6d917eac1f9 google/cadvisor "/usr/bin/cadvisor -…" About a minute ago Up About a minute 0.0.0.0:8080->8080/tcp cadvisor
测试访问web界面,点击docker containers可以用来查看指定容器的详细信息
// 可以点击查看
3. 修改Prometheus的配置文件
// 使用上一篇博客的Prometheus的容器
# Here it's Prometheus itself.
scrape_configs:# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.- job_name: "prometheus"- job_name: "linux"- job_name: "cadvisor" //要监控的对象# metrics_path defaults to '/metrics'# scheme defaults to 'http'.static_configs:- targets: ["localhost:9090"]- targets: ["192.168.182.151:9100"]- targets: ["192.168.182.151:8080"] //添加要监控的主机[root@master prometheus]# docker restart prometheus //重启容器
prometheus
// 查看web界面