-
Install Terraform
brew tap hashicorp/tapbrew install hashicorp/tap/terraformterraform -install-autocomplete
-
Install AWS CLI
- Setup
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEY
- Setup
-
Create VPC, the only thing important here is CIDR
-
Create an internet gateway, this is required from private subnet.
-
You need to create 4 subnets, 2 private and 2 public on a given availability zone
- Important tags on private subnet resources required by EKS
Namekubernetes.io/role/internal-elb: This is for kubernetes to discover subnets where internal load balancers will be created.kubernetes.io/cluster/sample: This tag indicates the subset ownership. The value equalownedmeans the resources are execlusively owned by the cluster and are not shared
- For public subnet, you need to set the property
map_public_ip_on_launchto ```true`` and the following tags:Namekubernetes.io/role/elb: This tells Kubernetes to create an extrernal load balancers this subnetkubernetes.io/cluster/sample: Same as above
- Important tags on private subnet resources required by EKS
-
Create NAT Gateway. This is used for providing internet egress to private subnet. This needs an Elastic IP first before you create the terraform resource. Need to associate the NAT gateway to the public subnet that has internet gateway configured.
-
Create route tables
- One public and one private route table. The public route table will have internet gateway and private route table will have nat gateway.
- Associate route tables with subnets
-
Now the fun part, creating the EKS
- Step 1: Create an IAM Role and role policy so that clutser can assume role for service eks.amazonaws.com
- Step 2: Create a policy attachement with the role created in the previous step
- Step 3: Create AWS EKS resource with the following
- Role
- VPC config with subnets for networking so that EKS cluster can create nodes and load balancer
- Policy
-
Create IAM role and policies for EC2 nodes and attach the following policies
AmazonEKSWorkerNodePolicy: This grant access to EC2 and EKSAmazonEKS_CNI_Policy: For networking
-
Configure managed node groups - AWS will manage the life cycle, auto scaling group uses it to scale the cluster
- Important component is
scaling_config: Define min and max number of nodes max_unavailable: Maximum number of allowed unavailable nodes during upgrade- Mind you this configuration is not enough for auto scaling, you need to intall cluster autoscaler
- You can also create some label and taints if required
- Important component is
-
Create OIDC (OpenID) which will allow IAM permissions for service accounts
- Get the certificate associated with EKS
- Create OpenID connect provider
-
Test the provider
- Create a policy document this role will be associated with EKS service account
- Create IAM role associated with the policy document
- Give permissions to do something
- Create policy attachement
- Output something to test
-
Perform
terraform initto download the plugins and providers -
Perform
terraform applyto create the infrastructure
-
Notifications
You must be signed in to change notification settings - Fork 0
gtinside/eks-via-terraform
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
About
As the name suggests
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published