diff --git a/bootstrap/instance/main.tf b/bootstrap/instance/main.tf index 860c945..4dc78bb 100644 --- a/bootstrap/instance/main.tf +++ b/bootstrap/instance/main.tf @@ -94,4 +94,15 @@ variable "is_custom" { variable "is_relay" { default = false -} \ No newline at end of file +} + +variable "tolerations" { + description = "List of tolerations for the node" + type = list(object({ + effect = string + key = string + operator = string + value = string + })) + default = [] +} diff --git a/bootstrap/instance/node.tf b/bootstrap/instance/node.tf index e2fdd72..0300e9e 100644 --- a/bootstrap/instance/node.tf +++ b/bootstrap/instance/node.tf @@ -24,6 +24,29 @@ locals { arguments = var.network == "vector-testnet" ? [] : var.is_custom == true ? local.custom_arguments : local.default_arguments n2n_port_name = var.is_relay == true ? "n2n-${var.network}" : "n2n" + + default_tolerations = [ + { + effect = "NoSchedule" + key = "demeter.run/compute-profile" + operator = "Equal" + value = var.compute_profile + }, + { + effect = "NoSchedule" + key = "demeter.run/compute-arch" + operator = "Equal" + value = var.compute_arch + }, + { + effect = "NoSchedule" + key = "demeter.run/availability-sla" + operator = "Equal" + value = var.availability_sla + } + ] + + combined_tolerations = concat(local.default_tolerations, var.tolerations) } @@ -113,25 +136,14 @@ resource "kubernetes_stateful_set_v1" "node" { } } - toleration { - effect = "NoSchedule" - key = "demeter.run/compute-profile" - operator = "Equal" - value = var.compute_profile - } - - toleration { - effect = "NoSchedule" - key = "demeter.run/compute-arch" - operator = "Equal" - value = var.compute_arch - } - - toleration { - effect = "NoSchedule" - key = "demeter.run/availability-sla" - operator = "Equal" - value = var.availability_sla + dynamic "toleration" { + for_each = local.combined_tolerations + content { + effect = toleration.value.effect + key = toleration.value.key + operator = toleration.value.operator + value = toleration.value.value + } } volume { diff --git a/bootstrap/main.tf b/bootstrap/main.tf index b43df61..476d950 100644 --- a/bootstrap/main.tf +++ b/bootstrap/main.tf @@ -84,6 +84,7 @@ module "instances" { restore = coalesce(each.value.restore, false) is_custom = coalesce(each.value.is_custom, false) is_relay = coalesce(each.value.is_relay, false) + tolerations = coalesce(each.value.tolerations, []) } module "custom_configs" { diff --git a/bootstrap/variables.tf b/bootstrap/variables.tf index 914bffb..ab7fc1c 100644 --- a/bootstrap/variables.tf +++ b/bootstrap/variables.tf @@ -160,6 +160,12 @@ variable "instances" { availability_sla = optional(string) is_custom = optional(bool) is_relay = optional(bool, false) + tolerations = optional(list(object({ + effect = string + key = string + operator = string + value = string + })), []) })) }