Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 52 additions & 5 deletions spartan/terraform/deploy-rpc/environments/mainnet/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
})
Expand Down Expand Up @@ -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
}
5 changes: 5 additions & 0 deletions spartan/terraform/deploy-rpc/modules/environment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 5 additions & 0 deletions spartan/terraform/deploy-rpc/modules/environment/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}))
}
Expand Down
14 changes: 7 additions & 7 deletions spartan/terraform/deploy-rpc/modules/rpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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(
[
{
Expand Down Expand Up @@ -149,7 +149,7 @@ resource "helm_release" "rpc" {
}

node = {
logLevel = "info"
logLevel = var.LOG_LEVEL
startupProbe = {
failureThreshold = 120
}
Expand Down Expand Up @@ -212,7 +212,7 @@ resource "helm_release" "rpc" {
}
}
})
]
], var.EXTRA_HELM_VALUES)
}

resource "kubernetes_manifest" "hpa" {
Expand All @@ -229,7 +229,7 @@ resource "kubernetes_manifest" "hpa" {
kind = "StatefulSet"
name = local.workload_name
}
minReplicas = 1
minReplicas = var.MIN_REPLICAS
maxReplicas = 4
behavior = {
scaleUp = {
Expand Down
30 changes: 30 additions & 0 deletions spartan/terraform/deploy-rpc/modules/rpc/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down