[英]Can we create EKS Cluster and Kubernetes deployment in a single terraform apply?
[英]How to create Kubernetes cluster on EKS with Terraform
我正在嘗試使用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.yaml
和kube_config.yaml
,但我可以看到創建了2個不同的文件: kubeconfig_eks-cluster-created-with-tf
和config-map-aws-auth_eks-cluster-created-with-tf.yaml
。
這里的問題似乎是你嘗試使用AssumedRole然后模塊嘗試執行本地exec,這就是它失敗的原因。
您將需要的是這樣的地方,您可以將“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中提供的任何名稱。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.