scholzj / terraform-aws-minikube

Terraform module for single node Kubernetes instance bootstrapped using kubeadm
Apache License 2.0
65 stars 45 forks source link
aws kubeadm kubernetes kubernetes-setup minikube minikube-setup terraform terraform-modules

AWS Minikube Terraform module

AWS Minikube is a single node Kubernetes deployment in AWS. It creates EC2 host and deploys Kubernetes cluster using Kubeadm tool. It provides full integration with AWS. It is able to handle ELB load balancers, EBS disks, Route53 domains etc.

Updates

Prerequisites and dependencies

Including the module

Although it can be run on its own, the main value is that it can be included into another Terraform configuration.

module "minikube" {
  source = "github.com/scholzj/terraform-aws-minikube"

  aws_region    = "eu-central-1"
  cluster_name  = "my-minikube"
  aws_instance_type = "t2.medium"
  ssh_public_key = "~/.ssh/id_rsa.pub"
  aws_subnet_id = "subnet-8a3517f8"
  ami_image_id = "ami-b81dbfc5"
  hosted_zone = "my-domain.com"
  hosted_zone_private = false

  tags = {
    Application = "Minikube"
  }

  addons = [
    "https://raw.githubusercontent.com/scholzj/terraform-aws-minikube/master/addons/storage-class.yaml",
    "https://raw.githubusercontent.com/scholzj/terraform-aws-minikube/master/addons/heapster.yaml",
    "https://raw.githubusercontent.com/scholzj/terraform-aws-minikube/master/addons/dashboard.yaml",
    "https://raw.githubusercontent.com/scholzj/terraform-aws-minikube/master/addons/external-dns.yaml"
  ]
}

An example of how to include this can be found in the examples dir.

Using custom AMI Image

AWS Minikube is built and tested on CentOS 7. But gives you the possibility to use their own AMI images. Your custom AMI image should be based on RPM distribution and should be similar to Cent OS 7. When ami_image_id variable is not specified, the latest available CentOS 7 image will be used.

Add-ons

Currently, following add-ons are supported:

The add-ons will be installed automatically based on the Terraform variables.

Custom add-ons

Custom add-ons can be added if needed. Fro every URL in the addons list, the initialization scripts will automatically call kubectl -f apply <Addon URL> to deploy it. Minikube is using RBAC. So the custom add-ons have to be RBAC ready.

Tagging

If you need to tag resources created by your Kubernetes cluster (EBS volumes, ELB load balancers etc.) check this AWS Lambda function which can do the tagging.

Kubernetes version

The intent for this module is to use it for development and testing against the latest version of Kubernetes. As such, the primary goal for this module is to ensure it works with whatever is the latest version of Kubernetes supported by Minikube. This includes provisioning the cluster as well as setting up networking and any of the supported add-ons. This module might, but is not guaranteed to, also work with other versions of Kubernetes. At your own discretion, you can use the kubernetes_version variable to specify a different version of Kubernetes for the Minikube cluster.