繁体   English   中英

使用 CloudFormation 通过 Fargate 安装 EKS

[英]Install EKS with Fargate using CloudFormation

我可以使用 Cloudformation 创建 EKS 集群。 我还可以拥有一个“节点组”和 EC2 的 + 自动缩放功能。 另一方面,我还可以安装 FargateProfile 并创建“fargate 节点”。 这很好用。 但我只想使用 fargate(没有 EC2 节点等)。 在这里,我需要在 Fargate 上托管我的管理 pod(在 kube-system 中)。 我该如何管理这个?

我试过这个:

Resources:
  FargateProfile:
    Type: AWS::EKS::FargateProfile
    Properties:
      ClusterName: eks-test-cluster-001
      FargateProfileName: fargate
      PodExecutionRoleArn: !Sub 'arn:aws:iam::${AWS::AccountId}:role/AmazonEKSFargatePodExecutionRole'
      Selectors:
        - Namespace: kube-system
        - Namespace: default
        - Namespace: xxx
      Subnets:
        !Ref Subnets

但是我的管理 pod 仍然在 EC2 上。 可能我错过了一些标签,但这是要走的路吗? 一些标签是用哈希生成的,所以我不能只将它们添加到我的 fargateProfile 中。

使用 eksctl 似乎是可能的:在上面的命令中添加 --fargate 选项会创建一个没有节点组的集群。 但是,eksctl 创建了一个 pod 执行角色、一个用于 default 和 kube-system 命名空间的 Fargate 配置文件,并修补了 coredns 部署,以便它可以在 Fargate 上运行。

但是如何在 CloudFormation 中做到这一点?

我也尝试过使用标签,但后来在 CloudFormation 中出现错误:模型validation failed (#: extraneous key [k8s-app] is not permitted)

我没有复制这个模板。 但是由于我遇到了与模型验证失败类似的问题,如果您使用标签,请确保您的格式为 Key: XXX Value: XXX

以下配置适用于我,但在手动修补核心 DNS 部署文件之后。 关于如何通过云形成在 Fargate 上运行核心 DNS 的任何想法。

Resources:
  FargateProfile:
    Type: 'AWS::EKS::FargateProfile'
    DependsOn: ControlPlane
    Properties:
      ClusterName: my-cluster
      FargateProfileName: fp-default
      PodExecutionRoleArn: !GetAtt 
        - FargatePodExecutionRole
        - Arn
      Selectors:
        - Namespace: default
        - Namespace: kube-system
          Labels:
            - Key: k8s-app
              Value: kube-dns

CloudFormation 模板是正确的。 您需要更改 CoreDNS 部署的注释 - 删除注释:

Annotations: eks.amazonaws.com/compute-type: ec2

为此,请使用以下命令:

kubectl patch deployment coredns \
    -n kube-system \
    --type json \
    -p='[{"op": "remove", "path": "/spec/template/metadata/annotations/eks.amazonaws.com~1compute-type"}]'

文档参考: https ://docs.aws.amazon.com/eks/latest/userguide/fargate-getting-started.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM