当前位置: 首页 > article >正文

Kubernetes DaemonSet深度解析:管理集群守护进程的最佳实践

Kubernetes DaemonSet深度解析管理集群守护进程的最佳实践一、DaemonSet概述DaemonSet是Kubernetes中用于在集群的每个节点上运行一个Pod副本的控制器。它确保所有节点或满足特定条件的节点都运行该Pod的一个实例。1.1 DaemonSet应用场景场景说明示例日志收集每个节点运行日志收集器Fluentd、Filebeat监控代理每个节点运行监控采集器Prometheus Node Exporter网络插件每个节点运行网络组件Calico、Flannel存储代理每个节点运行存储驱动CSI节点插件安全代理每个节点运行安全组件入侵检测系统1.2 DaemonSet vs Deployment特性DaemonSetDeployment副本数每个节点一个任意数量调度节点级别Pod级别更新策略滚动更新/替换滚动更新/重建适用场景节点守护进程应用服务二、DaemonSet核心配置2.1 基本DaemonSet配置apiVersion: apps/v1 kind: DaemonSet metadata: name: fluentd namespace: kube-system labels: k8s-app: fluentd-logging spec: selector: matchLabels: name: fluentd template: metadata: labels: name: fluentd spec: tolerations: - key: node-role.kubernetes.io/control-plane operator: Exists effect: NoSchedule containers: - name: fluentd image: fluentd:v1.12 resources: limits: memory: 200Mi requests: cpu: 100m memory: 200Mi volumeMounts: - name: varlog mountPath: /var/log - name: varlibdockercontainers mountPath: /var/lib/docker/containers readOnly: true volumes: - name: varlog hostPath: path: /var/log - name: varlibdockercontainers hostPath: path: /var/lib/docker/containers2.2 节点选择器配置apiVersion: apps/v1 kind: DaemonSet metadata: name: node-exporter spec: selector: matchLabels: app: node-exporter template: metadata: labels: app: node-exporter spec: nodeSelector: kubernetes.io/os: linux node-role.kubernetes.io/worker: containers: - name: node-exporter image: prom/node-exporter:v1.2.02.3 污点容忍配置apiVersion: apps/v1 kind: DaemonSet metadata: name: calico-node spec: selector: matchLabels: k8s-app: calico-node template: metadata: labels: k8s-app: calico-node spec: tolerations: - key: node-role.kubernetes.io/control-plane operator: Exists effect: NoSchedule - key: node-role.kubernetes.io/master operator: Exists effect: NoSchedule - key: node.kubernetes.io/not-ready operator: Exists effect: NoExecute三、DaemonSet更新策略3.1 滚动更新apiVersion: apps/v1 kind: DaemonSet metadata: name: fluentd spec: updateStrategy: type: RollingUpdate rollingUpdate: maxUnavailable: 1 maxSurge: 03.2 替换更新apiVersion: apps/v1 kind: DaemonSet metadata: name: legacy-daemon spec: updateStrategy: type: OnDelete四、DaemonSet部署与管理4.1 部署DaemonSetkubectl apply -f daemonset.yaml # 查看DaemonSet状态 kubectl get daemonset # 查看Pod分布 kubectl get pods -l namefluentd -o wide # 查看DaemonSet详情 kubectl describe daemonset fluentd4.2 滚动更新操作# 更新镜像版本 kubectl set image daemonset/fluentd fluentdfluentd:v1.13 # 查看更新状态 kubectl rollout status daemonset/fluentd # 暂停更新 kubectl rollout pause daemonset/fluentd # 恢复更新 kubectl rollout resume daemonset/fluentd # 回滚更新 kubectl rollout undo daemonset/fluentd4.3 查看历史版本kubectl rollout history daemonset/fluentd kubectl rollout history daemonset/fluentd --revision2五、DaemonSet最佳实践5.1 日志收集DaemonSetapiVersion: apps/v1 kind: DaemonSet metadata: name: filebeat namespace: logging spec: selector: matchLabels: app: filebeat template: metadata: labels: app: filebeat annotations: co.elastic.logs/module: docker spec: serviceAccountName: filebeat terminationGracePeriodSeconds: 30 containers: - name: filebeat image: elastic/filebeat:7.15.0 args: - -e - -c - /etc/filebeat.yml env: - name: ELASTICSEARCH_HOSTS value: elasticsearch:9200 securityContext: runAsUser: 0 volumeMounts: - name: config mountPath: /etc/filebeat.yml subPath: filebeat.yml - name: data mountPath: /usr/share/filebeat/data - name: varlibdockercontainers mountPath: /var/lib/docker/containers readOnly: true - name: varlog mountPath: /var/log readOnly: true volumes: - name: config configMap: name: filebeat-config - name: data hostPath: path: /var/lib/filebeat-data type: DirectoryOrCreate - name: varlibdockercontainers hostPath: path: /var/lib/docker/containers - name: varlog hostPath: path: /var/log5.2 节点监控DaemonSetapiVersion: apps/v1 kind: DaemonSet metadata: name: node-exporter namespace: monitoring spec: selector: matchLabels: app: node-exporter template: metadata: labels: app: node-exporter annotations: prometheus.io/scrape: true prometheus.io/port: 9100 spec: hostNetwork: true hostPID: true containers: - name: node-exporter image: prom/node-exporter:v1.2.0 args: - --path.procfs/host/proc - --path.sysfs/host/sys - --collector.filesystem.ignored-mount-points^/(dev|proc|sys|var/lib/docker/.|var/lib/kubelet/.)($|/) resources: limits: cpu: 100m memory: 100Mi requests: cpu: 100m memory: 100Mi volumeMounts: - name: proc mountPath: /host/proc readOnly: true - name: sys mountPath: /host/sys readOnly: true volumes: - name: proc hostPath: path: /proc - name: sys hostPath: path: /sys5.3 网络插件DaemonSetapiVersion: apps/v1 kind: DaemonSet metadata: name: flannel namespace: kube-system spec: selector: matchLabels: app: flannel template: metadata: labels: app: flannel spec: hostNetwork: true tolerations: - operator: Exists containers: - name: kube-flannel image: quay.io/coreos/flannel:v0.14.0 command: - /opt/bin/flanneld args: - --ip-masq - --kube-subnet-mgr securityContext: privileged: true env: - name: POD_NAME valueFrom: fieldRef: fieldPath: metadata.name - name: POD_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace volumeMounts: - name: run mountPath: /run/flannel - name: cni mountPath: /etc/cni/net.d - name: etc-flannel mountPath: /etc/flannel volumes: - name: run hostPath: path: /run/flannel - name: cni hostPath: path: /etc/cni/net.d - name: etc-flannel hostPath: path: /etc/flannel六、DaemonSet监控与调试6.1 状态检查# 查看DaemonSet状态 kubectl get ds # 查看DaemonSet详情 kubectl describe ds name # 查看Pod状态 kubectl get pods -l label -o wide # 查看节点上的Pod分布 kubectl get nodes -o jsonpath{range .items[*]}{.metadata.name}{\t}{.status.addresses[0].address}{\n}{end}6.2 日志查看# 查看所有Pod日志 kubectl logs -l appnode-exporter # 查看特定节点的Pod日志 kubectl logs -l appnode-exporter -n monitoring --field-selector spec.nodeNamenode-1 # 流式日志 kubectl logs -f pod-name6.3 调试命令# 在特定节点上执行命令 kubectl exec pod-name -- cat /var/log/messages # 查看节点信息 kubectl describe node node-name # 查看节点污点 kubectl get node node-name -o jsonpath{.spec.taints}七、性能优化7.1 资源限制配置apiVersion: apps/v1 kind: DaemonSet metadata: name: optimized-daemon spec: template: spec: containers: - name: daemon image: my-daemon resources: requests: cpu: 100m memory: 200Mi limits: cpu: 500m memory: 500Mi7.2 优先级配置apiVersion: scheduling.k8s.io/v1 kind: PriorityClass metadata: name: system-node-critical value: 2000001000 description: Priority class for system node critical components. --- apiVersion: apps/v1 kind: DaemonSet metadata: name: critical-daemon spec: template: spec: priorityClassName: system-node-critical containers: - name: daemon image: critical-component7.3 调度约束apiVersion: apps/v1 kind: DaemonSet metadata: name: constrained-daemon spec: template: spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: topology.kubernetes.io/zone operator: In values: - zone-a - zone-b containers: - name: daemon image: zone-aware-daemon八、常见问题与解决方案8.1 Pod无法调度到节点问题DaemonSet Pod在某些节点上Pending原因分析节点有污点且DaemonSet没有相应的容忍节点资源不足节点选择器不匹配解决方案kubectl describe node node-name | grep Taints kubectl get ds name -o yaml | grep tolerations8.2 更新卡住问题滚动更新卡在某个节点原因分析节点不可用Pod健康检查失败资源不足解决方案kubectl rollout status ds name kubectl describe pod pod-name kubectl rollout pause ds name8.3 镜像拉取失败问题DaemonSet无法拉取镜像原因分析镜像仓库不可达镜像名称或标签错误认证配置问题解决方案kubectl describe pod pod-name | grep -A 5 Events kubectl get secret regcred -o yaml九、总结DaemonSet是管理集群级守护进程的核心控制器适用于需要在每个节点上运行的系统级服务。通过合理配置可以实现节点级部署确保每个节点都运行守护进程自动扩展新节点加入时自动部署Pod滚动更新安全地更新守护进程版本节点隔离通过污点和容忍控制Pod部署位置建议在部署日志收集、监控代理、网络插件等系统服务时使用DaemonSet并结合资源限制和优先级配置确保系统稳定性。参考资料Kubernetes DaemonSet官方文档DaemonSet更新策略污点与容忍文档

