This module deploys a complete publicly accessible EKS cluster in an empty AWS account. All that is required is to have an AWS account and user created, awscli
configured, and kubectl
installed.
By leveraging existing EKS and VPC modules from the terraform modules registry, this module itself is kept relatively simple.
Use the following terraform.auto.tfvars
to deploy a VPC, EIP, NAT gateway, routes, public/private subnets, security groups, NAT gateway, IAM roles & policies, EKS backplane, and two worker groups (one using on-demand instances, the other on spot instances).
NOTE: If you wish to deploy to an existing VPC, the VPC module can be disabled by adding
create_vpc = false
in the.tfvars
and then existing VPC referenced using theexisting_vpc_*
variables. Note that all resources that would have been created by the VPC module must be present.
# terraform.auto.tfvars
region = "us-east-1"
cluster_name = "demo"
kubernetes_version = "1.24"
ami_type = "BOTTLEROCKET_x86_64"
vpc_cidr = "10.0.0.0/16"
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
eks_managed_node_groups = [
{
name = "demo-on-demand"
instance_types = ["t3.small"]
min_size = 1
max_size = 1
desired_size = 1
},
{
name = "demo-spot"
instance_types = ["t3.small"]
capacity_type = "SPOT"
min_size = 1
max_size = 1
desired_size = 1
},
]
Once the file has been added, run terraform plan
to see what will be deployed. Then run terraform apply -auto-approve
to deploy the infrastructure. This will take around 10-15 minutes.
After the apply is complete, run the following to configure the Kubernetes client:
aws eks update-kubeconfig --name $(terraform output -raw cluster_name)
The nodes and pods can then be checked by running the following:
kubectl get nodes
kubectl get pod -A
Finally, run terraform destroy -auto-approve
when you are ready to destroy all the created resources.
Name | Version |
---|---|
terraform | ~> 1.3 |
aws | ~> 4.50 |
cloudinit | ~> 2.2 |
kubernetes | ~> 2.16 |
random | ~> 3.4 |
tls | ~> 4.0 |
Name | Version |
---|---|
aws | 4.51.0 |
random | 3.4.3 |
Name | Source | Version |
---|---|---|
eks | terraform-aws-modules/eks/aws | 19.5.1 |
vpc | terraform-aws-modules/vpc/aws | 3.19.0 |
Name | Type |
---|---|
random_string.suffix | resource |
aws_availability_zones.available | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
ami_type | The AMI type of the node groups. See EKS Node Group documentation for valid types. | string |
n/a | yes |
cluster_name | The name of the cluster. This will be given a random suffix. | string |
n/a | yes |
create_vpc | Set to false and use the existing_vpc_* variables to deploy to an existing VPC. | bool |
true |
no |
eks_managed_node_groups | A list of EKS managed node groups. | list(object({ |
n/a | yes |
existing_vpc_id | Pass the vpc_id of an existing VPC. | string |
null |
no |
existing_vpc_subnet_ids | Pass the subnet ids where the cluster will be deployed to. | list(string) |
[] |
no |
kubernetes_version | The version to deploy on the EKS cluster. | string |
n/a | yes |
private_subnets | n/a | list(string) |
n/a | yes |
public_subnets | n/a | list(string) |
[] |
no |
region | AWS region | string |
n/a | yes |
vpc_cidr | n/a | string |
"10.0.0.0/16" |
no |
Name | Description |
---|---|
cluster_endpoint | Endpoint for EKS control plane |
cluster_name | Kubernetes Cluster Name |
cluster_security_group_id | Security group ids attached to the cluster control plane |
region | AWS region |