简体   繁体   English

如何使用Terraform在EKS上创建Kubernetes集群

[英]How to create Kubernetes cluster on EKS with Terraform

I'm trying to create K8s cluster on Amazon EKS with Terraform. 我正在尝试使用Terraform在Amazon EKS上创建K8s群集。 All the code is on github: https://github.com/amorfis/aws-eks-terraform 所有代码都在github上: https//github.com/amorfis/aws-eks-terraform

access_key and secret are configured for the user which has the necessary policy, as seen in README.md. access_key和secret是为具有必要策略的用户配置的,如README.md中所示。

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

I also checked in the modules, and it looks like it should create 2 files: aws_auth_configmap.yaml and kube_config.yaml , but instead I can see 2 different files created: kubeconfig_eks-cluster-created-with-tf and config-map-aws-auth_eks-cluster-created-with-tf.yaml . 我还检查了模块,它看起来应该创建2个文件: aws_auth_configmap.yamlkube_config.yaml ,但我可以看到创建了2个不同的文件: kubeconfig_eks-cluster-created-with-tfconfig-map-aws-auth_eks-cluster-created-with-tf.yaml

The problem here seems to be that you try to use an AssumedRole but then the module attempts to do local exec which is why it fails. 这里的问题似乎是你尝试使用AssumedRole然后模块尝试执行本地exec,这就是它失败的原因。

What you would be required is something like this where you add "kubeconfig_aws_authenticator_env_variables" to the module taken from the official example like below - 您将需要的是这样的地方,您可以将“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"
  }
}

Note: The following is added - 注意:添加以下内容 -

 kubeconfig_aws_authenticator_env_variables = {
    AWS_PROFILE = "NameOfProfile"
  }

Replace the value of profile with whatever name you have provided with in the ~/.aws/config. 将〜配置文件的值替换为〜/ .aws / config中提供的任何名称。

暂无
暂无

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

相关问题 我们可以在单个 terraform 应用程序中创建 EKS 集群和 Kubernetes 部署吗? - Can we create EKS Cluster and Kubernetes deployment in a single terraform apply? 使用 Terraform 通过 aws_eks_cluster 创建 EKS 集群后如何公开 kubeconfig 文件? - How to expose kubeconfig file after create an EKS cluster by aws_eks_cluster with Terraform? 如何使用 terraform 创建具有公共和私有 su.net 的 EKS 集群? - How to create an EKS cluster with public and private subnets using terraform? 如何使用 Fargate 创建 AWS Kube.netes 集群 (EKS)? - How to create a AWS Kubernetes cluster (EKS) using Fargate? 如何让 terraform 删除包含 kubernetes 创建的 AWS 资源的 EKS 集群? - How to make terraform delete an EKS cluster including the AWS resources created by kubernetes? 如何使用 terraform 部署简约的 EKS 集群? - How to deploy a minimalistic EKS cluster with terraform? 使用 Terraform,如何使用 Fargate 创建 AWS Kubernetes 集群? - Using Terraform, how would I create a AWS Kubernetes cluster with Fargate? AWS EKS NodeGroup“创建失败”:实例未能加入 kubernetes 集群 - AWS EKS NodeGroup "Create failed": Instances failed to join the kubernetes cluster AWS EKS Terraform - 未找到标记“KubernetesCluster”或“kubernetes.io/cluster/...” - AWS EKS Terraform - Tag "KubernetesCluster" nor "kubernetes.io/cluster/..." not found EKS:kubernetes 集群中的不健康节点 - EKS: Unhealthy nodes in the kubernetes cluster
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM