Skip to content

Commit 476ef9d

Browse files
committed
mitch/tmnt-225-create-guide-to-run-local-network-tests
1 parent 05b7c52 commit 476ef9d

File tree

12 files changed

+188
-82
lines changed

12 files changed

+188
-82
lines changed

.github/actions/setup-k8s-terraform/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ runs:
6666
ref: ${{ inputs.ref }}
6767

6868
- name: Authenticate to Google Cloud
69+
if: ${{ inputs.cluster != 'kind' }}
6970
uses: google-github-actions/auth@6fc4af4b145ae7821d527454aa9bd537d1f2dc5f
7071
with:
7172
credentials_json: ${{ inputs.gcp_sa_key }}

.github/local_workflow.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fi
3030
shift
3131
args=("$@")
3232

33-
SA_KEY_JSON=$(cat "$GOOGLE_APPLICATION_CREDENTIALS")
33+
# SA_KEY_JSON=$(cat "$GOOGLE_APPLICATION_CREDENTIALS")
3434

3535
mkdir -p $REPO_ROOT/.github/.act-tool-cache
3636

.github/workflows/deploy-aztec-infra.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ on:
103103
secrets:
104104
GCP_SA_KEY:
105105
description: The GCP service account key
106-
required: true
106+
required: false
107107
KUBECONFIG_B64:
108108
description: The base64 encoded kubeconfig
109-
required: true
109+
required: false
110110

111111
workflow_dispatch:
112112
inputs:

.github/workflows/deploy-eth-devnet.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ on:
4747
description: Resource profile to use (dev or prod)
4848
required: true
4949
type: string
50-
create_static_ips:
51-
description: Whether to create static IPs as part of the eth devnet for the execution and beacon nodes
52-
required: true
53-
type: string
50+
5451
run_terraform_destroy:
5552
description: Whether to run the terraform destroy
5653
required: false
@@ -69,7 +66,7 @@ on:
6966
secrets:
7067
GCP_SA_KEY:
7168
description: The JSON key for the GCP service account
72-
required: true
69+
required: false
7370
KUBECONFIG_B64:
7471
description: The base64 encoded kubeconfig
7572
required: true
@@ -120,10 +117,7 @@ on:
120117
description: Resource profile to use (dev or prod)
121118
required: true
122119
type: string
123-
create_static_ips:
124-
description: Whether to create static IPs as part of the eth devnet for the execution and beacon nodes
125-
required: true
126-
type: string
120+
127121
run_terraform_destroy:
128122
description: Whether to run the terraform destroy
129123
required: false

.github/workflows/deploy-rollup-contracts.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ on:
112112
secrets:
113113
GCP_SA_KEY:
114114
description: The JSON key for the GCP service account
115-
required: true
115+
required: false
116116
KUBECONFIG_B64:
117117
description: The base64 encoded kubeconfig
118-
required: true
118+
required: false
119119
outputs:
120120
registry_address:
121121
description: The address of the registry contract

.github/workflows/deploy-scenario-network.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ on:
3535
secrets:
3636
GCP_SA_KEY:
3737
description: The JSON key for the GCP service account
38-
required: true
38+
required: false
3939
KUBECONFIG_B64:
4040
description: The base64 encoded kubeconfig
4141
required: false
@@ -87,7 +87,6 @@ jobs:
8787
block_time: 12
8888
gas_limit: "32000000"
8989
resource_profile: ${{ inputs.cluster == 'kind' && 'dev' || 'prod' }}
90-
create_static_ips: false
9190
run_terraform_destroy: false
9291
mnemonic: ${{ inputs.devnet_mnemonic }}
9392
prefunded_mnemonic_indices: "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1000,1001,1002,1003"

spartan/scripts/install_deps.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
11
#!/usr/bin/env bash
2+
echo "Installing dependencies..."
23
source $(git rev-parse --show-toplevel)/ci3/source
4+
echo "Source loaded"
35

46
os=$(uname | awk '{print tolower($0)}')
57

68
# if kubectl is not installed, install it
79
if ! command -v kubectl &> /dev/null; then
10+
echo "Installing kubectl..."
811
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/${os}/$(arch)/kubectl"
912
chmod +x kubectl
1013
sudo mv kubectl /usr/local/bin/kubectl
1114
fi
1215

1316
# Install kind if it is not installed
1417
if ! command -v kind &> /dev/null; then
18+
echo "Installing kind..."
1519
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.23.0/kind-${os}-$(arch)
1620
chmod +x ./kind
1721
sudo mv ./kind /usr/local/bin/kind
1822
fi
1923

2024
# Install helm if it is not installed
2125
if ! command -v helm &> /dev/null; then
26+
echo "Installing helm..."
2227
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
2328
chmod +x get_helm.sh
2429
sudo ./get_helm.sh
2530
rm get_helm.sh
2631
fi
2732

