Skip to content
Merged
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
34 changes: 31 additions & 3 deletions spartan/aztec-network/files/config/setup-service-addresses.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions spartan/aztec-network/templates/eth/eth-beacon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions spartan/aztec-network/templates/eth/eth-execution.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions spartan/aztec-network/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ ethereum:
service:
port: 8545
targetPort: 8545
nodePort: ""
resources:
requests:
memory: "4Gi"
Expand All @@ -243,7 +242,6 @@ ethereum:
service:
port: 5052
targetPort: 5052
nodePort: ""
resources:
requests:
memory: "4Gi"
Expand Down
Loading