diff --git a/spartan/aztec-network/files/config/setup-service-addresses.sh b/spartan/aztec-network/files/config/setup-service-addresses.sh index 83118f1bf2b2..809fb760179d 100644 --- a/spartan/aztec-network/files/config/setup-service-addresses.sh +++ b/spartan/aztec-network/files/config/setup-service-addresses.sh @@ -2,8 +2,36 @@ set -ex +# Get load balancer IP for service +function get_load_balancer_ip() { + local SERVICE_LABEL=$1 + local PORT=$2 + local MAX_RETRIES=30 + local RETRY_INTERVAL=2 + local attempt=1 + + # Check load balancer exists for service + while [ $attempt -le $MAX_RETRIES ]; do + LOAD_BALANCER_IP=$(kubectl get svc -n ${NAMESPACE} -l app=${SERVICE_LABEL} -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}') + if [ -n "$LOAD_BALANCER_IP" ]; then + break + fi + echo "Attempt $attempt: Waiting for ${SERVICE_LABEL} load balancer to be available..." >&2 + sleep $RETRY_INTERVAL + attempt=$((attempt + 1)) + done + + if [ -z "$LOAD_BALANCER_IP" ]; then + echo "Error: Failed to get load balancer IP after $MAX_RETRIES attempts" >&2 + return 1 + fi + + echo "Load balancer IP: ${LOAD_BALANCER_IP}" >&2 + echo "http://${LOAD_BALANCER_IP}:${PORT}" +} + # Function to get pod and node details -get_service_address() { +function get_service_address() { local SERVICE_LABEL=$1 local PORT=$2 local MAX_RETRIES=30 @@ -56,7 +84,7 @@ get_service_address() { if [ "${EXTERNAL_ETHEREUM_HOST}" != "" ]; then ETHEREUM_ADDR="${EXTERNAL_ETHEREUM_HOST}" elif [ "${NETWORK_PUBLIC}" = "true" ]; then - ETHEREUM_ADDR=$(get_service_address "eth-execution" "${ETHEREUM_PORT}") + ETHEREUM_ADDR=$(get_load_balancer_ip "eth-execution" "${ETHEREUM_PORT}") else ETHEREUM_ADDR="http://${SERVICE_NAME}-eth-execution.${NAMESPACE}:${ETHEREUM_PORT}" fi @@ -65,7 +93,7 @@ fi if [ "${EXTERNAL_ETHEREUM_CONSENSUS_HOST}" != "" ]; then ETHEREUM_CONSENSUS_ADDR="${EXTERNAL_ETHEREUM_CONSENSUS_HOST}" elif [ "${NETWORK_PUBLIC}" = "true" ]; then - ETHEREUM_CONSENSUS_ADDR=$(get_service_address "eth-beacon" "${ETHEREUM_CONSENSUS_PORT}") + ETHEREUM_CONSENSUS_ADDR=$(get_load_balancer_ip "eth-beacon" "${ETHEREUM_CONSENSUS_PORT}") else ETHEREUM_CONSENSUS_ADDR="http://${SERVICE_NAME}-eth-beacon.${NAMESPACE}:${ETHEREUM_CONSENSUS_PORT}" fi diff --git a/spartan/aztec-network/templates/eth/eth-beacon.yaml b/spartan/aztec-network/templates/eth/eth-beacon.yaml index 8ab5d89e41d6..8eba410e83c1 100644 --- a/spartan/aztec-network/templates/eth/eth-beacon.yaml +++ b/spartan/aztec-network/templates/eth/eth-beacon.yaml @@ -61,6 +61,7 @@ metadata: name: {{ include "aztec-network.fullname" . }}-eth-beacon labels: {{- include "aztec-network.labels" . | nindent 4 }} + app: eth-beacon spec: {{- if .Values.network.public}} type: LoadBalancer diff --git a/spartan/aztec-network/templates/eth/eth-execution.yaml b/spartan/aztec-network/templates/eth/eth-execution.yaml index 6c4e475936b0..83dcf7a3f41f 100644 --- a/spartan/aztec-network/templates/eth/eth-execution.yaml +++ b/spartan/aztec-network/templates/eth/eth-execution.yaml @@ -65,6 +65,7 @@ metadata: name: {{ include "aztec-network.fullname" . }}-eth-execution labels: {{- include "aztec-network.labels" . | nindent 4 }} + app: eth-execution spec: {{- if .Values.network.public }} type: LoadBalancer diff --git a/spartan/aztec-network/values.yaml b/spartan/aztec-network/values.yaml index c660769756f0..2748786292c1 100644 --- a/spartan/aztec-network/values.yaml +++ b/spartan/aztec-network/values.yaml @@ -233,7 +233,6 @@ ethereum: service: port: 8545 targetPort: 8545 - nodePort: "" resources: requests: memory: "4Gi" @@ -243,7 +242,6 @@ ethereum: service: port: 5052 targetPort: 5052 - nodePort: "" resources: requests: memory: "4Gi"