Here is a kubernetes cluster module for terraform (to run on AWS).
- VPC
- S3 Endpoint (need one created to be retrieved via a terraform data).
- Route53 Host Zone (used as
cluster_dns). - Access to private subnet (VPN to reach instances in private subnets).
- Security group to allow you to reach the instances in SSH.
cluster_nameCluster name used byKubernetesClustertags.cluster_dnsDomain used to create DNS Records for the cluster (etcd,api).vpc_idVPC used to create subnets and route table for the cluster.aws_azAmazon AZ used to create subnets and route table for the cluster.public_cidr_blockBlock CIDR to use for public subnet (used by Kubernetes to create ELB).private_cidr_blockBlock CIDR to use for private subnet (where all instances are).nat_internet_gatewayNAT Gateway to use for the private subnet as default gateway.keypairKeypair to use to create instances.
propagating_vgws(List) Virtual Gateway to import routes in the route table.whitelisted_ips(List) Blocks CIDR to allow to reach kube-apiserver (default0.0.0.0/0).additional_security_groups(List) Additional security groups to apply to all instances.
module "k8s_cluster" {
source = "github.com/gbergere/terraform-aws-kubernetes-cluster"
# Cluster
cluster_name = "my-cluster"
cluster_dns = "gbergeret.org"
# VPC Networking
vpc_id = "vpc-xxxxxxxx"
aws_az = "eu-west-1a"
public_cidr_block = "192.168.0.0/24"
private_cidr_block = "192.168.1.0/24"
nat_internet_gateway = "nat-xxxxxxxxxxxxxxxxx"
# EC2
keypair = "my-keypair"
}In order to write the module I've been inspired by Kubernetes the Hard Way from Kelsey Hightower and Kubernetes: Getting Started with CoreOS