posts - 360,  comments - 2593,  views - 286万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

本节以 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:

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

执行 kubectl apply -f node_exporter.yml

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

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

书籍:

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


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

posted on   CloudMan  阅读(3538)  评论(6编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
点击右上角即可分享
微信分享提示