Closed troyraen closed 1 year ago
instruct Cloud Build to containerize the module and deploy it to Cloud Run
The script can skip this step until that stuff is added to the repo. (Update: this was added in #6. The deployment code is repeated below for convenience.)
Additional files may need to be added as well. For example, the script will need access to the file that defines the BigQuery table schema.
Here is the code to deploy to Cloud Run. Specifically, this will:
moduledir="classifier" # assumes we're in the repo's root dir
config="${moduledir}/cloudbuild.yaml"
gcloud builds submit --config="${config}" \
--substitutions=_SURVEY="${SURVEY}",_TESTID="${TESTID}" \
"${moduledir}"
Once that deploys, the Cloud Run module's URL will be printed to the screen. We need that URL in order to create the Pub/Sub subscription that will trigger this module. I am working on automating this, but for now, the URL must be manually copy-pasted into the following code in order to create the subscription:
subscrip="elasticc-loop-${TESTID}"
topic="elasticc-loop"
topic_project="avid-heading-329016"
url="<copy-paste the Cloud Run URL here>"
route="/"
runinvoker_svcact="cloud-run-invoker@${GOOGLE_CLOUD_PROJECT}.iam.gserviceaccount.com"
gcloud pubsub subscriptions create "${subscrip}" \
--topic "${topic}" \
--topic-project "${topic_project}" \
--ack-deadline=600 \
--push-endpoint="${url}${route}" \
--push-auth-service-account="${runinvoker_svcact}"
The Cloud Run module will be active as soon as the subscription is created. To stop the Cloud Run module, you must delete the trigger subscription:
gcloud pubsub subscriptions delete "${subscrip}"
@hernandezc1 when creating the Pub/Sub subscription with the code above, pay attention to the subscrip
, topic
, and topic_project
variables (in addition to the url
). You will need to change them in order to test this module in the way that we talked about testing it on Zoom today.
Note that the way I have those variables set above will work (what will it do, exactly?), or to be more specific, it should work and that is a test we will want to run in addition to the one we talked about today (why do we need to do both?). But first you should do it the way we talked about today.
completed in #9
Add a deployment script + instructions for its use.
The script should:
For now, we should put in a script similar to the one we use to deploy a broker instance.
Eventually we will want to replace this with something cleaner that uses Cloud Workflows, Cloud Build, and/or Terraform.