From 21dcf31777948219d46e915a474afae91560a3ee Mon Sep 17 00:00:00 2001 From: Florian Lemaitre Date: Mon, 11 Sep 2023 23:09:56 +0200 Subject: [PATCH] compute_plane_defaults for localhost/all-in-one --- .../localhost/all-in-one/armonik.tf | 2 +- .../localhost/all-in-one/parameters.tfvars | 215 ++++-------------- .../localhost/all-in-one/partitions.tf | 32 +++ .../localhost/all-in-one/variables.tf | 74 ++++-- 4 files changed, 138 insertions(+), 185 deletions(-) create mode 100644 infrastructure/quick-deploy/localhost/all-in-one/partitions.tf diff --git a/infrastructure/quick-deploy/localhost/all-in-one/armonik.tf b/infrastructure/quick-deploy/localhost/all-in-one/armonik.tf index b87e044d9..9920eb297 100644 --- a/infrastructure/quick-deploy/localhost/all-in-one/armonik.tf +++ b/infrastructure/quick-deploy/localhost/all-in-one/armonik.tf @@ -19,7 +19,7 @@ module "armonik" { // If compute plane has no partition data, provides a default // but always overrides the images compute_plane = { - for k, v in var.compute_plane : k => merge({ + for k, v in local.compute_plane : k => merge({ partition_data = { priority = 1 reserved_pods = 1 diff --git a/infrastructure/quick-deploy/localhost/all-in-one/parameters.tfvars b/infrastructure/quick-deploy/localhost/all-in-one/parameters.tfvars index 6bdc7fc3a..e45788775 100644 --- a/infrastructure/quick-deploy/localhost/all-in-one/parameters.tfvars +++ b/infrastructure/quick-deploy/localhost/all-in-one/parameters.tfvars @@ -80,207 +80,86 @@ admin_old_gui = { } } +compute_plane_defaults = { + # number of replicas for each deployment of compute plane + replicas = 0 + # ArmoniK polling agent + polling_agent = { + limits = { + cpu = "2000m" + memory = "2048Mi" + } + requests = { + cpu = "50m" + memory = "50Mi" + } + } + # ArmoniK workers + worker = { + limits = { + cpu = "1000m" + memory = "1024Mi" + } + requests = { + cpu = "50m" + memory = "50Mi" + } + } + hpa = { + type = "prometheus" + polling_interval = 15 + cooldown_period = 300 + min_replica_count = 0 + max_replica_count = 5 + behavior = { + restore_to_original_replica_count = true + stabilization_window_seconds = 300 + type = "Percent" + value = 100 + period_seconds = 15 + } + triggers = [ + { + type = "prometheus" + threshold = 2 + }, + ] + } +} + # Parameters of the compute plane compute_plane = { # Default partition that uses the C# extension for the worker default = { - # number of replicas for each deployment of compute plane - replicas = 0 - # ArmoniK polling agent - polling_agent = { - limits = { - cpu = "2000m" - memory = "2048Mi" - } - requests = { - cpu = "50m" - memory = "50Mi" - } - } - # ArmoniK workers worker = [ { image = "dockerhubaneo/armonik_worker_dll" - limits = { - cpu = "1000m" - memory = "1024Mi" - } - requests = { - cpu = "50m" - memory = "50Mi" - } } ] - hpa = { - type = "prometheus" - polling_interval = 15 - cooldown_period = 300 - min_replica_count = 0 - max_replica_count = 5 - behavior = { - restore_to_original_replica_count = true - stabilization_window_seconds = 300 - type = "Percent" - value = 100 - period_seconds = 15 - } - triggers = [ - { - type = "prometheus" - threshold = 2 - }, - ] - } }, # Partition for the stream worker stream = { - # number of replicas for each deployment of compute plane - replicas = 0 - # ArmoniK polling agent - polling_agent = { - limits = { - cpu = "2000m" - memory = "2048Mi" - } - requests = { - cpu = "50m" - memory = "50Mi" - } - } - # ArmoniK workers worker = [ { image = "dockerhubaneo/armonik_core_stream_test_worker" - limits = { - cpu = "1000m" - memory = "1024Mi" - } - requests = { - cpu = "50m" - memory = "50Mi" - } } ] - hpa = { - type = "prometheus" - polling_interval = 15 - cooldown_period = 300 - min_replica_count = 0 - max_replica_count = 5 - behavior = { - restore_to_original_replica_count = true - stabilization_window_seconds = 300 - type = "Percent" - value = 100 - period_seconds = 15 - } - triggers = [ - { - type = "prometheus" - threshold = 2 - }, - ] - } }, # Partition for the htcmock worker htcmock = { - # number of replicas for each deployment of compute plane - replicas = 0 - # ArmoniK polling agent - polling_agent = { - limits = { - cpu = "2000m" - memory = "2048Mi" - } - requests = { - cpu = "50m" - memory = "50Mi" - } - } - # ArmoniK workers worker = [ { image = "dockerhubaneo/armonik_core_htcmock_test_worker" - limits = { - cpu = "1000m" - memory = "1024Mi" - } - requests = { - cpu = "50m" - memory = "50Mi" - } } ] - hpa = { - type = "prometheus" - polling_interval = 15 - cooldown_period = 300 - min_replica_count = 0 - max_replica_count = 5 - behavior = { - restore_to_original_replica_count = true - stabilization_window_seconds = 300 - type = "Percent" - value = 100 - period_seconds = 15 - } - triggers = [ - { - type = "prometheus" - threshold = 2 - }, - ] - } }, # Partition for the bench worker bench = { - # number of replicas for each deployment of compute plane - replicas = 0 - # ArmoniK polling agent - polling_agent = { - limits = { - cpu = "2000m" - memory = "2048Mi" - } - requests = { - cpu = "50m" - memory = "50Mi" - } - } - # ArmoniK workers worker = [ { image = "dockerhubaneo/armonik_core_bench_test_worker" - limits = { - cpu = "1000m" - memory = "1024Mi" - } - requests = { - cpu = "50m" - memory = "50Mi" - } } ] - hpa = { - type = "prometheus" - polling_interval = 15 - cooldown_period = 300 - min_replica_count = 0 - max_replica_count = 5 - behavior = { - restore_to_original_replica_count = true - stabilization_window_seconds = 300 - type = "Percent" - value = 100 - period_seconds = 15 - } - triggers = [ - { - type = "prometheus" - threshold = 2 - }, - ] - } }, } diff --git a/infrastructure/quick-deploy/localhost/all-in-one/partitions.tf b/infrastructure/quick-deploy/localhost/all-in-one/partitions.tf new file mode 100644 index 000000000..3d28fc705 --- /dev/null +++ b/infrastructure/quick-deploy/localhost/all-in-one/partitions.tf @@ -0,0 +1,32 @@ +locals { + compute_plane = { + for name, partition in var.compute_plane : + name => { + replicas = try(coalesce(partition.replicas), coalesce(var.compute_plane_defaults.replicas), 1) + termination_grace_period_seconds = try(coalesce(partition.termination_grace_period_seconds), coalesce(var.compute_plane_defaults.termination_grace_period_seconds), 30) + image_pull_secrets = try(coalesce(partition.image_pull_secrets), coalesce(var.compute_plane_defaults.image_pull_secrets), "") + node_selector = try(coalesce(partition.node_selector), coalesce(var.compute_plane_defaults.node_selector), {}) + annotations = try(coalesce(partition.annotations), coalesce(var.compute_plane_defaults.annotations), {}) + polling_agent = { + image = try(coalesce(partition.polling_agent.image), coalesce(var.compute_plane_defaults.polling_agent.image), "dockerhubaneo/armonik_pollingagent") + tag = try(coalesce(partition.polling_agent.tag), coalesce(var.compute_plane_defaults.polling_agent.tag), null) + image_pull_policy = try(coalesce(partition.polling_agent.image_pull_policy), coalesce(var.compute_plane_defaults.polling_agent.image_pull_policy), "IfNotPresent") + limits = merge(try(coalesce(partition.polling_agent.limits), {}), try(coalesce(var.compute_plane_defaults.polling_agent.limits), {})) + requests = merge(try(coalesce(partition.polling_agent.requests), {}), try(coalesce(var.compute_plane_defaults.polling_agent.requests), {})) + } + worker = [ + for i, worker in partition.worker : + { + name = try(coalesce(worker.name), "worker-${i}") + image = try(coalesce(worker.image), coalesce(var.compute_plane_defaults.worker.image)) + tag = try(coalesce(worker.tag), coalesce(var.compute_plane_defaults.worker.tag), null) + image_pull_policy = try(coalesce(worker.image_pull_policy), coalesce(var.compute_plane_defaults.worker.image_pull_policy), "IfNotPresent") + limits = merge(try(coalesce(worker.limits), {}), try(coalesce(var.compute_plane_defaults.worker.limits), {})) + requests = merge(try(coalesce(worker.requests), {}), try(coalesce(var.compute_plane_defaults.worker.requests), {})) + } + ] + # KEDA scaler + hpa = try(coalesce(partition.hpa), coalesce(var.compute_plane_defaults.hpa), {}) + } + } +} diff --git a/infrastructure/quick-deploy/localhost/all-in-one/variables.tf b/infrastructure/quick-deploy/localhost/all-in-one/variables.tf index 65ed92eda..91b5a3831 100644 --- a/infrastructure/quick-deploy/localhost/all-in-one/variables.tf +++ b/infrastructure/quick-deploy/localhost/all-in-one/variables.tf @@ -373,18 +373,18 @@ variable "admin_old_gui" { } # Parameters of the compute plane -variable "compute_plane" { +variable "compute_plane_defaults" { description = "Parameters of the compute plane" - type = map(object({ - replicas = optional(number, 1) - termination_grace_period_seconds = optional(number, 30) - image_pull_secrets = optional(string, "IfNotPresent") - node_selector = optional(any, {}) - annotations = optional(any, {}) - polling_agent = object({ - image = optional(string, "dockerhubaneo/armonik_pollingagent") + type = object({ + replicas = optional(number) + termination_grace_period_seconds = optional(number) + image_pull_secrets = optional(string) + node_selector = optional(any) + annotations = optional(any) + polling_agent = optional(object({ + image = optional(string) tag = optional(string) - image_pull_policy = optional(string, "IfNotPresent") + image_pull_policy = optional(string) limits = optional(object({ cpu = optional(string) memory = optional(string) @@ -393,12 +393,12 @@ variable "compute_plane" { cpu = optional(string) memory = optional(string) })) - }) - worker = list(object({ - name = optional(string, "worker") - image = string + })) + worker = optional(object({ + name = optional(string) + image = optional(string) tag = optional(string) - image_pull_policy = optional(string, "IfNotPresent") + image_pull_policy = optional(string) limits = optional(object({ cpu = optional(string) memory = optional(string) @@ -410,7 +410,49 @@ variable "compute_plane" { })) # KEDA scaler hpa = optional(any) - })) + }) + default = {} +} +# Parameters of the compute plane +variable "compute_plane" { + description = "Parameters of the compute plane" + type = any + # type = map(object({ + # replicas = optional(number) + # termination_grace_period_seconds = optional(number) + # image_pull_secrets = optional(string) + # node_selector = optional(any) + # annotations = optional(any) + # polling_agent = optional(object({ + # image = optional(string) + # tag = optional(string) + # image_pull_policy = optional(string) + # limits = optional(object({ + # cpu = optional(string) + # memory = optional(string) + # })) + # requests = optional(object({ + # cpu = optional(string) + # memory = optional(string) + # })) + # })) + # worker = optional(list(object({ + # name = optional(string) + # image = optional(string) + # tag = optional(string) + # image_pull_policy = optional(string) + # limits = optional(object({ + # cpu = optional(string) + # memory = optional(string) + # })) + # requests = optional(object({ + # cpu = optional(string) + # memory = optional(string) + # })) + # }))) + # # KEDA scaler + # hpa = optional(any) + # })) } variable "ingress" {