From 33f7090d52d3c3ac5be9cd358e7dc00f1711da91 Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Thu, 6 Aug 2026 09:50:26 +0000 Subject: [PATCH] chore: update rpc deployment --- .../deploy-rpc/environments/mainnet/main.tf | 57 +++++++++++++++++-- .../deploy-rpc/modules/environment/main.tf | 5 ++ .../modules/environment/variables.tf | 5 ++ .../terraform/deploy-rpc/modules/rpc/main.tf | 14 ++--- .../deploy-rpc/modules/rpc/variables.tf | 30 ++++++++++ 5 files changed, 99 insertions(+), 12 deletions(-) diff --git a/spartan/terraform/deploy-rpc/environments/mainnet/main.tf b/spartan/terraform/deploy-rpc/environments/mainnet/main.tf index 03d1a6614f11..899218196cc5 100644 --- a/spartan/terraform/deploy-rpc/environments/mainnet/main.tf +++ b/spartan/terraform/deploy-rpc/environments/mainnet/main.tf @@ -58,6 +58,53 @@ locals { aztec_docker_image = var.CANONICAL_AZTEC_DOCKER_IMAGE hosts = ["v5.mainnet.rpc.aztec-labs.com", "canonical.mainnet.rpc.aztec-labs.com"] storage_size = "8Gi" + min_replicas = 1 + force_update = false + recreate_pods = false + log_level = "info" + extra_helm_values = [ + yamlencode({ + nodeSelector = { + local-ssd = "false" + node-type = "network" + cores = "2" + } + affinity = { + nodeAffinity = { + preferredDuringSchedulingIgnoredDuringExecution = [ + { + weight = 100 + preference = { + matchExpressions = [ + { + key = "cores" + operator = "In" + values = ["2"] + } + ] + } + } + ] + } + } + node = { + resources = { + requests = { + cpu = "1" + } + limits = { + cpu = "2" + } + } + updateStrategy = { + type = "RollingUpdate" + rollingUpdate = { + partition = 0 + } + } + } + }) + ] env = merge(local.env, { ROLLUP_VERSION = "" }) @@ -107,10 +154,10 @@ module "environment" { google = google } - NAMESPACE = "mainnet-rpc" - RELEASE_PREFIX = "mainnet" - RPCS = local.rpcs - ALLOW_ANONYMOUS = false - CONSUMERS = local.consumers + NAMESPACE = "mainnet-rpc" + RELEASE_PREFIX = "mainnet" + RPCS = local.rpcs + ALLOW_ANONYMOUS = false + CONSUMERS = local.consumers IRM_METRICS_ENABLED = true } diff --git a/spartan/terraform/deploy-rpc/modules/environment/main.tf b/spartan/terraform/deploy-rpc/modules/environment/main.tf index 352c3ff98e3e..44b290155131 100644 --- a/spartan/terraform/deploy-rpc/modules/environment/main.tf +++ b/spartan/terraform/deploy-rpc/modules/environment/main.tf @@ -61,12 +61,17 @@ module "rpc" { RELEASE_PREFIX = var.RELEASE_PREFIX AZTEC_DOCKER_IMAGE = each.value.aztec_docker_image + LOG_LEVEL = each.value.log_level ENV = each.value.env L1_RPC_SECRET_NAME = each.value.l1_rpc_secret_name L1_CONSENSUS_HOST_URLS_SECRET_NAME = each.value.l1_consensus_host_urls_secret_name L1_CONSENSUS_HOST_API_KEYS_SECRET_NAME = each.value.l1_consensus_host_api_keys_secret_name L1_CONSENSUS_HOST_API_KEY_HEADERS_SECRET_NAME = each.value.l1_consensus_host_api_key_headers_secret_name STORAGE_SIZE = each.value.storage_size + EXTRA_HELM_VALUES = each.value.extra_helm_values + MIN_REPLICAS = each.value.min_replicas + FORCE_UPDATE = each.value.force_update + RECREATE_PODS = each.value.recreate_pods OTEL_COLLECTOR_ENDPOINT_GCP_SECRET_NAME = var.OTEL_COLLECTOR_ENDPOINT_GCP_SECRET_NAME depends_on = [kubernetes_namespace_v1.rpc] diff --git a/spartan/terraform/deploy-rpc/modules/environment/variables.tf b/spartan/terraform/deploy-rpc/modules/environment/variables.tf index 87f75ef84218..c8026d2fdbcb 100644 --- a/spartan/terraform/deploy-rpc/modules/environment/variables.tf +++ b/spartan/terraform/deploy-rpc/modules/environment/variables.tf @@ -12,12 +12,17 @@ variable "RPCS" { description = "RPC instances keyed by public route alias." type = map(object({ aztec_docker_image = string + log_level = optional(string, "info") l1_rpc_secret_name = string l1_consensus_host_urls_secret_name = string l1_consensus_host_api_keys_secret_name = string l1_consensus_host_api_key_headers_secret_name = string hosts = list(string) storage_size = string + extra_helm_values = optional(list(string), []) + min_replicas = optional(number, 1) + force_update = optional(bool, true) + recreate_pods = optional(bool, true) env = map(string) })) } diff --git a/spartan/terraform/deploy-rpc/modules/rpc/main.tf b/spartan/terraform/deploy-rpc/modules/rpc/main.tf index 33bfa3a9bb3e..f32c69750378 100644 --- a/spartan/terraform/deploy-rpc/modules/rpc/main.tf +++ b/spartan/terraform/deploy-rpc/modules/rpc/main.tf @@ -26,20 +26,20 @@ resource "helm_release" "rpc" { namespace = var.NAMESPACE create_namespace = false upgrade_install = true - force_update = true - recreate_pods = true + force_update = var.FORCE_UPDATE + recreate_pods = var.RECREATE_PODS reuse_values = false timeout = 3600 # 1h to sync wait = true wait_for_jobs = true take_ownership = true - values = [ + values = concat([ file("${path.module}/values/prod.yaml"), file("${path.module}/values/prod-res.yaml"), yamlencode({ fullnameOverride = local.workload_name - replicaCount = 1 + replicaCount = var.MIN_REPLICAS extraObjects = concat( [ { @@ -149,7 +149,7 @@ resource "helm_release" "rpc" { } node = { - logLevel = "info" + logLevel = var.LOG_LEVEL startupProbe = { failureThreshold = 120 } @@ -212,7 +212,7 @@ resource "helm_release" "rpc" { } } }) - ] + ], var.EXTRA_HELM_VALUES) } resource "kubernetes_manifest" "hpa" { @@ -229,7 +229,7 @@ resource "kubernetes_manifest" "hpa" { kind = "StatefulSet" name = local.workload_name } - minReplicas = 1 + minReplicas = var.MIN_REPLICAS maxReplicas = 4 behavior = { scaleUp = { diff --git a/spartan/terraform/deploy-rpc/modules/rpc/variables.tf b/spartan/terraform/deploy-rpc/modules/rpc/variables.tf index 2b3c92b3a0ef..35beaa78b901 100644 --- a/spartan/terraform/deploy-rpc/modules/rpc/variables.tf +++ b/spartan/terraform/deploy-rpc/modules/rpc/variables.tf @@ -13,6 +13,12 @@ variable "RELEASE_PREFIX" { type = string } +variable "LOG_LEVEL" { + description = "Default and per-module log levels for the RPC node." + type = string + default = "info" +} + variable "AZTEC_DOCKER_IMAGE" { description = "Aztec Docker image in repository:tag form." type = string @@ -53,6 +59,30 @@ variable "STORAGE_SIZE" { type = string } +variable "EXTRA_HELM_VALUES" { + description = "Additional YAML values applied after the standard RPC values." + type = list(string) + default = [] +} + +variable "MIN_REPLICAS" { + description = "Minimum number of RPC pods kept ready by the HPA." + type = number + default = 1 +} + +variable "FORCE_UPDATE" { + description = "Whether Helm may replace resources during an upgrade." + type = bool + default = true +} + +variable "RECREATE_PODS" { + description = "Whether Helm restarts pods during an upgrade." + type = bool + default = true +} + variable "OTEL_COLLECTOR_ENDPOINT_GCP_SECRET_NAME" { description = "GCP Secret Manager secret containing the OpenTelemetry collector base URL." type = string