Skip to content

Commit

Permalink
feat(bootstrap): add tolerations support to instances module (#60)
Browse files Browse the repository at this point in the history
Signed-off-by: Ales Verbic <[email protected]>
  • Loading branch information
verbotenj authored Dec 5, 2024
1 parent 533cd7f commit 5678653
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 20 deletions.
13 changes: 12 additions & 1 deletion bootstrap/instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,15 @@ variable "is_custom" {

variable "is_relay" {
default = false
}
}

variable "tolerations" {
description = "List of tolerations for the node"
type = list(object({
effect = string
key = string
operator = string
value = string
}))
default = []
}
50 changes: 31 additions & 19 deletions bootstrap/instance/node.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}


Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions bootstrap/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
6 changes: 6 additions & 0 deletions bootstrap/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
})), [])
}))
}

Expand Down

0 comments on commit 5678653

Please sign in to comment.