How to Setup EKS Cluster using Terraform
Posted By : Baldev Pal | 20-Jun-2022
Step1.Install the terraform on your local machine in ubuntu.
i. Install the unzip command.
$ sudo apt-get install unzip
ii. Download the latest version of terraform.
$ wget https://releases.hashicorp.com/terraform/1.0.7/terraform_1.0.7_linux_amd64.zip
iii. Extract the terraform file.
$ unzip terraform_1.0.7_linux_amd64.zip
iv. After the extract file Move the terraform file to this location /usr/local/bin.
$ sudo mv terraform /usr/local/bin/
v. check the terraform version.
$ terraform -v
Step2. Install the Pycharm or VS code to write terraform script.
Step3. Configure the AWS access and secret key in your local machines.
Step4. Start writing the terraform script for the EKS cluster setup.
i. Create a provider.tf file and configure the provider.tf file.
ii. Create a vpc.tf file and configure the VPC.
iii. Create a subnet.tf file and configure the subnet.
iv. Create an internet_gatway file and configure the internet_gatway.
v. Create a route_table file and configure the route_tabe.
vi. Create a route-table-association.tf file and configure the route-table-association.
vii. Create a nat_gateway.tf file and configure the nat_gateway.
viii. Create a eips.tf file and configure the Elastic ip.
ix. Create a eks.tf file and configure the EKS cluster.
x. Create an esk-node-groups.tf and configure the node group.
Step5.After creating the terraform script run the terraform init command.
$ terraform init
Step6.After running terraforms init command run the terraform apply command.
$ terraform apply
Step6. After Completing all resources, go to the aws account and check all resources.
Step7. Install kubectl in your VM or system, and Enable kubectl to communicate with your cluster by adding a new context to the kubectl config file in this command.
$ aws eks update-kubeconfig --profile profile_name --region region-code --name cluster-name
Step8 After connecting EKS cluster in your VM or system, check the worker node in this command.
$ kubectl get node
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Baldev Pal
Baldev is a DevOps Engineer. He has Knowledge of Linux, AWS, Docker, Jenkins, Kubernetes, Terraform, and Git.