Skip to content

Commit be1948c

Browse files
committed
add the limit to run the script only on valid regions
1 parent b198190 commit be1948c

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

experimental/serverless-fleets/init-fleet-sandbox

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#!/bin/bash
22

3+
#### Global vars
4+
# vsi_images hashmap contains the list of valid vsi-images that can be used within fleets
5+
# The fleet sandbox can be setup on regions with a valid vsi-image, only.
6+
declare -A vsi_images
7+
vsi_images["eu-de"]=r010-e7b25759-7857-455a-aec0-904b65c3c4cb
8+
vsi_images["eu-gb"]=r018-31655c46-96e7-4d38-b61a-2ab1b66b9bbd
9+
vsi_images["us-east"]=r014-b7f47448-72db-4012-b018-bb120518b078
10+
311
# Env vars
412
CLEANUP_ON_ERROR=${CLEANUP_ON_ERROR:=false}
513
CLEANUP_ON_SUCCESS=${CLEANUP_ON_SUCCESS:=false}
@@ -32,6 +40,13 @@ sysdig_key_name="${NAME_PREFIX}--sysdig-key"
3240
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
3341
source ${SCRIPT_DIR}/common.sh
3442

43+
44+
45+
46+
47+
48+
49+
3550
# Clean up previous run
3651
function clean() {
3752
(
@@ -146,6 +161,14 @@ echo "Please note: This script will install various IBM Cloud resources within t
146161
print_msg "\nChecking prerequisites ..."
147162
check_prerequisites
148163

164+
# checking if a there is a valid vsi-image in the region available
165+
vsi_image_id=${vsi_images[${REGION}]}
166+
167+
if [[ $vsi_image_id == "" || $vsi_image_id == null ]]; then
168+
echo " Fleet sandbox setup is currently not supported in region ($region), exiting setup... "
169+
exit -1
170+
fi
171+
149172
# Ensure that latest versions of used IBM Cloud ClI is installed
150173
print_msg "\nPulling latest IBM Cloud CLI release ..."
151174
ibmcloud update --force
@@ -409,16 +432,15 @@ ibmcloud ce secret create --name fleet-registry-secret --format registry --serve
409432

410433
# using the common base VSI image "jwe-ubuntu24-gpu" enabled for GPU and including podman and s3fs
411434
print_msg "\nCreating a Code Engine configmap 'fleet-vpc-config' to access the new VPC ..."
412-
# retrieve the best fitting ubuntu vsi base image by selection from available image list
413-
vsi-image-id=$(ibmcloud is images --output JSON|jq -r 'first( .[]|select(.name | startswith("ibm-ubuntu-24")) ) | .id')
435+
414436
print_msg "\nSelected the ubuntu-24 vsi image for fleets with the image-id = $vsi-image-id"
415437
ibmcloud ce configmap create --name fleet-vpc-config \
416438
--from-literal NETWORK_ZONE="${REGION}-1" \
417439
--from-literal SSH_SECRET_NAME="fleet-ssh-secret" \
418440
--from-literal VPC_ID="$(ibmcloud is vpc ${vpc_name} --output json | jq -r '.id')" \
419441
--from-literal SUBNET_ID="$(ibmcloud is subnet ${vpc_name}-subnet --output json | jq -r '.id')" \
420442
--from-literal SECURITY_GROUP_ID="$(ibmcloud is security-group ${vpc_name}-group --output json | jq -r '.id')" \
421-
--from-literal VSI_IMAGE_ID="$vsi-image-id" \
443+
--from-literal VSI_IMAGE_ID="$vsi_image_id" \
422444
--from-literal VSI_PREFERRED_PROFILE="cx2-2x4"
423445

424446
# alternative to fetch the latest stock image:

0 commit comments

Comments
 (0)