Skip to content
Terraform code for "Kubernetes the (right) hard way (AWS)"
HCL Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
.gitignore
.pre-commit-config.yaml
LICENSE
README.md
main.tf
outputs.tf
provider.tf
terraform-k8s-real-hard-way.png
userdata-bastion.tpl
userdata-etcd.tpl
userdata-master.tpl
userdata-worker.tpl
variables.tf
version.tf

README.md

Terraform Kubernetes the (right) hard way on AWS!

This little project creates the infrastructure in Terraform for my blog post Kubernetes the (right) hard way on AWS.

AWS CDK Python code available 🔗 HERE

You can practice creating a multi node K8s Cluster yourself for training purposes or CKA exam preparation.

Alt text

Requirements

  • Existing AWS Route53 Public Hosted Zone

Features

  • Terraform 0.12
  • 1x VPC, 3x Public Subnets, Route Tables, Routes
  • 3x Worker Nodes (editable)
  • 3x Master Nodes (editable)
  • 3x Etcd Nodes (editable)
  • Genertes AWS Key Pair for instances
  • Route53 Records for internal & external IPv4 addresses
  • LoadBalancer for Master Node (external kubectl access)
  • Gets most recent Ubuntu AMI for all regions
  • Install awscli, cfssl, cfssl_json via UserData
  • Allows external access from workstation IPv4 address only

Inputs

Name Description Type Default Required
availability_zones Number of different AZs to use number "3" no
aws_key_pair_name AWS Key Pair name to use for EC2 Instances (if already existent) string "null" no
aws_profile AWS cli profile (e.g. default) string "default" no
aws_region AWS region (e.g. us-east-1 => US North Virginia) string "us-east-1" no
aws_vpc_cidr VPC CIDR block string "10.23.0.0/16" no
bastion_instance_type EC2 instance type for Bastion Host string "t3a.small" no
bastion_max_size Maximum number of EC2 instances for Bastion AutoScalingGroup number "1" no
bastion_min_size Minimum number of EC2 instances for Bastion AutoScalingGroup number "1" no
bastion_size Desired number of EC2 instances for Bastion AutoScalingGroup number "1" no
etcd_instance_type EC2 instance type for etcd instances string "t3a.small" no
etcd_instances Number of EC2 instances to provision for etcd number "3" no
etcd_max_size Maximum number of EC2 instances for etcd AutoScalingGroup number "3" no
etcd_min_size Minimum number of EC2 instances for etcd AutoScalingGroup number "3" no
etcd_size Desired number of EC2 instances for etcd AutoScalingGroup number "3" no
hosted_zone Route53 Hosted Zone for creating records (without . suffix, e.g. napo.io) string n/a yes
master_instance_type EC2 instance type for K8s master instances string "t3a.small" no
master_max_size Maximum number of EC2 instances for K8s Master AutoScalingGroup number "3" no
master_min_size Minimum number of EC2 instances for K8s Master AutoScalingGroup number "3" no
master_size Desired number of EC2 instances for K8s Master AutoScalingGroup number "3" no
owner Owner name used for tags string "napo.io" no
project Project name used for tags string "k8s-the-right-hard-way-aws" no
ssh_public_key_path SSH public key path (to create a new AWS Key Pair from existing local SSH public RSA key) string "~/.ssh/id_rsa.pub" no
stage Environment name (e.g. testing, dev, staging, prod) string "testing" no
worker_instance_type EC2 instance type for K8s worker instances string "t3a.small" no
worker_max_size Maximum number of EC2 instances for K8s Worker AutoScalingGroup number "3" no
worker_min_size Minimum nnumber of EC2 instances for K8s Worker AutoScalingGroup number "3" no
worker_size Desired number of EC2 instances for K8s Worker AutoScalingGroup number "3" no

Outputs

Name Description
route53_bastion_public_fqdn Route53 record for Bastion Host instances
You can’t perform that action at this time.