You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在K8s集群中仅让试点节点更新DaemonSet镜像(无需双DaemonSet)

无需拆分DaemonSet的解决方案:节点标签+Keel金丝雀更新策略

完全不需要创建两个DaemonSet,通过以下操作就能实现仅3个试点节点更新镜像的需求:

1. 给试点节点打专属标识标签

先给目标3个工作节点添加用于区分试点的标签,比如update-pilot=true:

kubectl label nodes <node-name-1> <node-name-2> <node-name-3> update-pilot=true

2. 配置DaemonSet的Keel注解

修改现有DaemonSet的元数据注解,利用Keel的金丝雀更新特性,指定仅匹配标签的节点拉取新版本镜像:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: your-daemonset-name
  annotations:
    keel.sh/policy: canary          # 启用金丝雀更新模式
    keel.sh/canary-nodes: "update-pilot=true"  # 仅对带该标签的节点执行更新
    keel.sh/match-tag: "latest"     # 根据你的镜像版本策略调整,比如用semver规则
    keel.sh/poll: "true"            # 开启自动轮询镜像仓库以检测新版本
spec:
  selector:
    matchLabels:
      app: your-app-label
  template:
    metadata:
      labels:
        app: your-app-label
    spec:
      nodeSelector:
        worker: "true"              # 保持原有的worker节点选择规则
      containers:
      - name: your-container-name
        image: your-image-repo/your-image:current-old-tag

3. 效果验证

当新版本镜像推送到仓库后,Keel只会触发带有update-pilot=true标签的3个节点上的Pod更新镜像;其余17个未打标签的worker节点会继续运行旧版本,不会受到影响。

扩展说明

  • 如果后续需要扩大试点范围,只需给更多节点打上update-pilot=true标签,Keel会自动在这些节点上完成镜像更新。
  • 若要全量更新所有节点,只需将keel.sh/canary-nodes注解移除,或者添加keel.sh/canary-weight: "100"即可。

内容的提问来源于stack exchange,提问作者Anton Schleenvoigt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 12:55:19