【问题标题】:How to add taint to AWS EKS node Group?如何将污点添加到 AWS EKS 节点组?
【发布时间】:2021-02-06 05:10:30
【问题描述】:

我正在启动并运行一个 AWS EKS 集群。我需要添加带有污点的节点组。这样我就可以在 EKS 中的特定节点组上部署 pod。我可以使用以下命令在 azure AKS 中执行此操作。

az aks nodepool add --resource-group rg-xx --cluster-name aks-xxx --name np1 --node-count 1 --node-vm-size xxx --node-taints key=value: NoSchedule --no-wait

如何在 AWS EKS 中实现相同的功能?

【问题讨论】:

    标签: amazon-web-services kubernetes devops azure-aks


    【解决方案1】:

    你可以使用这个例子:https://eksctl.io/usage/autoscaling/#scaling-up-from-0

    nodeGroups:
    - name: ng1-public
      ...
      labels:
        my-cool-label: pizza
      taints:
        feaster: "true:NoSchedule"
    

    【讨论】:

    • 感谢您的回复。我不想使用 eksctl .. 有没有其他方法可以做到这一点,例如从 UI 或 AWS CLI 命令?
    【解决方案2】:

    自 2021 年 4 月起,EKS 托管的 NodeGroup 支持 Kubernetes 污点:https://docs.aws.amazon.com/eks/latest/userguide/node-taints-managed-node-groups.html

    【讨论】:

      【解决方案3】:

      如果您将 eksctl 与托管节点组一起使用,您可以修补引导脚本以实现您想要的。

      managedNodeGroups:
        - name: batch
          preBootstrapCommands:
            - sed -i '/^KUBELET_EXTRA_ARGS=/a KUBELET_EXTRA_ARGS+=" --register-with-taints=tier=batch:NoSchedule"' /etc/eks/bootstrap.sh
          tags:
            k8s.io/cluster-autoscaler/node-template/taint/tier: "batch:NoSchedule"
      

      这依赖于https://github.com/awslabs/amazon-eks-ami/blob/189baaa77c14120a1b62c42bacced17ba429466b/files/bootstrap.sh#L107 处的代码不会发生太大变化。

      您可以类似地启用 docker 网桥(又名--enable-docker-bridge

          preBootstrapCommands:
            - sed -i 's/^ENABLE_DOCKER_BRIDGE=.*/ENABLE_DOCKER_BRIDGE=true/' bootstrap.sh
      

      实际 EKS 支持的跟踪问题位于 https://github.com/aws/containers-roadmap/issues/864,此解决方案来自评论

      【讨论】:

        【解决方案4】:

        我没有看到 eksctl 作为问题中的要求,所以我添加了另外 2 个选项。

        选项 1 - AWS CLI

        来自here

        Kubernetes 节点污点可以应用于新的和现有的托管节点 使用 AWS 管理控制台或通过 Amazon EKS API 的组

        以下是使用 AWS CLI 创建带有污点的节点组的示例:

        aws eks create-nodegroup \
         --cli-input-json '
        {
          "clusterName": "my-cluster",
          ...
          "taints": [
             {
                 "key": "dedicated",
                 "value": "gpuGroup",
                 "effect": "NO_SCHEDULE"
             }
           ],
        }'
        

        选项 2 - Terraform

        如果您使用的是 Terraform,那么 Hashicorp AWS provider 使用 taint configuration block 支持开箱即用的污点:

        resource "aws_eks_node_group" "stateless-ng" {
          cluster_name    = aws_eks_cluster.main.name
          node_group_name = "stateless-ng"
          .
          .
          .
          
          # Block 1 
          taint {
            key = "stateless-no-schedule"
            value  = "true"
            effect = "NO_SCHEDULE"
          }
        
          # Block 2    
          taint {
            key = "stateless-no-execute"
            value  = "true"
            effect = "NO_EXECUTE"
          }
        }
        

        请注意,每个污点都需要在一个单独的配置块中进行配置。

        【讨论】:

          【解决方案5】:

          您可以在 AWS:EKS:NodeGroup Cloudformation 模板中添加这样的内容

          Taints:
            - Effect: "NO_SCHEDULE"
              Key: !Ref NodeGroupName
              Value: "dedicated"
          

          【讨论】:

            猜你喜欢
            • 2020-04-23
            • 2021-03-16
            • 1970-01-01
            • 2020-12-17
            • 2019-09-17
            • 2021-07-31
            • 2021-01-12
            • 2020-12-03
            • 2019-10-22
            相关资源
            最近更新 更多