diff --git a/infra/vultr-kubernetes/Makefile b/infra/vultr-kubernetes/Makefile new file mode 100644 index 0000000..17a709d --- /dev/null +++ b/infra/vultr-kubernetes/Makefile @@ -0,0 +1,24 @@ +plan=out.plan + +SHELL := /bin/bash + +$(plan): *.tf + source ./secrets.env && terraform plan -input=false -out $(plan) + +push: build + source ./secrets.env && terraform apply $(plan) + +refresh: + source ./secrets.env && terraform apply -refresh-only + +test: + terraform validate + + +rip: + source ./secrets.env && terraform destroy + +clean: + rm -f $(plan) + +.PHONY: test build clean push rip diff --git a/infra/vultr-kubernetes/backend.tf b/infra/vultr-kubernetes/backend.tf new file mode 100644 index 0000000..e97929e --- /dev/null +++ b/infra/vultr-kubernetes/backend.tf @@ -0,0 +1,34 @@ +terraform { + required_version = ">= 0.13" + backend s3 { + bucket = "project-athens" + key = "infra/vke/state/build.tfstate" + region = "us-west-1" + encrypt = true + } + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5.0" + } + vultr = { + source = "vultr/vultr" + version = "2.19.0" + } + } +} + +provider vultr { + api_key = var.vultr_api_key + rate_limit = 100 + retry_limit = 3 +} + +provider aws { + access_key = var.aws_key + secret_key = var.aws_secret + region = var.aws_region + max_retries = 1 +} + + diff --git a/infra/vultr-kubernetes/cluster.tf b/infra/vultr-kubernetes/cluster.tf new file mode 100644 index 0000000..0e5f51b --- /dev/null +++ b/infra/vultr-kubernetes/cluster.tf @@ -0,0 +1,13 @@ +resource vultr_kubernetes athens { + region = var.cluster.region + version = var.cluster.version + label = var.cluster.label + node_pools { + # how many pools do we want + node_quantity = 1 + plan = var.cluster.pool.plan + label = var.cluster.pool.label + min_nodes = var.cluster.pool.min + max_nodes = var.cluster.pool.max + } +} diff --git a/infra/vultr-kubernetes/readme.md b/infra/vultr-kubernetes/readme.md new file mode 100644 index 0000000..760cc66 --- /dev/null +++ b/infra/vultr-kubernetes/readme.md @@ -0,0 +1,5 @@ +# Kubernetes Cluster On Vultr + + + + diff --git a/infra/vultr-kubernetes/variables.tf b/infra/vultr-kubernetes/variables.tf new file mode 100644 index 0000000..2192f5b --- /dev/null +++ b/infra/vultr-kubernetes/variables.tf @@ -0,0 +1,35 @@ +# API Keys required to reach AWS/Vultr +variable vultr_api_key { + type = string + sensitive = true +} + +variable aws_key { + type = string + sensitive = true +} + +variable aws_secret { + type = string + sensitive = true +} + +variable aws_region { + type = string + sensitive = true +} + +# Cluster configuration +variable cluster { + type = object({ + region = string + label = string + version = string + pool = object({ + plan = string + autoscale = bool + min = number + max = number + }) + }) +}