This is a Terraform template for launching a Kubernetes cluster on AWS at low cost.
It is derived from a tool I use daily for personal and testing environment.
If you want to use K8s at a low price, please use.
Tool | Version |
---|---|
Terraform | v1.10.4 |
Platform | WSL2 (linux_amd64) |
OS | Amazon Linux 2023 |
Kubernetes Version | v1.31 |
AWS Region | ap-northeast-1 (default) |
- Creates a VPC, subnet, internet gateway, and route table
- Configures security groups for SSH and Kubernetes API access
- Launches a single EC2 instance as the Kubernetes master node
- Runs
install-k8s.yml
(Ansible Playbook) via Terraform provisioner - Installs:
- containerd (v2.0.2)
- runc (v1.2.4)
- CNI plugins (v1.6.2)
- Kubernetes components (
kubeadm
,kubelet
,kubectl
)
- Initializes the Kubernetes cluster using
kubeadm
- Applies the Flannel CNI for networking
Step | Description |
---|---|
Containerd Installation | Downloads and extracts containerd |
runc Installation | Downloads and installs runc |
CNI Plugins Installation | Downloads and extracts CNI plugins to /opt/cni/bin |
System Configuration | Loads kernel modules (overlay, br_netfilter) and sets sysctl parameters |
Package Installation | Installs kubeadm , kubelet , kubectl from the Kubernetes repo |
Cluster Initialization | Runs kubeadm init with Flannel pod network CIDR |
kubeconfig Setup | Copies admin kubeconfig to both root and ec2-user's home directory |
Network Plugin Setup | Applies Flannel manifest |
git clone https://github.com/7csc/k8s-launch-pad.git
cd k8s-launch-pad
- Place your public key (e.g., ~/.ssh/id_rsa.pub) in the location defined in terraform.tfvars
- Update terraform.tfvars with your:
- AWS region
- Key pair name
- Allowed IP for SSH (ssh_allowed_ip)
terraform init
terraform plan -var-file=terraform.tfvars
terraform apply -var-file=terraform.tfvars
terraform destroy -var-file=terraform.tfvars