Skip to content

Commit 0e62e56

Browse files
committed
mitch/tmnt-225-create-guide-to-run-local-network-tests
1 parent 886fc52 commit 0e62e56

File tree

13 files changed

+164
-114
lines changed

13 files changed

+164
-114
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,17 @@ 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 }}
7273

7374
- name: Set up Cloud SDK
75+
if: ${{ inputs.cluster != 'kind' }}
7476
uses: google-github-actions/setup-gcloud@6189d56e4096ee891640bb02ac264be376592d6a
7577

7678
- name: Install GKE Auth Plugin
79+
if: ${{ inputs.cluster != 'kind' }}
7780
shell: bash
7881
run: |
7982
gcloud components install gke-gcloud-auth-plugin --quiet

.github/local_workflow.sh

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

33+
# Only needed when running against GKE
3334
SA_KEY_JSON=$(cat "$GOOGLE_APPLICATION_CREDENTIALS")
3435

3536
mkdir -p $REPO_ROOT/.github/.act-tool-cache

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,14 @@ on:
9696
description: RPC resource profile
9797
required: true
9898
type: string
99-
rpc_external_ingress:
100-
description: Whether to use an external ingress for the rpc
101-
required: true
102-
type: boolean
99+
103100
secrets:
104101
GCP_SA_KEY:
105102
description: The GCP service account key
106-
required: true
103+
required: false
107104
KUBECONFIG_B64:
108105
description: The base64 encoded kubeconfig
109-
required: true
106+
required: false
110107

111108
workflow_dispatch:
112109
inputs:
@@ -203,10 +200,6 @@ on:
203200
description: RPC resource profile
204201
required: true
205202
type: string
206-
rpc_external_ingress:
207-
description: Whether to use an external ingress for the rpc
208-
required: true
209-
type: boolean
210203

211204
jobs:
212205
deploy_aztec_infra:
@@ -236,7 +229,6 @@ jobs:
236229
TF_VAR_VALIDATOR_RESOURCE_PROFILE: ${{ inputs.validator_resource_profile }}
237230
TF_VAR_PROVER_RESOURCE_PROFILE: ${{ inputs.prover_resource_profile }}
238231
TF_VAR_RPC_RESOURCE_PROFILE: ${{ inputs.rpc_resource_profile }}
239-
TF_VAR_RPC_EXTERNAL_INGRESS: ${{ inputs.rpc_external_ingress }}
240232

241233
steps:
242234
- name: Debug 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 & 3 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"
@@ -156,7 +155,6 @@ jobs:
156155
validator_resource_profile: ${{ inputs.cluster == 'kind' && 'dev' || 'prod' }}
157156
prover_resource_profile: ${{ inputs.cluster == 'kind' && 'dev' || 'prod' }}
158157
rpc_resource_profile: ${{ inputs.cluster == 'kind' && 'dev' || 'prod' }}
159-
rpc_external_ingress: false
160158
run_terraform_destroy: false
161159
secrets:
162160
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}

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: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ terraform {
2121
}
2222
}
2323

24-
# Only used if deploying an RPC with an external ingress
25-
provider "google" {
26-
project = var.GCP_PROJECT
27-
region = var.GCP_REGION
28-
}
29-
3024
provider "kubernetes" {
3125
alias = "gke-cluster"
3226
config_path = "~/.kube/config"
@@ -161,10 +155,6 @@ resource "helm_release" "releases" {
161155
(var.OTEL_COLLECTOR_ENDPOINT != "" && each.key != "p2p_bootstrap") ? {
162156
"global.otelCollectorEndpoint" = var.OTEL_COLLECTOR_ENDPOINT
163157
} : {},
164-
# 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-
} : {}
168158
)
169159
content {
170160
name = set.key
@@ -182,10 +172,3 @@ resource "helm_release" "releases" {
182172
}
183173
}
184174

185-
# 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-
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ variable "RPC_RESOURCE_PROFILE" {
4949
}
5050
}
5151

52-
variable "RPC_EXTERNAL_INGRESS" {
53-
description = "Whether to use an external ingress for the rpc"
54-
type = bool
55-
default = false
56-
}
57-
5852
variable "K8S_CLUSTER_CONTEXT" {
5953
description = "GKE cluster context"
6054
type = string

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

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,13 @@ terraform {
1010
source = "hashicorp/kubernetes"
1111
version = "~> 2.24.0"
1212
}
13-
google = {
14-
source = "hashicorp/google"
15-
version = "~> 5.0"
16-
}
1713
null = {
1814
source = "hashicorp/null"
1915
version = "~> 3.2"
2016
}
2117
}
2218
}
2319

24-
provider "google" {
25-
project = var.project
26-
region = var.region
27-
}
28-
2920
provider "kubernetes" {
3021
alias = "gke-cluster"
3122
config_path = "~/.kube/config"
@@ -40,29 +31,6 @@ provider "helm" {
4031
}
4132
}
4233

43-
44-
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
52-
53-
54-
}
55-
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
62-
63-
64-
}
65-
6634
# Generate genesis files before deploying
6735
resource "null_resource" "generate_genesis" {
6836
triggers = {
@@ -123,30 +91,12 @@ resource "helm_release" "eth_devnet" {
12391
value = var.MNEMONIC
12492
}
12593

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-
14394
timeout = 300
14495
wait = true
14596
wait_for_jobs = false
14697
}
14798

14899
data "kubernetes_service" "eth_execution" {
149-
count = var.CREATE_STATIC_IPS ? 0 : 1
150100
provider = kubernetes.gke-cluster
151101

152102
metadata {
@@ -158,7 +108,6 @@ data "kubernetes_service" "eth_execution" {
158108
}
159109

160110
data "kubernetes_service" "eth_beacon" {
161-
count = var.CREATE_STATIC_IPS ? 0 : 1
162111
provider = kubernetes.gke-cluster
163112

164113
metadata {

0 commit comments

Comments
 (0)