From f68c6b227affae35ce572833eda29ef696c99b71 Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 18 Apr 2024 13:28:39 +1200 Subject: [PATCH] add vultr k8s --- terraform/vultr/k8s.tf | 20 ++++++++++++++++++++ terraform/vultr/main.tf | 31 +++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 terraform/vultr/k8s.tf create mode 100644 terraform/vultr/main.tf diff --git a/terraform/vultr/k8s.tf b/terraform/vultr/k8s.tf new file mode 100644 index 0000000..cc38903 --- /dev/null +++ b/terraform/vultr/k8s.tf @@ -0,0 +1,20 @@ +resource "vultr_kubernetes" "k8s" { + region = "ewr" + version = "v1.29.2+1" + label = "cluster00" + ha_controlplanes = false + enable_firewall = false + + node_pools { + node_quantity = 1 + plan = "vc2-2c-2gb" + label = "cluster00-worker-2c-2g" + auto_scaler = false + } +} + +resource "local_sensitive_file" "kubeconfig" { + content_base64 = vultr_kubernetes.k8s.kube_config + filename = "~/.kube/vultr" + file_permission = "0600" +} diff --git a/terraform/vultr/main.tf b/terraform/vultr/main.tf new file mode 100644 index 0000000..27913e0 --- /dev/null +++ b/terraform/vultr/main.tf @@ -0,0 +1,31 @@ +terraform { + required_version = ">= 1.8.0" + required_providers { + vault = { + source = "hashicorp/vault" + version = ">= 4.2.0" + } + vultr = { + source = "vultr/vultr" + version = ">= 2.19.0" + } + } + backend "local" { + path = "/home/michael/Nextcloud/Backups/tfstate/vultr.tfstate" + } +} + +provider "vault" { + # Export the vault token to the environment variable VAULT_TOKEN + address = "https://vault.balsillie.house" +} + +data "vault_kv_secret" "vultr" { + path = "kv/vultr" +} + +provider "vultr" { + api_key = data.vault_kv_secret.vultr.data.api_key + rate_limit = 100 + retry_limit = 3 +}