vpc.tf
module "vpc" {source= "terraform-aws-modules/vpc/aws"version = "3.14.2"name = "wade-test-vpc"cidr = local.vpc.cidrazs= slice(data.aws_availability_zones.available.names, 0, 2)private_subnets = local.vpc.private_subnetspublic_subnets= local.vpc.public_subnetsenable_nat_gateway= truesingle_nat_gateway= trueenable_dns_hostnames = truepublic_subnet_tags = {"kubernetes.io/cluster/${local.cluster_name}" = "shared""kubernetes.io/role/elb"= 1}private_subnet_tags = {"kubernetes.io/cluster/${local.cluster_name}" = "shared""kubernetes.io/role/internal-elb"= 1}}
output.tf
output "cluster_id" {description = "EKS cluster ID"value= https://www.huyubaike.com/biancheng/module.wade-eks.cluster_id}output"cluster_endpoint" {description = "Endpoint for EKS control plane"value= https://www.huyubaike.com/biancheng/module.wade-eks.cluster_endpoint}output"region" {description = "EKS region"value= https://www.huyubaike.com/biancheng/local.region}output"cluster_name" {description = "AWS Kubernetes Cluster Name"value= https://www.huyubaike.com/biancheng/local.cluster_name}文件结构如下

文章插图
### 本文首发于博客园 https://www.cnblogs.com/wade-xu/p/16839468.html
部署配置aws account key/secret
Option 1: Export AWS access and security to environment variables
export AWS_ACCESS_KEY_ID=xxxexport AWS_SECRET_ACCESS_KEY=xxxOption 2: Add a profile to your AWS credentials file
aws configure# orvim ~/.aws/credentials[default]aws_access_key_id=xxxaws_secret_access_key=xxx可以使用如下命令来验证当前用的是哪个credentials
aws sts get-caller-identity
部署tf资源
terraform initterraform planterraform apply
成功之后有如下输出

文章插图
配置连接EKS集群#### Adding the cluster to your contextaws eks --region $(terraform output -raw region) update-kubeconfig \--name $(terraform output -raw cluster_name)使用同上面,需要下载kubectl
Example 命令:
kubectl cluster-infokubectl get nodes
感谢阅读 , 如果您觉得本文的内容对您的学习有所帮助,您可以打赏和推荐 , 您的鼓励是我创作的动力
推荐阅读
- Git 02: git管理码云代码仓库 + IDEA集成使用git
- 云顶之弈龙境探秘活动玩法是什么
- 云顶之弈玉龙猴王阵容怎么玩
- 乾象投资:基于JuiceFS 构建云上量化投研平台
- 云顶之弈s7.5神龙努努怎么玩
- 【Serverless】快速集成云函数HarmonyOS
- 京东云开发者|京东云RDS数据迁移常见场景攻略
- 华为云相册登陆 华为云相册登陆
- SpringCloud怎么迈向云原生?
- C++算法之旅、02 从木棒切割问题领悟二分法精髓