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

如何阻止Daemonset调度至混合EKS集群的Fargate节点?

混合EKS集群阻止Daemonset调度到Fargate节点的方案

方法一:自动为Fargate节点添加污点

EKS的Fargate虚拟节点默认带有标签eks.amazonaws.com/compute-type: fargate,可以通过Mutating Admission Webhook自动为这类节点添加污点,阻止无对应容忍配置的Daemonset Pod调度过来:

  • 无需从零开发控制器,可借助现有工具如Kyverno或OPA Gatekeeper快速实现。例如用Kyverno的ClusterPolicy规则:
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: add-fargate-taint
spec:
  rules:
  - name: taint-fargate-nodes
    match:
      resources:
        kinds:
        - Node
        selector:
          matchLabels:
            eks.amazonaws.com/compute-type: fargate
    mutate:
      patchStrategicMerge:
        spec:
          taints:
          - key: node.kubernetes.io/fargate
            effect: NoSchedule
  • 该规则会监听节点的创建/更新事件,自动为Fargate节点注入node.kubernetes.io/fargate: NoSchedule污点,所有未配置该污点容忍的Daemonset Pod将无法调度到这些节点。

方法二:自动为所有Daemonset添加节点反亲和性(无需修改第三方Helm Chart)

通过Mutating Admission Webhook,自动给所有Daemonset的Pod模板添加节点反亲和规则,拒绝调度到Fargate节点:

  • 同样可用Kyverno实现,无需手动修改任何Daemonset配置(包括第三方Helm Chart部署的):
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: daemonset-avoid-fargate
spec:
  rules:
  - name: add-anti-affinity
    match:
      resources:
        kinds:
        - DaemonSet
    mutate:
      patchStrategicMerge:
        spec:
          template:
            spec:
              affinity:
                nodeAffinity:
                  requiredDuringSchedulingIgnoredDuringExecution:
                    nodeSelectorTerms:
                    - matchExpressions:
                      - key: eks.amazonaws.com/compute-type
                        operator: NotIn
                        values:
                        - fargate
  • 该策略会自动为所有Daemonset添加节点选择规则,强制Pod仅调度到非Fargate类型的节点上。

补充说明

  • 无需从零开发自定义控制器,上述两种方案均基于Kubernetes原生的准入控制机制,借助成熟工具即可快速落地。
  • 你用Fargate托管cluster-autoscaler的设计是合理的,能有效避免EC2节点滚动更新时的死锁问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.22 07:33:13