Skip to content

A Terraform-based IaC that provisions an Amazon EKS cluster on AWS with VPC, subnets, managed node groups, and add-ons (AWS Load Balancer Controller & Amazon EBS CSI Driver) using IRSA and Kubernetes RBAC best practices.

License

Notifications You must be signed in to change notification settings

adityawdubey/terraform-eks-infrastructure

Repository files navigation

Terraform-EKS-Infrastructure

A Terraform-based IaC that provisions an Amazon EKS cluster on AWS with VPC, subnets, managed node groups, and add-ons (AWS Load Balancer Controller & Amazon EBS CSI Driver) using IRSA and Kubernetes RBAC best practices.

blog: https://adityadubey.tech/deploying-an-amazon-eks-cluster-with-terraform

Table of Contents

Architecture

The infrastructure follows a resilient, secure, and highly available design spanning multiple AWS Availability Zones.

EKS Arch-Redacto Architecture

  • Public Subnets: These subnets house NAT Gateways that allow outbound internet access for resources in private subnets.
  • Private Subnets: These subnets contain the EKS worker nodes, providing an additional layer of security by isolating them from direct internet access.
  • Ingress Controller: Deployed as part of the EKS cluster to manage external access to services running within the cluster.

Technologies Used

  • Terraform: v1.11.3+
  • AWS ~> 5.0: EKS, VPC, IAM
  • Kubernetes: v2.0+

Features

  • Automated provisioning of an EKS cluster with VPC, subnets, and managed node groups
  • A highly available Multi-AZ VPC with public/private subnets and NAT gateways
  • Integration of critical EKS add-ons: CoreDNS, kube-proxy, AWS VPC CNI, and EBS CSI Driver
  • Kubernetes RBAC best practices for secure access control
  • Automated deployment of add-ons with proper IAM permissions
  • Deployed the AWS Load Balancer Controller with full Ingress support
  • Configured DNS + ALB Ingress to expose workloads securely
  • Cluster Autoscaler for automatic scaling of EKS node groups based on pod resource demands

Setup and Deployment

Prerequisites

  • Terraform CLI
  • AWS CLI
  • Kubernetes CLI

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/terraform-eks-infrastructure.git
cd terraform-eks-infrastructure
  1. Configure AWS CLI:
aws configure
  1. Create a terraform.tfvars file:
cp terraform.tfvars.example terraform.tfvars
  1. Customize the variables in terraform.tfvars

    Edit the terraform.tfvars file to tailor the variables to your specific needs.

Deployment

  1. Initialize Terraform:
terraform init
  1. Plan the deployment:
terraform plan
  1. Apply the configuration:
terraform apply

Usage

Accessing the Cluster

  1. Set the AWS CLI profile:

Run the following command to update your kubeconfig file, allowing kubectl to communicate with the EKS cluster:

aws eks update-kubeconfig --name <eks_cluster_name> --region <aws_region>
  1. Verify the connection:
kubectl get nodes

References

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

About

A Terraform-based IaC that provisions an Amazon EKS cluster on AWS with VPC, subnets, managed node groups, and add-ons (AWS Load Balancer Controller & Amazon EBS CSI Driver) using IRSA and Kubernetes RBAC best practices.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages