本节以 Prometheus Node Exporter 为例演示如何运行自己的 DaemonSet。

Prometheus 是流行的系统监控方案,Node Exporter 是 Prometheus 的 agent,以 Daemon 的形式运行在每个被监控节点上。

如果是直接在 Docker 中运行 Node Exporter 容器,命令为:

docker run -d \
 -v "/proc:/host/proc" \
 -v "/sys:/host/sys" \
 -v "/:/rootfs" \
 --net=host \  prom/node-exporter \
 --path.procfs /host/proc \
 --path.sysfs /host/sys \
 --collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)"

将其转换为 DaemonSet 的 YAML 配置文件 node_exporter.yml:

运行自己的 DaemonSet - 每天5分钟玩转 Docker 容器技术(131)

① 直接使用 Host 的网络。
② 设置容器启动命令。
③ 通过 Volume 将 Host 路径 
/proc/sys 和 / 映射到容器中。我们将在后面详细讨论 Volume。

执行 kubectl apply -f node_exporter.yml

运行自己的 DaemonSet - 每天5分钟玩转 Docker 容器技术(131)

DaemonSet node-exporter-daemonset 部署成功,k8s-node1 和 k8s-node2 上分别运行了一个 node exporter Pod。

DaemonSet 就讨论到这里,下一节我们学习另一个 Controller -- Job。

运行自己的 DaemonSet - 每天5分钟玩转 Docker 容器技术(131)书籍:

1.《每天5分钟玩转Docker容器技术》
https://item.jd.com/16936307278.html


2.《每天5分钟玩转OpenStack》
https://item.jd.com/12086376.html

运行自己的 DaemonSet - 每天5分钟玩转 Docker 容器技术(131)

转载于:https://blog.51cto.com/cloudman/2071854

相关文章:

  • 2021-06-21
  • 2021-06-26
  • 2021-05-16
猜你喜欢
  • 2021-11-16
  • 2021-11-29
  • 2022-01-05
相关资源
相似解决方案