-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: public network deployments (#10089)
A helm deploy with `--set network.public=true` will create a network that may be joined from public internet.
- Loading branch information
1 parent
a0551ee
commit 570f70a
Showing
25 changed files
with
700 additions
and
444 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/sh | ||
|
||
POD_NAME=$(echo $HOSTNAME) | ||
|
||
if [ "${NETWORK_PUBLIC}" = "true" ]; then | ||
# First try treating HOSTNAME as a pod name | ||
NODE_NAME=$(kubectl get pod $POD_NAME -n ${NAMESPACE} -o jsonpath='{.spec.nodeName}' 2>/dev/null) | ||
|
||
# If that fails, HOSTNAME might be the node name itself | ||
if [ $? -ne 0 ]; then | ||
echo "Could not find pod $POD_NAME, assuming $POD_NAME is the node name" | ||
NODE_NAME=$POD_NAME | ||
fi | ||
|
||
EXTERNAL_IP=$(kubectl get node $NODE_NAME -o jsonpath='{.status.addresses[?(@.type=="ExternalIP")].address}') | ||
|
||
if [ -z "$EXTERNAL_IP" ]; then | ||
echo "Warning: Could not find ExternalIP, falling back to InternalIP" | ||
EXTERNAL_IP=$(kubectl get node $NODE_NAME -o jsonpath='{.status.addresses[?(@.type=="InternalIP")].address}') | ||
fi | ||
|
||
TCP_ADDR="${EXTERNAL_IP}:${P2P_TCP_PORT}" | ||
UDP_ADDR="${EXTERNAL_IP}:${P2P_UDP_PORT}" | ||
|
||
else | ||
# Get pod IP for non-public networks | ||
POD_IP=$(hostname -i) | ||
TCP_ADDR="${POD_IP}:${P2P_TCP_PORT}" | ||
UDP_ADDR="${POD_IP}:${P2P_UDP_PORT}" | ||
fi | ||
|
||
# Write addresses to file for sourcing | ||
echo "export P2P_TCP_ANNOUNCE_ADDR=${TCP_ADDR}" > /shared/p2p/p2p-addresses | ||
echo "export P2P_TCP_LISTEN_ADDR=0.0.0.0:${P2P_TCP_PORT}" >> /shared/p2p/p2p-addresses | ||
echo "export P2P_UDP_ANNOUNCE_ADDR=${UDP_ADDR}" >> /shared/p2p/p2p-addresses | ||
echo "export P2P_UDP_LISTEN_ADDR=0.0.0.0:${P2P_UDP_PORT}" >> /shared/p2p/p2p-addresses | ||
|
||
echo "P2P addresses configured:" | ||
cat /shared/p2p/p2p-addresses |
88 changes: 88 additions & 0 deletions
88
spartan/aztec-network/files/config/setup-service-addresses.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
# Function to get pod and node details | ||
get_service_address() { | ||
local SERVICE_LABEL=$1 | ||
local PORT=$2 | ||
local MAX_RETRIES=30 | ||
local RETRY_INTERVAL=2 | ||
local attempt=1 | ||
|
||
# Get pod name | ||
while [ $attempt -le $MAX_RETRIES ]; do | ||
POD_NAME=$(kubectl get pods -n ${NAMESPACE} -l app=${SERVICE_LABEL} -o jsonpath='{.items[0].metadata.name}') | ||
if [ -n "$POD_NAME" ]; then | ||
break | ||
fi | ||
echo "Attempt $attempt: Waiting for ${SERVICE_LABEL} pod to be available..." >&2 | ||
sleep $RETRY_INTERVAL | ||
attempt=$((attempt + 1)) | ||
done | ||
|
||
if [ -z "$POD_NAME" ]; then | ||
echo "Error: Failed to get ${SERVICE_LABEL} pod name after $MAX_RETRIES attempts" >&2 | ||
return 1 | ||
fi | ||
echo "Pod name: [${POD_NAME}]" >&2 | ||
|
||
# Get node name | ||
attempt=1 | ||
NODE_NAME="" | ||
while [ $attempt -le $MAX_RETRIES ]; do | ||
NODE_NAME=$(kubectl get pod ${POD_NAME} -n ${NAMESPACE} -o jsonpath='{.spec.nodeName}') | ||
if [ -n "$NODE_NAME" ]; then | ||
break | ||
fi | ||
echo "Attempt $attempt: Waiting for node name to be available..." >&2 | ||
sleep $RETRY_INTERVAL | ||
attempt=$((attempt + 1)) | ||
done | ||
|
||
if [ -z "$NODE_NAME" ]; then | ||
echo "Error: Failed to get node name after $MAX_RETRIES attempts" >&2 | ||
return 1 | ||
fi | ||
echo "Node name: ${NODE_NAME}" >&2 | ||
|
||
# Get the node's external IP | ||
NODE_IP=$(kubectl get node ${NODE_NAME} -o jsonpath='{.status.addresses[?(@.type=="ExternalIP")].address}') | ||
echo "Node IP: ${NODE_IP}" >&2 | ||
echo "http://${NODE_IP}:${PORT}" | ||
} | ||
|
||
# Configure Ethereum address | ||
if [ "${ETHEREUM_EXTERNAL_HOST}" != "" ]; then | ||
ETHEREUM_ADDR="${ETHEREUM_EXTERNAL_HOST}" | ||
elif [ "${NETWORK_PUBLIC}" = "true" ]; then | ||
ETHEREUM_ADDR=$(get_service_address "ethereum" "${ETHEREUM_PORT}") | ||
else | ||
ETHEREUM_ADDR="http://${SERVICE_NAME}-ethereum.${NAMESPACE}:${ETHEREUM_PORT}" | ||
fi | ||
|
||
# Configure Boot Node address | ||
if [ "${BOOT_NODE_EXTERNAL_HOST}" != "" ]; then | ||
BOOT_NODE_ADDR="${BOOT_NODE_EXTERNAL_HOST}" | ||
elif [ "${NETWORK_PUBLIC}" = "true" ]; then | ||
BOOT_NODE_ADDR=$(get_service_address "boot-node" "${BOOT_NODE_PORT}") | ||
else | ||
BOOT_NODE_ADDR="http://${SERVICE_NAME}-boot-node.${NAMESPACE}:${BOOT_NODE_PORT}" | ||
fi | ||
|
||
# Configure Prover Node address | ||
if [ "${PROVER_NODE_EXTERNAL_HOST}" != "" ]; then | ||
PROVER_NODE_ADDR="${PROVER_NODE_EXTERNAL_HOST}" | ||
elif [ "${NETWORK_PUBLIC}" = "true" ]; then | ||
PROVER_NODE_ADDR=$(get_service_address "prover-node" "${PROVER_NODE_PORT}") | ||
else | ||
PROVER_NODE_ADDR="http://${SERVICE_NAME}-prover-node.${NAMESPACE}:${PROVER_NODE_PORT}" | ||
fi | ||
|
||
|
||
# Write addresses to file for sourcing | ||
echo "export ETHEREUM_HOST=${ETHEREUM_ADDR}" >> /shared/config/service-addresses | ||
echo "export BOOT_NODE_HOST=${BOOT_NODE_ADDR}" >> /shared/config/service-addresses | ||
echo "export PROVER_NODE_HOST=${PROVER_NODE_ADDR}" >> /shared/config/service-addresses | ||
echo "Addresses configured:" | ||
cat /shared/config/service-addresses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.