2833
if ! command -v stern &> /dev/null; then
34+
echo "Installing stern..."
2935
# Download Stern
3036
curl -Lo stern.tar.gz https://github.com/stern/stern/releases/download/v1.31.0/stern_1.31.0_${os}_$(arch).tar.gz
3137

@@ -44,6 +50,7 @@ if ! command -v stern &> /dev/null; then
4450
fi
4551

4652
if ! command -v gcloud &> /dev/null; then
53+
echo "Installing gcloud..."
4754
curl -Lo google-cloud-cli.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-$os-$(arch).tar.gz
4855
tar -xzf google-cloud-cli.tar.gz
4956
rm google-cloud-cli.tar.gz
@@ -57,10 +64,21 @@ fi
5764

5865
# Install GKE auth plugin for kubectl
5966
if command -v gcloud &> /dev/null; then
60-
if dpkg -l google-cloud-cli 2>/dev/null | grep -q "^ii"; then
61-
sudo apt-get update
62-
sudo apt-get install -y google-cloud-cli-gke-gcloud-auth-plugin
67+
# Check if GKE auth plugin is already installed
68+
if command -v gke-gcloud-auth-plugin &> /dev/null ||
69+
gcloud components list --filter="id:gke-gcloud-auth-plugin" --format="value(state.name)" 2>/dev/null | grep -q "Installed"; then
70+
: # do nothing
71+
elif dpkg -l google-cloud-cli 2>/dev/null | grep -q "^ii"; then
72+
# Check if apt package is already installed
73+
if dpkg -l google-cloud-cli-gke-gcloud-auth-plugin 2>/dev/null | grep -q "^ii"; then
74+
: # do nothing
75+
else
76+
echo "Installing GKE auth plugin for kubectl via apt..."
77+
sudo apt-get update
78+
sudo apt-get install -y google-cloud-cli-gke-gcloud-auth-plugin
79+
fi
6380
else
81+
echo "Installing GKE auth plugin for kubectl via gcloud components..."
6482
gcloud components install gke-gcloud-auth-plugin
6583
fi
6684
fi

spartan/terraform/deploy-aztec-infra/main.tf

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ terraform {
2222
}
2323

2424
# Only used if deploying an RPC with an external ingress
25-
provider "google" {
26-
project = var.GCP_PROJECT
27-
region = var.GCP_REGION
28-
}
25+
# provider "google" {
26+
# project = var.GCP_PROJECT
27+
# region = var.GCP_REGION
28+
# }
2929

3030
provider "kubernetes" {
3131
alias = "gke-cluster"
@@ -162,9 +162,9 @@ resource "helm_release" "releases" {
162162
"global.otelCollectorEndpoint" = var.OTEL_COLLECTOR_ENDPOINT
163163
} : {},
164164
# Add RPC ingress annotation if needed
165-
(each.key == "rpc" && var.RPC_EXTERNAL_INGRESS && length(google_compute_address.rpc_ingress) > 0) ? {
166-
"service.ingress.annotations.networking\\.gke\\.io\\/load-balancer-ip-addresses" = google_compute_address.rpc_ingress[0].name
167-
} : {}
165+
# (each.key == "rpc" && var.RPC_EXTERNAL_INGRESS) ? {
166+
# "service.ingress.annotations.networking\\.gke\\.io\\/load-balancer-ip-addresses" = data.kubernetes_service.rpc.spec[0].cluster_ip
167+
# } : {}
168168
)
169169
content {
170170
name = set.key
@@ -183,9 +183,9 @@ resource "helm_release" "releases" {
183183
}
184184

185185
# Keep the Google Compute Address as separate resource
186-
resource "google_compute_address" "rpc_ingress" {
187-
count = var.RPC_EXTERNAL_INGRESS ? 1 : 0
188-
provider = google
189-
name = "${var.NAMESPACE}-${var.RELEASE_PREFIX}-rpc-ingress"
190-
address_type = "EXTERNAL"
191-
}
186+
# resource "google_compute_address" "rpc_ingress" {
187+
# count = var.RPC_EXTERNAL_INGRESS ? 1 : 0
188+
# provider = google
189+
# name = "${var.NAMESPACE}-${var.RELEASE_PREFIX}-rpc-ingress"
190+
# address_type = "EXTERNAL"
191+
# }

spartan/terraform/deploy-eth-devnet/main.tf

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ terraform {
2121
}
2222
}
2323

24-
provider "google" {
25-
project = var.project
26-
region = var.region
27-
}
2824

2925
provider "kubernetes" {
3026
alias = "gke-cluster"
@@ -40,28 +36,33 @@ provider "helm" {
4036
}
4137
}
4238

39+
# TODO: move this to a separate workflow so the GCP service account is not needed
40+
# provider "google" {
41+
# project = var.project
42+
# region = var.region
43+
# }
4344

4445

