forked from aptos-labs/aptos-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tf][do] fullnode tf on digital ocean
Closes: aptos-labs#782
- Loading branch information
Showing
6 changed files
with
237 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.tfstate | ||
*.tfstate.backup | ||
*.yml |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
resource "digitalocean_kubernetes_cluster" "aptos" { | ||
name = "aptos-${terraform.workspace}" | ||
region = var.region | ||
version = "1.22.8-do.1" | ||
|
||
node_pool { | ||
name = "fullnodes" | ||
size = var.machine_type | ||
node_count = var.num_fullnodes | ||
tags = ["fullnodes"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
provider "kubernetes" { | ||
host = "${digitalocean_kubernetes_cluster.aptos.endpoint}" | ||
cluster_ca_certificate = base64decode(digitalocean_kubernetes_cluster.aptos.kube_config[0].cluster_ca_certificate) | ||
token = digitalocean_kubernetes_cluster.aptos.kube_config[0].token | ||
} | ||
|
||
resource "kubernetes_namespace" "aptos" { | ||
metadata { | ||
name = var.k8s_namespace | ||
} | ||
} | ||
|
||
provider "helm" { | ||
kubernetes { | ||
host = "${digitalocean_kubernetes_cluster.aptos.endpoint}" | ||
cluster_ca_certificate = base64decode(digitalocean_kubernetes_cluster.aptos.kube_config[0].cluster_ca_certificate) | ||
token = digitalocean_kubernetes_cluster.aptos.kube_config[0].token | ||
} | ||
} | ||
|
||
resource "helm_release" "fullnode" { | ||
count = var.num_fullnodes | ||
name = "${terraform.workspace}${count.index}" | ||
chart = "${path.module}/../../helm/fullnode" | ||
max_history = 100 | ||
wait = false | ||
namespace = var.k8s_namespace | ||
create_namespace = true | ||
|
||
values = [ | ||
jsonencode({ | ||
chain = { | ||
era = var.era | ||
} | ||
image = { | ||
tag = var.image_tag | ||
} | ||
nodeSelector = { | ||
"doks.digitalocean.com/node-pool" = digitalocean_kubernetes_cluster.aptos.node_pool[0].name | ||
} | ||
storageClass = { | ||
class = "do-block-storage" | ||
} | ||
service = { | ||
type = "LoadBalancer" | ||
} | ||
storage = { | ||
size = "100Gi" | ||
} | ||
}), | ||
jsonencode(var.fullnode_helm_values), | ||
jsonencode(var.fullnode_helm_values_list == {} ? {} : var.fullnode_helm_values_list[count.index]), | ||
] | ||
|
||
set { | ||
name = "timestamp" | ||
value = var.helm_force_update ? timestamp() : "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
terraform { | ||
required_providers { | ||
digitalocean = { | ||
source = "digitalocean/digitalocean" | ||
version = "~> 2.0" | ||
} | ||
} | ||
} | ||
|
||
provider "local" {} | ||
|
||
provider "digitalocean" { | ||
token = var.do_token | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
variable "helm_values" { | ||
description = "Map of values to pass to Helm" | ||
type = any | ||
default = {} | ||
} | ||
|
||
variable "fullnode_helm_values" { | ||
description = "Map of values to pass to public fullnode Helm" | ||
type = any | ||
default = {} | ||
} | ||
|
||
variable "do_token" { | ||
type = string | ||
description = "Digital Notion API token" | ||
} | ||
|
||
variable "region" { | ||
description = "Digital Ocean region of nodes" | ||
type = string | ||
} | ||
|
||
variable "fullnode_helm_values_list" { | ||
description = "List of values to pass to public fullnode, for setting different value per node. length(fullnode_helm_values_list) must equal var.num_fullnodes" | ||
type = any | ||
default = {} | ||
} | ||
|
||
variable "helm_force_update" { | ||
description = "Force Terraform to update the Helm deployment" | ||
default = false | ||
} | ||
|
||
variable "k8s_namespace" { | ||
default = "aptos" | ||
description = "Kubernetes namespace that the fullnode will be deployed into" | ||
} | ||
|
||
variable "k8s_api_sources" { | ||
description = "List of CIDR subnets which can access the Kubernetes API endpoint" | ||
default = ["0.0.0.0/0"] | ||
} | ||
|
||
variable "num_fullnodes" { | ||
default = 1 | ||
description = "Number of fullnodes" | ||
} | ||
|
||
variable "image_tag" { | ||
default = "devnet" | ||
description = "Docker image tag to use for the fullnode" | ||
} | ||
|
||
variable "era" { | ||
description = "Chain era, used to start a clean chain" | ||
default = 1 | ||
} | ||
|
||
variable "chain_id" { | ||
description = "aptos chain ID" | ||
default = "DEVNET" | ||
} | ||
|
||
variable "machine_type" { | ||
description = "Machine type for running fullnode" | ||
default = "s-4vcpu-8gb" | ||
} |