GitHub Repository
https://github.com/0xp4ck3t/K3s-Cluster-on-AWS-with-Terraform
You can download the files and test the setup with the following commands:
git clone https://github.com/0xp4ck3t/K3s-Cluster-on-AWS-with-Terraform.git
cd K3s-Cluster-on-AWS-with-Terraform
terraform init
terraform apply
Architecture
VPC Configuration
- CIDR Block:
10.10.0.0/16
- Description: This deployment will create a custom VPC that will be used by our resources.
Subnet Configuration
Private Subnets
- Subnet 1:
10.10.6.0/24
- Subnet 2:
10.10.7.0/24
- Description: These subnets are designated for the database.
Public Subnets
- Subnet 1:
10.10.1.0/24
- Subnet 2:
10.10.2.0/24
- Description: These subnets are designed for resources that need to interact with the internet, such as application servers or nodes within the K3s cluster.
Security Groups
- Private Subnet Security Group: Controls access to the private subnets, ensuring that only authorized traffic can reach the K3s database.
- Public Subnet Security Group: Manages access to the public subnets, allowing for controlled interaction with internet-facing resources.
Internet Gateway (IGW)
- Description: Provides internet access to resources within the public subnets, allowing for external communication and service access.
MySQL RDS
- Description: The K3s database is securely hosted within the private subnet, ensuring it is not directly accessible from the internet. It communicates with the instances in the public subnets, which utilize the external MySQL database hosted on Amazon RDS as the datastore for the K3s cluster.
Instances in Public Subnets
- Description: The instances will use Ubuntu Server as its operating system. The EC2 instances will be configured to run the K3s server, a lightweight Kubernetes distribution designed for resource-constrained environments. This server will manage the clusterā€™s resources and workloads.