Skip to content

Commit

Permalink
[tf] [vultr] pass cluster vars via state, not local file. allow setti…
Browse files Browse the repository at this point in the history
…ng storage classs. cleanup.

Closes: aptos-labs#867
  • Loading branch information
dr-smo authored and aptos-bot committed May 10, 2022
1 parent 56b1f33 commit c14351e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
7 changes: 1 addition & 6 deletions terraform/fullnode/vultr/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
23 changes: 9 additions & 14 deletions terraform/fullnode/vultr/kubernetes.tf
Original file line number Diff line number Diff line change
@@ -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" {
Expand All @@ -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"])
}
}

Expand All @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions terraform/fullnode/vultr/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ terraform {
}
}

provider "local" {}

provider "vultr" {
api_key = var.api_key
rate_limit = 700
Expand Down
6 changes: 6 additions & 0 deletions terraform/fullnode/vultr/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit c14351e

Please sign in to comment.