相关文章:

Kubernetes DaemonSet深度解析:管理集群守护进程的最佳实践

Kubernetes DaemonSet深度解析:管理集群守护进程的最佳实践 一、DaemonSet概述 DaemonSet 是Kubernetes中用于在集群的每个节点上运行一个Pod副本的控制器。它确保所有节点(或满足特定条件的节点)都运行该Pod的一个实例。 1.1 DaemonSet应…...

昇腾CANN runtime Stream 调度引擎:从命令队列到 AI Core 的执行链路

用户看到的是一行 torch.nn.functional.softmax(x)&#xff0c;背后 runtime 要做&#xff1a;分配 Stream、入队命令、调度到 AI Core、等待完成、同步结果。如果这一行的延迟是 10μs&#xff0c;runtime 的调度开销必须 < 0.5μs——否则就是 5% 的性能损失。 runtime 的…...

Kubernetes StatefulSet深度解析:管理有状态应用的最佳实践

Kubernetes StatefulSet深度解析&#xff1a;管理有状态应用的最佳实践 一、StatefulSet概述 StatefulSet 是Kubernetes中用于管理有状态应用的控制器。它为Pod提供稳定的网络标识和持久化存储&#xff0c;确保Pod的有序部署、扩展和更新。 1.1 StatefulSet vs Deployment …...

