|
| 1 | +terraform { |
| 2 | + backend "gcs" { |
| 3 | + bucket = "aztec-terraform" |
| 4 | + prefix = "terraform/state/eth/sepolia" |
| 5 | + } |
| 6 | + required_providers { |
| 7 | + helm = { |
| 8 | + source = "hashicorp/helm" |
| 9 | + version = "~> 3.0.2" |
| 10 | + } |
| 11 | + kubernetes = { |
| 12 | + source = "hashicorp/kubernetes" |
| 13 | + version = "~> 2.38.0" |
| 14 | + } |
| 15 | + } |
| 16 | +} |
| 17 | + |
| 18 | +provider "kubernetes" { |
| 19 | + alias = "gke-cluster" |
| 20 | + config_path = "~/.kube/config" |
| 21 | + config_context = var.K8S_CLUSTER_CONTEXT |
| 22 | +} |
| 23 | + |
| 24 | +provider "helm" { |
| 25 | + alias = "gke-cluster" |
| 26 | + kubernetes = { |
| 27 | + config_path = "~/.kube/config" |
| 28 | + config_context = var.K8S_CLUSTER_CONTEXT |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +resource "random_bytes" "jwt" { |
| 33 | + length = 32 |
| 34 | +} |
| 35 | + |
| 36 | +locals { |
| 37 | + eth_panda_ops_repo = "https://ethpandaops.github.io/ethereum-helm-charts" |
| 38 | + |
| 39 | + lighthouse_chart_ver = "1.1.7" |
| 40 | + lighthouse_image = "sigp/lighthouse:v8.0.0-rc.1" # compatible with Fusaka hardfork |
| 41 | + |
| 42 | + reth_name = "reth" # this the name of the helm installed app |
| 43 | + reth_chart_ver = "0.1.6" |
| 44 | + reth_image = "ghcr.io/paradigmxyz/reth:v1.8.2" |
| 45 | + |
| 46 | + common = yamlencode({ |
| 47 | + replicas = 1 |
| 48 | + # we have to mark it as non-sensitive otherwise we can't run for_each on helm_releases :( |
| 49 | + jwt = nonsensitive(random_bytes.jwt.hex) |
| 50 | + |
| 51 | + resources = { |
| 52 | + requests = { |
| 53 | + cpu = 2 |
| 54 | + memory = "60Gi" |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + persistence = { |
| 59 | + enabled = true |
| 60 | + size = "2Ti" |
| 61 | + storageClassName = "premium-rwo" |
| 62 | + } |
| 63 | + |
| 64 | + nodeSelector = { |
| 65 | + "node-type" = "infra" |
| 66 | + } |
| 67 | + }) |
| 68 | + |
| 69 | + helm_releases = tomap({ |
| 70 | + reth = { |
| 71 | + name = local.reth_name |
| 72 | + chart = "reth" |
| 73 | + repository = local.eth_panda_ops_repo |
| 74 | + version = local.reth_chart_ver |
| 75 | + values = [ |
| 76 | + local.common, |
| 77 | + yamlencode({ |
| 78 | + image = { |
| 79 | + pullPolicy = "Always" |
| 80 | + repository = split(":", local.reth_image)[0] |
| 81 | + tag = split(":", local.reth_image)[1] |
| 82 | + } |
| 83 | + p2pNodePort = { |
| 84 | + enabled = true |
| 85 | + port = 32000 |
| 86 | + } |
| 87 | + extraArgs = [ |
| 88 | + "--chain=sepolia", |
| 89 | + "--full" |
| 90 | + ] |
| 91 | + }) |
| 92 | + ] |
| 93 | + } |
| 94 | + |
| 95 | + lighthouse = { |
| 96 | + name = "lighthouse" |
| 97 | + chart = "lighthouse" |
| 98 | + version = local.lighthouse_chart_ver |
| 99 | + repository = local.eth_panda_ops_repo |
| 100 | + values = [ |
| 101 | + local.common, |
| 102 | + yamlencode({ |
| 103 | + image = { |
| 104 | + pullPolicy = "Always" |
| 105 | + repository = split(":", local.lighthouse_image)[0] |
| 106 | + tag = split(":", local.lighthouse_image)[1] |
| 107 | + } |
| 108 | + checkpointSync = { |
| 109 | + enabled = true |
| 110 | + url = "https://checkpoint-sync.sepolia.ethpandaops.io" |
| 111 | + } |
| 112 | + p2pNodePort = { |
| 113 | + enabled = true |
| 114 | + port = 32001 |
| 115 | + } |
| 116 | + extraArgs = [ |
| 117 | + "--execution-endpoint=http://${local.reth_name}.${var.NAMESPACE}.svc.cluster.local:8551", |
| 118 | + "--supernode", |
| 119 | + "--network=sepolia" |
| 120 | + ] |
| 121 | + }) |
| 122 | + ] |
| 123 | + } |
| 124 | + }) |
| 125 | +} |
| 126 | + |
| 127 | +# Create all helm releases using for_each |
| 128 | +resource "helm_release" "releases" { |
| 129 | + for_each = { for k, v in local.helm_releases : k => v if v != null } |
| 130 | + |
| 131 | + provider = helm.gke-cluster |
| 132 | + namespace = var.NAMESPACE |
| 133 | + |
| 134 | + name = each.value.name |
| 135 | + repository = each.value.repository |
| 136 | + chart = each.value.chart |
| 137 | + version = each.value.version |
| 138 | + |
| 139 | + values = each.value.values |
| 140 | + |
| 141 | + create_namespace = true |
| 142 | + force_update = true |
| 143 | + recreate_pods = true |
| 144 | + reuse_values = false |
| 145 | + timeout = 600 |
| 146 | + wait = false |
| 147 | +} |
0 commit comments