This repository contains infrastructure code designed to easily deploy Kubernetes v1.31 cluster with Calico CNI v3.28.0 on AWS EC2 instances (Ubuntu 22.04 LTS) using Terraform. The infrastructure is automatically configured through Terraform's apply command, installing Kubernetes on EC2 instances.
- Kubernetes: v1.31
- CNI: Calico v3.28.0
- OS: Ubuntu 22.04 LTS
- Cloud: AWS
- IaC: Terraform 1.8+
- Master Node: Minimum t3.medium (2 vCPU, 4GB RAM)
- Worker Node: Minimum t3.medium (2 vCPU, 4GB RAM)
- Storage: Minimum 30GB gp3 EBS volume
- Network: Private subnet within VPC
- Automatic Kubernetes v1.31 cluster configuration
- Automatic Calico CNI v3.28.0 installation and configuration
- Enhanced SSH security (port modification)
- Automatic Seoul timezone setting
- Automatic worker node joining
- Master Node: Runs control plane components
- Worker Nodes: Runs application workloads
- Networking: Pod network configuration via Calico CNI
- Storage: Persistent storage through gp3 EBS volumes
The purpose of this project is to build an environment that easily deploys and manages Kubernetes clusters within AWS infrastructure using Terraform. Users can automatically create and manage Kubernetes clusters through Terraform's apply command.
- Automate Kubernetes v1.31 cluster deployment on AWS infrastructure using Terraform
- Configure SSH port changes and Seoul timezone (Asia/Seoul) during EC2 instance creation
- Automate infrastructure deployment and management for Master node and Worker nodes
- Simplify infrastructure maintenance through Terraform variable files
First, you need Terraform installed. AWS CLI is also required, along with properly configured AWS credentials.
aws configure # Register AWS credentials
aws configure list # List AWS credentials
git clone https://github.com/dongkoony/k8s-aws
cd k8s-aws
Modify the terraform.tfvars
file according to your environment. Refer to the variable configuration guide for detailed settings.
region = "YOUR-REGION" # AAWS Region. ex: ap-northeast-2 (Seoul)
availability_zone = "YOUR-AZ" # Availability Zone. ex: ap-northeast-2a
ami_id = "YOUR-AMI-ID" # AMI ID (k8s installation script based on Ubuntu 22.04 LTS)
master_instance_type = "YOUR-MASTER-TYPE" # Master node instance type. ex: t3.medium
node_instance_type = "YOUR-WORKER-TYPE" # Worker node instance type. ex: t3.medium
worker_instance_count= "YOUR-WORKER-COUNT" # Number of worker nodes. ex: 2
volume_size = "YOUR-VOLUME-SIZE" # Root volume size(GB). ex: 30
volume_type = "YOUR-VOLUME-TYPE" # Volume type. ex: gp3
key_name = "YOUR-KEY-NAME" # SSH key pair name
private_key_path = "YOUR-KEY-PATH" # Private key path. ex: /home/ubuntu/your-key.pem
private_key_name = "YOUR-KEY-FILE-NAME" # Private key filename. ex: your-key.pem
terraform init # Initialize
terraform plan # Check execution plan
terraform apply --auto-approve # Deploy infrastructure
terraform destroy --auto-approve # Remove infrastructure
- Optimized for Kubernetes v1.31 and Calico v3.28.0
- Tested only on Ubuntu 22.04 LTS
- Recommended instance type: t3.medium or higher
- Recommended volume type: gp3
Check the following when issues occur:
- Verify AWS credentials are properly configured
- Confirm required AWS permissions are in place
- Ensure instance type and volume size meet requirements
- Verify network settings are correct
This project is licensed under the MIT License. See the LICENSE file for details.
For additional inquiries or contributions, please create an issue or submit a pull request.