JDK常用类与工具(速览版)

JDK常用类与工具&#xff08;速览版&#xff09;JDK&#xff08;Java Development Kit&#xff09;提供了丰富的标准库和实用工具&#xff0c;它们构成了Java开发者日常工作的基石。掌握这些核心类、集合框架、并发工具、IO/NIO库、日期时间API、正则表达式、异常处理机制、日志…...

GPS测速仪SpeedView 3.2.0汉化版 精准速度 实时测速工具

一款实时测速应用程序&#xff0c;英文名为“SpeedView”&#xff0c;安装到手机上就能够在开车的时候查看仪表盘车辆的速度是否准确 实时测速&#xff1a;通过GPS精准定位&#xff0c;实时显示当前速度、平均速度和最高速度&#xff0c;支持多种单位切换&#xff08;km/h、mp…...

阿里巴巴运营/2026年阿里巴巴1688店铺效果越来越差的3个核心原因(附解决方案)

阿里巴巴运营/2026年阿里巴巴1688店铺效果越来越差的3个核心原因&#xff08;附解决方案&#xff09;最近很多工厂老板跟我说&#xff0c;小峰老师&#xff0c;我这1688店铺怎么越做越没效果了&#xff1f;明明以前还能来几个询盘&#xff0c;现在越来越少&#xff0c;是不是16…...

