feat: cloud region selection in native script, rename deploy script
- wallarm-native.sh: added cloud region (US/EU) selection step during --install. Preflight now saves reachability to US_CLOUD_REACHABLE/ EU_CLOUD_REACHABLE globals, select_cloud_region() prompts user, API_HOST passed through to env file and installer. - wallarm-ct-deploy.sh renamed to wallarm-docker.sh (reflects Docker binary usage, leaves room for podman variant). - setup.sh: updated next-steps reference for renamed script.
This commit is contained in:
parent
0ee73f5af3
commit
62ddaaa9c5
3 changed files with 20 additions and 5 deletions
|
|
@ -44,6 +44,12 @@ INSTALLER_URL="${WALLARM_INSTALLER_URL:-${INSTALLER_BASE_URL}/wallarm-native-nod
|
|||
EU_DATA_NODES=("api.wallarm.com" "node-data0.eu1.wallarm.com" "node-data1.eu1.wallarm.com")
|
||||
US_DATA_NODES=("us1.api.wallarm.com" "node-data0.us1.wallarm.com" "node-data1.us1.wallarm.com")
|
||||
|
||||
# Cloud region selection (populated by preflight, used by select_cloud_region)
|
||||
US_CLOUD_REACHABLE="false"
|
||||
EU_CLOUD_REACHABLE="false"
|
||||
CLOUD_REGION=""
|
||||
API_HOST=""
|
||||
|
||||
# --- Helper functions ---
|
||||
log() { echo ">>> $*"; }
|
||||
err() { echo "!!! $*" >&2; }
|
||||
|
|
@ -87,12 +93,14 @@ EOF
|
|||
write_env_file() {
|
||||
local node_name="$1"
|
||||
local api_token="$2"
|
||||
local labels="$3"
|
||||
local api_host="$3"
|
||||
local labels="$4"
|
||||
local config_path="${NODES_DIR}/${node_name}/etc/go-node.yaml"
|
||||
local env_file="${NODES_DIR}/${node_name}/env"
|
||||
|
||||
cat > "${env_file}" <<EOF
|
||||
WALLARM_API_TOKEN=${api_token}
|
||||
WALLARM_API_HOST=${api_host}
|
||||
WALLARM_LABELS=${labels}
|
||||
WALLARM_CONFIG_PATH=${config_path}
|
||||
EOF
|
||||
|
|
@ -152,6 +160,8 @@ run_preflight() {
|
|||
local us eu
|
||||
us=$(test_cloud_endpoints "US" "${US_DATA_NODES[@]}")
|
||||
eu=$(test_cloud_endpoints "EU" "${EU_DATA_NODES[@]}")
|
||||
US_CLOUD_REACHABLE="$us"
|
||||
EU_CLOUD_REACHABLE="$eu"
|
||||
if [[ "$us" != "true" && "$eu" != "true" ]]; then
|
||||
err "Preflight failed: no Wallarm cloud region reachable (US/EU)."
|
||||
failed=1
|
||||
|
|
@ -203,7 +213,8 @@ install_single_node() {
|
|||
local node_name="$1"
|
||||
local listen_address="$2"
|
||||
local api_token="$3"
|
||||
local labels="${4:-group=${node_name}}"
|
||||
local api_host="$4"
|
||||
local labels="${5:-group=${node_name}}"
|
||||
|
||||
local work_dir="${NODES_DIR}/${node_name}"
|
||||
local installer_path="${work_dir}/wallarm-native-node-aio.sh"
|
||||
|
|
@ -230,11 +241,12 @@ EOF
|
|||
fi
|
||||
|
||||
# 3. Write environment file (used by systemd and manual scripts)
|
||||
write_env_file "${node_name}" "${api_token}" "${labels}"
|
||||
write_env_file "${node_name}" "${api_token}" "${api_host}" "${labels}"
|
||||
|
||||
# 4. Run installer
|
||||
cd "${work_dir}" || return 1
|
||||
if WALLARM_API_TOKEN="${api_token}" \
|
||||
WALLARM_API_HOST="${api_host}" \
|
||||
WALLARM_LABELS="${labels}" \
|
||||
WALLARM_CONFIG_PATH="${work_dir}/etc/go-node.yaml" \
|
||||
./wallarm-native-node-aio.sh install \
|
||||
|
|
@ -278,6 +290,9 @@ cmd_install() {
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Select Wallarm cloud region (US/EU)
|
||||
select_cloud_region
|
||||
|
||||
echo ""
|
||||
echo "Enter each node's name and listening address (format: name IP:Port)"
|
||||
echo "Example: node1 0.0.0.0:8081"
|
||||
|
|
@ -324,7 +339,7 @@ cmd_install() {
|
|||
|
||||
declare -a INSTALL_PIDS=()
|
||||
for i in "${!NODE_NAMES[@]}"; do
|
||||
install_single_node "${NODE_NAMES[$i]}" "${NODE_ADDRESSES[$i]}" "$WALLARM_API_TOKEN" &
|
||||
install_single_node "${NODE_NAMES[$i]}" "${NODE_ADDRESSES[$i]}" "$WALLARM_API_TOKEN" "$API_HOST" &
|
||||
INSTALL_PIDS+=($!)
|
||||
done
|
||||
|
||||
|
|
|
|||
2
setup.sh
2
setup.sh
|
|
@ -169,7 +169,7 @@ for deploy_type in "${DEPLOY_TYPES[@]}"; do
|
|||
docker)
|
||||
echo -e "${CYAN}Docker deployment next steps:${NC}"
|
||||
echo -e " 1. Run the preflight check: ${YELLOW}./deploy/wallarm-ct-check.sh${NC}"
|
||||
echo -e " 2. Deploy a Wallarm node: ${YELLOW}./deploy/wallarm-ct-deploy.sh${NC}"
|
||||
echo -e " 2. Deploy a Wallarm node: ${YELLOW}./deploy/wallarm-docker.sh${NC}"
|
||||
echo -e " 3. Reconfigure existing node: ${YELLOW}./deploy/wallarm-ct-reconfigure.sh${NC}"
|
||||
echo -e " 4. Uninstall a node: ${YELLOW}./deploy/wallarm-ct-uninstall.sh${NC}"
|
||||
echo
|
||||
|
|
|
|||
Loading…
Reference in a new issue