[英]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.yaml
和kube_config.yaml
,但我可以看到创建了2个不同的文件: kubeconfig_eks-cluster-created-with-tf
和config-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.