From: Peter Mikus Date: Thu, 18 Sep 2025 05:34:45 +0000 (+0200) Subject: feat(terraform): Add dispatcher X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=464d844fa998c6f93a39ea09369a626bebc8a584;p=csit.git feat(terraform): Add dispatcher Signed-off-by: Peter Mikus Change-Id: Ieefefba0f44dcf0cd867ea1cb9a548f97d5af051 --- diff --git a/fdio.infra.terraform/terraform-nomad-gha-dispatcher/main.tf b/fdio.infra.terraform/terraform-nomad-gha-dispatcher/main.tf new file mode 100644 index 0000000000..635317ac4a --- /dev/null +++ b/fdio.infra.terraform/terraform-nomad-gha-dispatcher/main.tf @@ -0,0 +1,21 @@ +locals { + datacenters = join(",", var.datacenters) +} + +resource "nomad_job" "gha-dispatcher" { + for_each = toset(var.namespace) + jobspec = templatefile( + "${path.cwd}/nomad-${var.job_name}-${each.key}.hcl.tftpl", + { + cpu = var.cpu, + datacenters = local.datacenters, + image = "${var.image}-${each.key}:latest", + job_name = "${var.job_name}-${each.key}", + memory = var.memory, + namespace = each.key, + node_pool = var.node_pool, + region = var.region, + type = var.type + }) + detach = false +} \ No newline at end of file diff --git a/fdio.infra.terraform/terraform-nomad-gha-dispatcher/nomad-gha-dispatcher-prod.hcl.tftpl b/fdio.infra.terraform/terraform-nomad-gha-dispatcher/nomad-gha-dispatcher-prod.hcl.tftpl new file mode 100644 index 0000000000..ea17f9c7ce --- /dev/null +++ b/fdio.infra.terraform/terraform-nomad-gha-dispatcher/nomad-gha-dispatcher-prod.hcl.tftpl @@ -0,0 +1,45 @@ +job "${job_name}" { + datacenters = ["${datacenters}"] + type = "${type}" + node_pool = "${node_pool}" + region = "${region}" + namespace = "${namespace}" + + group "${job_name}" { + count = 1 + constraint { + attribute = "$${attr.cpu.arch}" + value = "amd64" + } + constraint { + attribute = "$${node.class}" + value = "builder" + } + ephemeral_disk { + migrate = false + size = 3000 + sticky = false + } + task "${job_name}" { + driver = "docker" + config { + image = "${image}" + } + template { + destination = "$${NOMAD_SECRETS_DIR}/.env" + env = true + data = <