Skip to content

Terraform for AWS to provision infrastructure for learning kubeadm / self-managed Kubernetes (CKA)

License

Notifications You must be signed in to change notification settings

hajowieland/tf-k8s-learn-kubeadm

Repository files navigation

tf-k8s-learn-kubeadm

This Terraform module creates AWS resources to learn for CKA and experiment with kubeadm / self-managed K8s.

Resources

  • OPTIONAL: AWS Key Pair (you can use a pre-existing one, too)
  • VPC
    • Public Subnets
      • Internet Gateway
    • Private Subnets
      • NAT Gateway (single one for all AZs to save costs)
  • Classic Load Balancer
    • etcd
    • kube-apiserver
  • UserData
  • EC2 Instances (NO AUTOSCALING!)
    • Bastion (provisioned with your private SSH Key and populated SSH Config)
    • etcd
    • controller
    • worker

Examples

Set variables in your local terraform.tfvars file to match your needs.

Use Ubuntu 20.04 LTS instead of default 18.04 and pre-existing AWS Key Pair and SSH Key path:

owner                = "johndoe"
ssh_private_key_path = "$HOME/.ssh/id_rsa-customkey"
key_pair_name        = "my-key-pair-name"
ubuntu_release       = "focal-20.04"

Set custom instance types (default: t3a.small):

owner                 = "johndoe"
bastion_instance_type = "t3a.micro"
etcd_instance_type    = "t3a.medium"
master_instance_type  = "t3a.medium"
worker_instance_type  = "t3a.large"

Terraform Docs

Requirements

No requirements.

Providers

Name Version
aws n/a
http n/a

Inputs

Name Description Type Default Required
aws_region AWS Region to use for all resources string "eu-central-1" no
bastion_instance_type Bastion: EC2 Instance Type string "t3a.small" no
bastion_volume_size bastion - EBS root volume size in GB number 30 no
cfssl_version cfssl version to install in UserData string "1.4.1" no
controller_instance_type controller: EC2 Instance Type string "t3a.small" no
controller_volume_size controller - EBS root volume size in GB number 30 no
etcd_instance_type etcd: EC2 Instance Type string "t3a.small" no
etcd_version etcd / etcdctl version to install in UserData string "v3.4.13" no
etcd_volume_size etcd - EBS root volume size in GB number 30 no
key_pair_name Preexisting AWS Key Pair name for SSH (leave emty to generate new AWS Key Pair) string "" no
number_azs Number of AWS Availability Zones to use for every subnet number 3 no
owner Tag 'Owner' to be used for all resources string n/a yes
ssh_private_key_path SSH Private Key path on your workstatio (must match 'key_pair_name' SSH Key) string "$HOME/.ssh/id_rsa" no
tags Tags to apply to resources map(string)
{
"ManagedBy": "terraform",
"Name": "cka-kubeadm",
"Project": "cka-kubeadm"
}
no
timezone TImezone to set for alle instances string "Europe/Berlin" no
ubuntu_release Ubuntu release name and version for AMI data source search (<short-name>-<version-number>) string "bionic-18.04" no
vpc_cidr AWS VPC CIDR network block (e.g. 10.0.0.0/16) string "10.0.0.0/16" no
worker_instance_type Worker: EC2 Instance Type string "t3a.small" no
worker_volume_size Worker - EBS root volume size in GB number 30 no

Outputs

Name Description
ami AMI description
bastion_public_ip Bastion Host Public IPv4 address to connect to
lb_etcd_dns etcd Load Balancer DNS
lb_kube_apiserver_dns kube-apiserver Load Balancer DNS
workstation_ip Your workstation's IP address

About

Terraform for AWS to provision infrastructure for learning kubeadm / self-managed Kubernetes (CKA)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published