From c14351eb1aab41d02e3344fd4d9e4a459952bab2 Mon Sep 17 00:00:00 2001 From: dr-smo Date: Mon, 9 May 2022 09:56:06 +0200 Subject: [PATCH] [tf] [vultr] pass cluster vars via state, not local file. allow setting storage classs. cleanup. Closes: #867 --- terraform/fullnode/vultr/cluster.tf | 7 +------ terraform/fullnode/vultr/kubernetes.tf | 23 +++++++++-------------- terraform/fullnode/vultr/main.tf | 2 -- terraform/fullnode/vultr/variables.tf | 6 ++++++ 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/terraform/fullnode/vultr/cluster.tf b/terraform/fullnode/vultr/cluster.tf index b97cc3e433a6a..84ef333ab8e0d 100644 --- a/terraform/fullnode/vultr/cluster.tf +++ b/terraform/fullnode/vultr/cluster.tf @@ -8,9 +8,4 @@ resource "vultr_kubernetes" "k8" { plan = var.machine_type label = "aptos-fullnode" } -} - -resource "local_file" "kube_config" { - content = base64decode(vultr_kubernetes.k8.kube_config) - filename = "${path.module}/vultr_kube_config.yml" -} +} \ No newline at end of file diff --git a/terraform/fullnode/vultr/kubernetes.tf b/terraform/fullnode/vultr/kubernetes.tf index 98a1ef27a8db9..11fa87a8c8e3e 100644 --- a/terraform/fullnode/vultr/kubernetes.tf +++ b/terraform/fullnode/vultr/kubernetes.tf @@ -1,5 +1,8 @@ provider "kubernetes" { - config_path = local_file.kube_config.filename + host = yamldecode(base64decode(vultr_kubernetes.k8.kube_config)).clusters[0].cluster["server"] + cluster_ca_certificate = base64decode(yamldecode(base64decode(vultr_kubernetes.k8.kube_config)).clusters[0].cluster["certificate-authority-data"]) + client_certificate = base64decode(yamldecode(base64decode(vultr_kubernetes.k8.kube_config)).users[0].user["client-certificate-data"]) + client_key = base64decode(yamldecode(base64decode(vultr_kubernetes.k8.kube_config)).users[0].user["client-key-data"]) } resource "kubernetes_namespace" "aptos" { @@ -8,20 +11,12 @@ resource "kubernetes_namespace" "aptos" { } } -resource "kubernetes_storage_class" "ssd" { - metadata { - name = "ssd" - } - storage_provisioner = "block.csi.vultr.com" - volume_binding_mode = "WaitForFirstConsumer" - parameters = { - block_type = "high_perf" - } -} - provider "helm" { kubernetes { - config_path = local_file.kube_config.filename + host = yamldecode(base64decode(vultr_kubernetes.k8.kube_config)).clusters[0].cluster["server"] + cluster_ca_certificate = base64decode(yamldecode(base64decode(vultr_kubernetes.k8.kube_config)).clusters[0].cluster["certificate-authority-data"]) + client_certificate = base64decode(yamldecode(base64decode(vultr_kubernetes.k8.kube_config)).users[0].user["client-certificate-data"]) + client_key = base64decode(yamldecode(base64decode(vultr_kubernetes.k8.kube_config)).users[0].user["client-key-data"]) } } @@ -46,7 +41,7 @@ resource "helm_release" "fullnode" { "vke.vultr.com/node-pool" = "aptos-fullnode" } storage = { - class = kubernetes_storage_class.ssd.metadata[0].name + class = var.block_storage_class } service = { type = "LoadBalancer" diff --git a/terraform/fullnode/vultr/main.tf b/terraform/fullnode/vultr/main.tf index 3daf4c4139bd8..a58ca318efff4 100644 --- a/terraform/fullnode/vultr/main.tf +++ b/terraform/fullnode/vultr/main.tf @@ -7,8 +7,6 @@ terraform { } } -provider "local" {} - provider "vultr" { api_key = var.api_key rate_limit = 700 diff --git a/terraform/fullnode/vultr/variables.tf b/terraform/fullnode/vultr/variables.tf index 5b9743f1937fc..bb74443460889 100644 --- a/terraform/fullnode/vultr/variables.tf +++ b/terraform/fullnode/vultr/variables.tf @@ -65,3 +65,9 @@ variable "fullnode_region" { description = "Geographical region for the node location. All 25 regions can be obtained at https://api.vultr.com/v2/regions" default = "fra" } + + +variable "block_storage_class" { + description = "Either vultr-block-storage for high_perf/ssd, vultr-block-storage-hdd for storage_opt/hdd. high_perf is not available in all regions!" + default = "vultr-block-storage" +} \ No newline at end of file