CANN-ATB量化推理-昇腾NPU上W8A8量化为什么比W4A16更实用

Llama2-70B 权重 140GB&#xff0c;8 卡 TP 刚好放得下但没什么余量给 KV Cache。W8A8 量化把权重从 fp16 压到 int8&#xff0c;权重体积减半&#xff0c;4 卡就能跑 70B。W4A16 理论上压得更狠&#xff08;4 倍压缩&#xff09;&#xff0c;但精度损失在实际业务里往往不可接…...

CANN-HCCL-昇腾NPU分布式训练的通信库怎么选

8 卡 Atlas 800I A2 内部走 HCCS&#xff08;带宽 200GB/s&#xff09;&#xff0c;跨机走 RoCE&#xff08;带宽 100GB/s&#xff09;。HCCL 是昇腾NPU的通信库&#xff0c;对标 NVIDIA 的 NCCL。Tensor Parallel 和 Pipeline Parallel 的 All-Reduce、All-to-All 都靠它。 HC…...

nvm-setup安装步骤详解

nvm-setup是 Node Version Manager&#xff08;Node.js 版本管理器&#xff09;​ 的安装包。装了它&#xff0c;你就能在一台电脑上随时切换多个 Node.js 版本&#xff0c;做前端开发、跑不同项目的必备工具。一、准备工作安装包下载&#xff1a;https://wwbkk.lanzoub.com/iU…...

独立开发者如何利用 Taotoken 的 Token Plan 套餐以更优成本启动 AI 项目

&#x1f680; 告别海外账号与网络限制&#xff01;稳定直连全球优质大模型&#xff0c;限时半价接入中。 &#x1f449; 点击领取海量免费额度 独立开发者如何利用 Taotoken 的 Token Plan 套餐以更优成本启动 AI 项目 对于独立开发者或小型工作室而言&#xff0c;在项目启动…...

工业级大模型学习之路021:LangChain零基础入门教程(第四篇):文档加载与文本分块技术

一、文档处理是 RAG 系统的基石1.1 为什么文档处理决定了 RAG 系统的上限&#xff1f;RAG 系统的核心逻辑是 **"检索相关文档片段 → 喂给大模型生成回答"**&#xff0c;整个流程的质量完全依赖于文档处理环节&#xff1a;如果文档解析失败&#xff0c;再好的检索和生…...

深度学习安全帽佩戴检测系统

1 前言 今天学长向大家介绍一个机器视觉的毕设项目&#xff0c;深度学习安全帽佩戴检测系统 项目运行效果&#xff1a; 毕业设计 深度学习安全帽佩戴检测系统&#x1f9ff; 项目分享:见主页简介 1 课题背景 建筑工人头部伤害是造成建筑伤亡事故的重要原因。佩戴安全帽是防止…...

解决华硕灵耀X双屏Linux下扬声器不工作的问题

