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

Kubernetes中DaemonSet配置多容忍度实现多节点部署可行吗?

Kubernetes DaemonSet多标签与污点配置说明

当然可以给DaemonSet配置多个节点标签选择规则和多个污点容忍度,以此实现跨多个节点部署。你提供的配置存在格式错误,下面是正确的配置方式:

错误点说明

你在tolerations的单个条目里写了多个key值,这不符合Kubernetes的API规范——每个容忍度条目只能对应一个污点的key,多个污点需要拆分成多个独立的tolerations对象。

正确配置示例

1. 容忍多个节点污点

如果需要容忍sample-node=true和example-node=true这两个NoSchedule类型的污点,配置如下:

spec:
  tolerations:
    - key: "sample-node"
      operator: "Equal"
      effect: "NoSchedule"
      value: "true"
    - key: "example-node"
      operator: "Equal"
      effect: "NoSchedule"
      value: "true"

2. 匹配多个节点标签

如果要让DaemonSet部署到指定标签的节点,可根据需求选择两种配置方式:

方式一:简单逻辑与匹配(同时满足多个标签)

spec:
  template:
    spec:
      nodeSelector:
        node-role: worker
        env: production

方式二:复杂逻辑匹配(支持或/与组合)

比如匹配带有env=production或env=staging标签的节点:

spec:
  template:
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: env
                operator: In
                values:
                - production
                - staging

关键说明

  • 每个tolerations条目对应一个污点的容忍规则,多个污点必须定义多个独立条目。
  • 节点标签匹配可通过nodeSelector实现简单的"且"逻辑,或通过nodeAffinity实现更复杂的节点选择逻辑。

内容的提问来源于stack exchange,提问作者Lakshmi Narayanan

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.11 17:22:33