Skip to content

Commit

Permalink
Fix service account file generation and add probability parameter (#8)
Browse files Browse the repository at this point in the history
* Use tagged version of gcloud-jsonnet-cbif

* use '

* Make probability a parameter

* Update base cloudbuild image to use artifact registry

* Update IATA to oma
  • Loading branch information
robertodauria authored Aug 20, 2024
1 parent 22d7bc6 commit 3e33a68
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
steps:
# Run the deployment script. NOTE: the IATA depends on the region where the
# VM is deployed. Our testing VM is always in us-central1, which is CBF.
- name: gcr.io/$PROJECT_ID/gcloud-jsonnet-cbif
# VM is deployed. Our testing VM is always in us-central1, which is OMA.
- name: us-central1-docker.pkg.dev/$PROJECT_ID/build-images/gcloud-jsonnet-cbif:1.1
dir: '/workspace/'
args: [
'/workspace/deploy.sh $PROJECT_ID mlab ${_API_KEY}'
'/workspace/deploy.sh $PROJECT_ID mlab ${_API_KEY} ${_PROBABILITY}'
]
15 changes: 10 additions & 5 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
#!/bin/bash
set -euxo pipefail

USAGE="$0 <project> <organization> <iata> <api-key>"
USAGE="$0 <project> <organization> <api-key> <probability>"
PROJECT=${1:?Please provide the GCP project (e.g., mlab-sandbox): ${USAGE}}
ORG=${2:?Please provide the organization (e.g., mlab): ${USAGE}}
API_KEY=${3:?Please provide the API key: ${USAGE}}
PROBABILITY=${4:?Please provide the probability: ${USAGE}}

IATA="cbf"
IATA="oma"
VM_ZONE="us-central1-a"
VM_NAME="autonode"
DOCKER_COMPOSE_FILE_PATH="examples/ndt-fullstack.yml"
LOCATE_URL="locate-dot-${PROJECT}.appspot.com"
PROBABILITY="1.0"
INTERFACE_NAME="ens4"
INTERFACE_MAXRATE="150000000"
SA_ACCOUNT="autonode@${PROJECT}.iam.gserviceaccount.com"

LOCATE_URL="locate-dot-${PROJECT}.appspot.com"
if [ "$PROJECT" = "mlab-autojoin" ]; then
LOCATE_URL="locate.measurementlab.net"
fi


# NOTE: We don't use the VM's default credentials because we want to simulate
# how a non-GCP user would set up an autonode. Instead, we generate a temporary
# key for the autonode service account that will only exist until the next
Expand Down Expand Up @@ -61,7 +66,7 @@ gcloud --project ${PROJECT} compute ssh --zone ${VM_ZONE} ${VM_NAME} --tunnel-th
echo "INTERFACE_MAXRATE=${INTERFACE_MAXRATE}" >> .env
# Write service account key to the expected file.
echo "${SA_KEY}" > certs/service-account-autojoin.json
echo '${SA_KEY}' > certs/service-account-autojoin.json
# Start the docker compose again.
docker compose -f docker-compose.yml up -d
Expand Down

0 comments on commit 3e33a68

Please sign in to comment.