解决华硕灵耀X双屏Linux下扬声器不工作的问题系统信息解决方法0. 备份系统1. 修改内核启动参数&#xff0c;使用HDA驱动2. 测试修复方案3. 持久化修复方案系统信息 我的电脑是&#xff1a;华硕灵耀X双屏Pro UX5100HM 电脑声卡为&#xff1a;ALC294 操作系统为&#xff1a;Manj…...

第二周学习

学习&#xff08;一&#xff09;、低通滤波器1、原理&#xff08;为什么方波经过低通滤波器变成了正弦波&#xff09;傅里叶变换对于f&#xff08;t&#xff09;来说&#xff0c;只要f&#xff08;t&#xff09;是周期的&#xff0c;则一定可以将f&#xff08;t&#xff09;拆解…...

【Linux驱动开发】第12天:Linux设备树核心:树形结构+节点+属性 完整全解

目录 设备树树形结构概述节点&#xff08;Node&#xff09;全解&#xff1a;命名规范标准节点常用设备节点属性&#xff08;Property&#xff09;全解&#xff1a;类型核心属性总线专用属性标签与节点引用&#xff1a;设备树复用的核心常见错误与注意事项总结&#xff1a;驱动…...

2026年亲测AI写作辅助软件指南(高效定稿版)

为解决学术写作中效率与合规两大核心痛点&#xff0c;本文精选8款高适配性AI论文写作工具&#xff08;按综合优先级排序&#xff09;&#xff0c;围绕中文学术规范适配、真实参考文献生成、格式标准化、高性价比四大核心维度筛选&#xff0c;同时配套分场景精准选型方案与学术合…...

安全打底・能力拉满:我的 OpenClaw 龙虾生态 Skill 清单

2026开年AI圈两大热词&#xff1a;龙虾&#xff08;OpenClaw&#xff09;、Skill插件。龙虾是短期流量话题&#xff0c;热度来得快去得快&#xff1b;而Skill插件可一次部署、长期复用&#xff0c;真正落地到日常办公、协作、社交场景。 市面多数Skill推荐内容堆砌命令、实用性…...

HTML应用指南:利用GET请求获取智己汽车门店位置信息

智己汽车作为高端智能电动汽车品牌&#xff0c;深度融合先锋设计美学、纯电驱动技术、高阶智能驾驶与全场景出行服务&#xff0c;依托L7、LS7、LS6、L6等产品矩阵&#xff0c;打造兼具科技感与驾控乐趣的高端出行体验。在营销推广层面&#xff0c;智己摒弃传统4S店模式&#xf…...

2025大厂Java后端面试:RAG高频考点【干货】

根据近期&#xff08;2025-2026年&#xff09;牛客网上字节、腾讯、阿里、快手、京东等大厂的Java后端面经&#xff0c;RAG&#xff08;检索增强生成&#xff09;已高频结合传统Java八股进行考察。&#x1f4da; 面试问题分类与总结1. &#x1f3d7;️ RAG 基础概念与理解这是面…...

传统FPM项目怎么渐进式迁移到Swoole/Hyperf?

传统 FPM 项目渐进式迁移到 Swoole / Hyperf 完整方案下面是一份实战派迁移指南,不搞理想化"重写",而是一边赚钱一边换引擎。---一、先讲清楚:为啥要迁?要迁到哪?1.1 FPM 的痛点- 每个请求都要重新加载框架(Laravel 启动 30~80ms,Hyperf 启动后 0ms)- 不能保持长连…...

从Java全栈开发到云原生:一次真实的面试对话与技术剖析

从Java全栈开发到云原生&#xff1a;一次真实的面试对话与技术剖析 面试场景回顾 在一次真实的互联网大厂Java全栈开发岗位的面试中&#xff0c;面试官和应聘者展开了一场围绕技术栈、项目经验和系统设计的深入交流。面试官以专业严谨的态度&#xff0c;逐步引导应聘者展示其技…...

pod创建

