DEBUG.WIKI
PanstarCloud:部署应用,接入 AI,云服务器与 AI 网关
晚安云;香港 CN2 ¥15/月
V.PS:让项目靠近用户,亚太、欧洲、北美 KVM VPS

解决 Kubernetes DaemonSet 报错 0/N nodes available: node(s) had untolerated taint 的排查指南

排查与解决 Kubernetes DaemonSet Pod 无法调度到 Master/Control-plane 节点提示 untolerated taint 的完整方案。

问题现象

在 Kubernetes 集群部署系统级监控组件(如 Prometheus Node-Exporter、Filebeat、Calico CNI)的 DaemonSet 时,发现 DaemonSet 期望的副本数与实际调度运行数不符。查看 Pod 事件记录:

Events:
  Type     Reason            Age   From               Message
  ----     ------            ----  ----               -------
  Warning  FailedScheduling  15s   default-scheduler  0/3 nodes are available: 1 node(s) had untolerated taint {node-role.kubernetes.io/control-plane: }, 2 node(s) had untolerated taint {node-role.kubernetes.io/master: NoSchedule}.

Master / 控制面节点上没有跑起对应的 DaemonSet Pod。

触发根因

  1. Kubernetes 为了保护集群核心控制平面组件(API Server、ETCD、Controller-Manager)的稳定性,默认会对 Master 节点打上 NoSchedule 污点(Taint)。
  2. 普通的工作负载(Workload)默认不会被调度到带污点的节点上。
  3. DaemonSet YAML 模板中缺少对应的**污点容忍(Tolerations)**声明。

解决步骤与操作命令

步骤一:查看 Master 节点的具体污点定义

运行命令获取节点上的污点键值:

kubectl describe nodes | grep -i taints

常见污点键名包括:

  • node-role.kubernetes.io/control-plane:NoSchedule
  • node-role.kubernetes.io/master:NoSchedule

步骤二:在 DaemonSet Spec 中添加对控制面污点的容忍

编辑 DaemonSet YAML,在 spec.template.spec 区域追加 tolerations:

spec:
  template:
    spec:
      tolerations:
      # 容忍旧版 master 污点
      - key: node-role.kubernetes.io/master
        operator: Exists
        effect: NoSchedule
      # 容忍新版 control-plane 污点
      - key: node-role.kubernetes.io/control-plane
        operator: Exists
        effect: NoSchedule

若该 DaemonSet 属于底层网络插件(如 CNI)必须运行在所有物理节点上,直接容忍所有污点:

tolerations:
- operator: Exists # 容忍集群内的一切污点

步骤三:应用配置生效

kubectl apply -f daemonset.yaml

验证确认

再次查看 DaemonSet 的运行状况:

kubectl get ds -n monitoring

DESIRED 与 CURRENT、READY 数量完全对齐,Master 节点上的 Pod 成功被拉起并进入 Running 状态。