From 2bfe30a2433b8a51c18d101a5648647eb370fb62 Mon Sep 17 00:00:00 2001 From: Alejandro Avagnina Date: Fri, 30 Aug 2024 19:06:19 -0300 Subject: [PATCH] chore: update services selectors to use node version instead of release --- bootstrap/instance/main.tf | 4 ++++ bootstrap/instance/node.tf | 2 +- bootstrap/main.tf | 10 ++++++---- bootstrap/relay/main.tf | 5 ----- bootstrap/service/main.tf | 18 +++++++++++------- bootstrap/variables.tf | 8 +++++--- 6 files changed, 27 insertions(+), 20 deletions(-) diff --git a/bootstrap/instance/main.tf b/bootstrap/instance/main.tf index 0297ccf..860c945 100644 --- a/bootstrap/instance/main.tf +++ b/bootstrap/instance/main.tf @@ -91,3 +91,7 @@ variable "restore" { variable "is_custom" { default = false } + +variable "is_relay" { + default = false +} \ No newline at end of file diff --git a/bootstrap/instance/node.tf b/bootstrap/instance/node.tf index 3d63699..e2fdd72 100644 --- a/bootstrap/instance/node.tf +++ b/bootstrap/instance/node.tf @@ -23,7 +23,7 @@ locals { ] arguments = var.network == "vector-testnet" ? [] : var.is_custom == true ? local.custom_arguments : local.default_arguments - n2n_port_name = contains(["mainnet", "preview", "preprod"], var.network) && var.release == "stable" ? "n2n-${var.network}" : "n2n" + n2n_port_name = var.is_relay == true ? "n2n-${var.network}" : "n2n" } diff --git a/bootstrap/main.tf b/bootstrap/main.tf index 73e39f7..912d3ea 100644 --- a/bootstrap/main.tf +++ b/bootstrap/main.tf @@ -81,6 +81,7 @@ module "instances" { node_version = each.value.node_version restore = coalesce(each.value.restore, false) is_custom = coalesce(each.value.is_custom, false) + is_relay = coalesce(each.value.is_relay, false) } @@ -102,10 +103,11 @@ module "services" { for_each = var.services source = "./service" - namespace = var.namespace - network = each.value.network - release = each.value.release - active_salt = each.value.active_salt + namespace = var.namespace + network = each.value.network + release = each.value.release + node_version = each.value.node_version + active_salt = each.value.active_salt } module "node_relay" { diff --git a/bootstrap/relay/main.tf b/bootstrap/relay/main.tf index 23bf9c0..2befdc0 100644 --- a/bootstrap/relay/main.tf +++ b/bootstrap/relay/main.tf @@ -19,7 +19,6 @@ resource "kubernetes_service_v1" "node-relay-n2n" { selector = { "role" = "node" - "release" = "stable" } port { @@ -42,9 +41,5 @@ resource "kubernetes_service_v1" "node-relay-n2n" { port = 3002 target_port = "n2n-preview" } - - - - } } diff --git a/bootstrap/service/main.tf b/bootstrap/service/main.tf index d106037..e9cb975 100644 --- a/bootstrap/service/main.tf +++ b/bootstrap/service/main.tf @@ -15,16 +15,20 @@ variable "active_salt" { default = "" } +variable "node_version" { + description = "the version of the node" +} + locals { selector = length(var.active_salt) > 0 ? { - "role" = "node" - "network" = var.network - "release" = var.release - "salt" = var.active_salt + "role" = "node" + "network" = var.network + "node-version" = var.node_version + "salt" = var.active_salt } : { - "role" = "node" - "network" = var.network - "release" = var.release + "role" = "node" + "network" = var.network + "node-version" = var.node_version } } diff --git a/bootstrap/variables.tf b/bootstrap/variables.tf index 4762022..90574d5 100644 --- a/bootstrap/variables.tf +++ b/bootstrap/variables.tf @@ -154,13 +154,15 @@ variable "instances" { compute_profile = optional(string) availability_sla = optional(string) is_custom = optional(bool) + is_relay = optional(bool, false) })) } variable "services" { type = map(object({ - network = string - release = string - active_salt = optional(string) + network = string + release = string + node_version = string + active_salt = optional(string) })) }