Pod 由一个或多个紧密耦合的容器组成&#xff0c;它们之间共享网络、存储等资源&#xff0c;Pod 是 Kubernetes 中最小的工作单元&#xff0c;Pod 中的容器会一起启动和停止。1.创建pod一个pod只有一个业务容器kubectl logs mypod 命令用于查看名为 mypod 的 Pod 中唯一容器的标…...

第 2 篇:Agent 的三种工作模式,选错了事倍功半

系列简介&#xff1a;从零搭建一个多 Agent AI 助手&#xff0c;覆盖原理、实现、部署全链路。不讲空话&#xff0c;每篇都有可运行的代码。 项目地址&#xff1a;https://github.com/CodeMomentYY/LangGraph-Agent 本篇目标&#xff1a;理解 Agent 的三种工作模式&#xff0c;…...

为什么92%的Midjourney水效渲染失败?——解析v6.1+版本流体折射权重、noise scale与--s值的黄金三角关系

更多请点击&#xff1a; https://codechina.net 第一章&#xff1a;为什么92%的Midjourney水效渲染失败&#xff1f;——问题现象与根本归因 大量用户在使用 Midjourney v6 生成「水效渲染」&#xff08;Water Efficiency Rendering&#xff09;类提示词时遭遇高频失败——表现…...

Shutter Encoder:构建高效媒体工作流的FFmpeg图形化解决方案

Shutter Encoder&#xff1a;构建高效媒体工作流的FFmpeg图形化解决方案 【免费下载链接】shutter-encoder A professional video compression tool accessible to all, mostly based on FFmpeg. 项目地址: https://gitcode.com/gh_mirrors/sh/shutter-encoder 在数字媒…...

AI正在重构工程师岗位:被替代的不是“人”,而是低维度能力

过去很多人认为,AI更适合写文案、做客服、生成图片,而真正复杂的工程领域——尤其是工业、制造、自动化系统——依然离不开工程师。 但最近一个劳动仲裁案例,让越来越多工程技术人员开始重新思考这个问题: 一位从事测绘工作15年的工程师,因为企业全面导入AI自动化测绘系…...

嵌入式C语言开发中的三大致命陷阱

很多人刚开始学习C语言时,会觉得: 会指针 会结构体 会寄存器操作 能驱动外设 似乎就已经掌握了嵌入式开发。 但真正进入项目后才会发现: 嵌入式开发最难的,从来不是语法,而是“代码与硬件现实世界之间的耦合”。 同样一句代码: 在PC上可能只是运行错误; 在单片机里却可…...

Midjourney V6调色板设置失效的5大隐性原因:从--sref误用到色域压缩陷阱,一文终结色彩失真

更多请点击&#xff1a; https://codechina.net 第一章&#xff1a;Midjourney V6调色板设置失效的全局认知 Midjourney V6 引入了更严格的色彩语义解析机制&#xff0c;导致此前在 V5.x 中广泛使用的 --palette 参数&#xff08;如 --palette vibrant 或 --palette muted&…...

SQL 数据库从免费到付费选型实战:支撑真实规模产品的能力分析与选择指南

引言:为什么 SQL 数据库选型如此重要? 在当今数据驱动的时代,数据库是任何数字产品的核心基础设施。无论是初创公司的 MVP(最小可行产品),还是日活百万的成熟应用,数据库的选择直接影响着产品的性能、成本、可扩展性和开发效率。 对于技术决策者而言,面对琳琅满目的 …...

【小白快速上手】Windows 系统 OpenClaw v2.7.5 一键部署完整教程(包含安装包)

OpenClaw 一键安装完整教程&#xff08;2026 最新&#xff09; 适配系统&#xff1a;Windows10/11 64 位当前版本&#xff1a;v2.7.5&#xff08;虾壳云版&#xff09;文件大小&#xff1a;约 58.7MB下载地址&#xff1a;https://xiake.yun/api/download/package/16?promoCod…...