Skip to content

bcbrookman/terraform-aws-kubeadm-k8s

Repository files navigation

AWS Kubeadm-K8s Terraform module

This module provisions Kubernetes clusters on AWS EC2 instances using Kubeadm with a stacked etcd topology.

How it works

  1. Each node is created with a user-data script that runs at first boot.
  2. The script prepares each node with prerequisite configurations and packages.
  3. kubeadm init is run on the first control-plane node to initialize the Kubernetes cluster.
  4. The resulting kubeadm join commands are copied to an S3 bucket.
  5. All other nodes download the kubeadm join command from the S3 bucket and join the cluster.
  6. The cluster admin can then manage the cluster using kubectl, etc. via the first control-plane node.

Important

No CNI plugin is installed by this module. You will need to install one yourself before running workloads.

Example Usage

module "mycluster" {
  source                  = "bcbrookman/kubeadm-k8s/aws"
  cluster_name            = "mycluster"
  controlplane_node_count = 1
  worker_node_count       = 3
  subnet_id               = aws_subnet.mysubnet.id
  ssh_key_name            = aws_key_pair.mykeypair.key_name
}

Customizing the API server DNS name

The DNS name of the API server load balancer is available as a module output so it can be used in a CNAME record to customize the API server's DNS name.

For example:

module "mycluster" {
  source        = "bcbrookman/kubeadm-k8s/aws"
  ...
  apiserver_dns = "mycluster.mydomain.example"
}

resource "aws_route53_record" "mycluster" {
  zone_id = aws_route53_zone.example.zone_id
  name    = "mycluster.mydomain.example"
  type    = "CNAME"
  ttl     = 300
  records = [module.mycluster.apiserver_lb_dns_name]
}

About

A Terraform module for creating Kubeadm K8s clusters on AWS EC2

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •