【问题标题】:How to create Kubernetes cluster on EKS with Terraform如何使用 Terraform 在 EKS 上创建 Kubernetes 集群
【发布时间】:2019-07-08 22:48:35
【问题描述】:

我正在尝试使用 Terraform 在 Amazon EKS 上创建 K8s 集群。所有代码都在github上:https://github.com/amorfis/aws-eks-terraform

access_key 和 secret 是为具有必要策略的用户配置的,如 README.md 中所示。

我运行terraform init,然后运行terraform apply,但它失败并出现以下错误: module.eks.null_resource.update_config_map_aws_auth (local-exec): error: unable to recognize "aws_auth_configmap.yaml": Unauthorized

我还检查了模块,它看起来应该创建 2 个文件:aws_auth_configmap.yamlkube_config.yaml,但我可以看到创建了 2 个不同的文件:kubeconfig_eks-cluster-created-with-tfconfig-map-aws-auth_eks-cluster-created-with-tf.yaml

【问题讨论】:

    标签: amazon-web-services kubernetes terraform amazon-eks


    【解决方案1】:

    这里的问题似乎是您尝试使用 AssumedRole 但模块尝试执行本地执行,这就是它失败的原因。

    你需要的是这样的东西,你可以在其中添加 “kubeconfig_aws_authenticator_env_variables”到从官方示例中获取的模块,如下所示 -

    module "my-cluster" {
      source       = "terraform-aws-modules/eks/aws"
      cluster_name = "my-cluster"
      kubeconfig_aws_authenticator_env_variables = {
                 AWS_PROFILE = "NameOfProfile"
      }
      subnets      = ["subnet-abcde012", "subnet-bcde012a", "subnet-fghi345a"]
      vpc_id       = "vpc-1234556abcdef"
    
      worker_groups = [
        {
          instance_type = "m4.large"
          asg_max_size  = 5
        }
      ]
    
      tags = {
        environment = "test"
      }
    }
    

    注意:添加以下内容-

     kubeconfig_aws_authenticator_env_variables = {
        AWS_PROFILE = "NameOfProfile"
      }
    

    将配置文件的值替换为您在 ~/.aws/config 中提供的任何名称。

    【讨论】:

      猜你喜欢
      • 2021-07-08
      • 2021-04-13
      • 2020-08-20
      • 2021-07-09
      • 2018-10-09
      • 2022-08-09
      • 2020-10-26
      • 2019-03-30
      • 2021-07-07
      相关资源
      最近更新 更多