GCE leader nodes can now be provisioned with a static IP address
This commit is contained in:
parent
d9e4bce6ad
commit
ec38dba209
31
net/gce.sh
31
net/gce.sh
@ -19,6 +19,7 @@ clientAccelerator=
|
|||||||
imageName="ubuntu-16-04-cuda-9-2-new"
|
imageName="ubuntu-16-04-cuda-9-2-new"
|
||||||
publicNetwork=false
|
publicNetwork=false
|
||||||
zone="us-west1-b"
|
zone="us-west1-b"
|
||||||
|
leaderAddress=
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
exitcode=0
|
exitcode=0
|
||||||
@ -40,12 +41,13 @@ Configure a GCE-based testnet
|
|||||||
(default: $prefix)
|
(default: $prefix)
|
||||||
|
|
||||||
create-specific options:
|
create-specific options:
|
||||||
-n number - Number of validator nodes (default: $validatorNodeCount)
|
-n [number] - Number of validator nodes (default: $validatorNodeCount)
|
||||||
-c number - Number of client nodes (default: $clientNodeCount)
|
-c [number] - Number of client nodes (default: $clientNodeCount)
|
||||||
-P - Use public network IP addresses (default: $publicNetwork)
|
-P - Use public network IP addresses (default: $publicNetwork)
|
||||||
-z - GCP Zone for the nodes (default: $zone)
|
-z [zone] - GCP Zone for the nodes (default: $zone)
|
||||||
-i imageName - Existing image on GCE (default: $imageName)
|
-i [imageName] - Existing image on GCE (default: $imageName)
|
||||||
-g - Enable GPU
|
-g - Enable GPU
|
||||||
|
-a [address] - Set the leader node's external IP address to this GCE address
|
||||||
|
|
||||||
config-specific options:
|
config-specific options:
|
||||||
none
|
none
|
||||||
@ -63,7 +65,7 @@ command=$1
|
|||||||
shift
|
shift
|
||||||
[[ $command = create || $command = config || $command = delete ]] || usage "Invalid command: $command"
|
[[ $command = create || $command = config || $command = delete ]] || usage "Invalid command: $command"
|
||||||
|
|
||||||
while getopts "h?p:Pi:n:c:z:g" opt; do
|
while getopts "h?p:Pi:n:c:z:ga:" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
h | \?)
|
h | \?)
|
||||||
usage
|
usage
|
||||||
@ -89,6 +91,9 @@ while getopts "h?p:Pi:n:c:z:g" opt; do
|
|||||||
g)
|
g)
|
||||||
leaderAccelerator="count=4,type=nvidia-tesla-k80"
|
leaderAccelerator="count=4,type=nvidia-tesla-k80"
|
||||||
;;
|
;;
|
||||||
|
a)
|
||||||
|
leaderAddress=$OPTARG
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
usage "Error: unhandled option: $opt"
|
usage "Error: unhandled option: $opt"
|
||||||
;;
|
;;
|
||||||
@ -187,13 +192,17 @@ create)
|
|||||||
echo "Client(s) = $clientNodeCount x $clientMachineType (GPU=${clientAccelerator:-none})"
|
echo "Client(s) = $clientNodeCount x $clientMachineType (GPU=${clientAccelerator:-none})"
|
||||||
echo ==================================================================
|
echo ==================================================================
|
||||||
echo
|
echo
|
||||||
gcloud_CreateInstances "$prefix-leader" 1 \
|
gcloud_CreateInstances "$prefix-leader" 1 "$zone" \
|
||||||
"$zone" "$imageName" "$leaderMachineType" "$leaderAccelerator" "$here/remote/remote-startup.sh"
|
"$imageName" "$leaderMachineType" "$leaderAccelerator" \
|
||||||
gcloud_CreateInstances "$prefix-validator" "$validatorNodeCount" \
|
"$here/remote/remote-startup.sh" "$leaderAddress" \
|
||||||
"$zone" "$imageName" "$validatorMachineType" "$validatorAccelerator" "$here/remote/remote-startup.sh"
|
|
||||||
|
gcloud_CreateInstances "$prefix-validator" "$validatorNodeCount" "$zone" \
|
||||||
|
"$imageName" "$validatorMachineType" "$validatorAccelerator" \
|
||||||
|
"$here/remote/remote-startup.sh" ""
|
||||||
if [[ -n $clientNodeCount ]]; then
|
if [[ -n $clientNodeCount ]]; then
|
||||||
gcloud_CreateInstances "$prefix-client" "$clientNodeCount" \
|
gcloud_CreateInstances "$prefix-client" "$clientNodeCount" "$zone" \
|
||||||
"$zone" "$imageName" "$clientMachineType" "$clientAccelerator" "$here/remote/remote-startup.sh"
|
"$imageName" "$clientMachineType" "$clientAccelerator" \
|
||||||
|
"$here/remote/remote-startup.sh" ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
prepareInstancesAndWriteConfigFile
|
prepareInstancesAndWriteConfigFile
|
||||||
|
@ -75,7 +75,8 @@ gcloud_ForEachInstance() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# gcloud_CreateInstances [namePrefix] [numNodes] [zone] [imageName] [machineType] [accelerator] [startupScript]
|
# gcloud_CreateInstances [namePrefix] [numNodes] [zone] [imageName]
|
||||||
|
# [machineType] [accelerator] [startupScript] [address]
|
||||||
#
|
#
|
||||||
# Creates one more identical instances.
|
# Creates one more identical instances.
|
||||||
#
|
#
|
||||||
@ -87,6 +88,9 @@ gcloud_ForEachInstance() {
|
|||||||
# accelerator - Optional accelerator to attach to the instance(s), see
|
# accelerator - Optional accelerator to attach to the instance(s), see
|
||||||
# eg, request 4 K80 GPUs with "count=4,type=nvidia-tesla-k80"
|
# eg, request 4 K80 GPUs with "count=4,type=nvidia-tesla-k80"
|
||||||
# startupScript - Optional startup script to execute when the instance boots
|
# startupScript - Optional startup script to execute when the instance boots
|
||||||
|
# address - Optional name of the GCE static IP address to attach to the
|
||||||
|
# instance. Requires that |numNodes| = 1 and that addressName
|
||||||
|
# has been provisioned in the GCE region that is hosting |zone|
|
||||||
#
|
#
|
||||||
# Tip: use gcloud_FindInstances to locate the instances once this function
|
# Tip: use gcloud_FindInstances to locate the instances once this function
|
||||||
# returns
|
# returns
|
||||||
@ -98,6 +102,7 @@ gcloud_CreateInstances() {
|
|||||||
declare machineType="$5"
|
declare machineType="$5"
|
||||||
declare optionalAccelerator="$6"
|
declare optionalAccelerator="$6"
|
||||||
declare optionalStartupScript="$7"
|
declare optionalStartupScript="$7"
|
||||||
|
declare optionalAddress="$8"
|
||||||
|
|
||||||
declare nodes
|
declare nodes
|
||||||
if [[ $numNodes = 1 ]]; then
|
if [[ $numNodes = 1 ]]; then
|
||||||
@ -127,6 +132,16 @@ gcloud_CreateInstances() {
|
|||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n $optionalAddress ]]; then
|
||||||
|
[[ $numNodes = 1 ]] || {
|
||||||
|
echo "Error: address may not be supplied when provisioning multiple nodes: $optionalAddress"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
args+=(
|
||||||
|
"--address=$optionalAddress"
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
(
|
(
|
||||||
set -x
|
set -x
|
||||||
gcloud beta compute instances create "${nodes[@]}" "${args[@]}"
|
gcloud beta compute instances create "${nodes[@]}" "${args[@]}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user