45-
# Static IP addresses for eth-devnet services
46-
resource "google_compute_address" "eth_execution_ip" {
47-
count = var.CREATE_STATIC_IPS ? 1 : 0
48-
provider = google
49-
name = "${var.NAMESPACE}-${var.RELEASE_PREFIX}-execution-ip"
50-
address_type = "EXTERNAL"
51-
region = var.region
46+
# # Static IP addresses for eth-devnet services
47+
# resource "google_compute_address" "eth_execution_ip" {
48+
# count = var.CREATE_STATIC_IPS ? 1 : 0
49+
# provider = google
50+
# name = "${var.NAMESPACE}-${var.RELEASE_PREFIX}-execution-ip"
51+
# address_type = "EXTERNAL"
52+
# region = var.region
5253

5354

54-
}
55+
# }
5556

56-
resource "google_compute_address" "eth_beacon_ip" {
57-
count = var.CREATE_STATIC_IPS ? 1 : 0
58-
provider = google
59-
name = "${var.NAMESPACE}-${var.RELEASE_PREFIX}-beacon-ip"
60-
address_type = "EXTERNAL"
61-
region = var.region
57+
# resource "google_compute_address" "eth_beacon_ip" {
58+
# count = var.CREATE_STATIC_IPS ? 1 : 0
59+
# provider = google
60+
# name = "${var.NAMESPACE}-${var.RELEASE_PREFIX}-beacon-ip"
61+
# address_type = "EXTERNAL"
62+
# region = var.region
6263

6364

64-
}
65+
# }
6566

6667
# Generate genesis files before deploying
6768
resource "null_resource" "generate_genesis" {
@@ -123,30 +124,12 @@ resource "helm_release" "eth_devnet" {
123124
value = var.MNEMONIC
124125
}
125126

126-
127-
dynamic "set" {
128-
for_each = var.CREATE_STATIC_IPS ? [1] : []
129-
content {
130-
name = "ethereum.execution.service.loadBalancerIP"
131-
value = google_compute_address.eth_execution_ip[0].address
132-
}
133-
}
134-
135-
dynamic "set" {
136-
for_each = var.CREATE_STATIC_IPS ? [1] : []
137-
content {
138-
name = "ethereum.beacon.service.loadBalancerIP"
139-
value = google_compute_address.eth_beacon_ip[0].address
140-
}
141-
}
142-
143127
timeout = 300
144128
wait = true
145129
wait_for_jobs = false
146130
}
147131

148132
data "kubernetes_service" "eth_execution" {
149-
count = var.CREATE_STATIC_IPS ? 0 : 1
150133
provider = kubernetes.gke-cluster
151134

152135
metadata {
@@ -158,7 +141,6 @@ data "kubernetes_service" "eth_execution" {
158141
}
159142

160143
data "kubernetes_service" "eth_beacon" {
161-
count = var.CREATE_STATIC_IPS ? 0 : 1
162144
provider = kubernetes.gke-cluster
163145

164146
metadata {

spartan/terraform/deploy-eth-devnet/outputs.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
output "eth_execution_ip" {
22
description = "IP address for Ethereum execution client (Static IP or Cluster IP)"
3-
value = var.CREATE_STATIC_IPS ? google_compute_address.eth_execution_ip[0].address : data.kubernetes_service.eth_execution[0].spec[0].cluster_ip
3+
value = data.kubernetes_service.eth_execution.spec[0].cluster_ip
44
}
55

66
output "eth_beacon_ip" {
77
description = "IP address for Ethereum beacon client (Static IP or Cluster IP)"
8-
value = var.CREATE_STATIC_IPS ? google_compute_address.eth_beacon_ip[0].address : data.kubernetes_service.eth_beacon[0].spec[0].cluster_ip
8+
value = data.kubernetes_service.eth_beacon.spec[0].cluster_ip
99
}
1010

1111
output "eth_execution_rpc_url" {
1212
description = "Ethereum execution RPC URL"
13-
value = var.CREATE_STATIC_IPS ? "http://${google_compute_address.eth_execution_ip[0].address}:8545" : "http://${data.kubernetes_service.eth_execution[0].spec[0].cluster_ip}:8545"
13+
value = "http://${data.kubernetes_service.eth_execution.spec[0].cluster_ip}:8545"
1414
}
1515

1616
output "eth_execution_ws_url" {
1717
description = "Ethereum execution WebSocket URL"
18-
value = var.CREATE_STATIC_IPS ? "ws://${google_compute_address.eth_execution_ip[0].address}:8546" : "ws://${data.kubernetes_service.eth_execution[0].spec[0].cluster_ip}:8546"
18+
value = "ws://${data.kubernetes_service.eth_execution.spec[0].cluster_ip}:8546"
1919
}
2020

2121
output "eth_beacon_api_url" {
2222
description = "Ethereum beacon API URL"
23-
value = var.CREATE_STATIC_IPS ? "http://${google_compute_address.eth_beacon_ip[0].address}:5052" : "http://${data.kubernetes_service.eth_beacon[0].spec[0].cluster_ip}:5052"
23+
value = "http://${data.kubernetes_service.eth_beacon.spec[0].cluster_ip}:5052"
2424
}
2525

2626
output "chain_id" {

0 commit comments

Comments
 (0)