How to deploy a service (developer’s guide)¶
This is a guide for developers that want to deploy Octue services themselves - it is not needed if Octue manages your services for you or if you are only asking questions to existing Octue services.
What deployment enables¶
Deploying an Octue service to Google Cloud Run means it:
Is deployed as a docker container
Is ready to be asked questions by any other Octue service that has the correct permissions (you can control this)
Can ask questions to any other Octue service for which it has the correct permissions
Will automatically build and redeploy upon the conditions you provide (e.g. pushes or merges into
Will automatically start and run when Pub/Sub messages are received from the topic you created. The Pub/Sub messages can be sent from anywhere in the world, but the container will only run in the region you chose (you can create multiple Cloud Run services in different regions for the same repository if this is a problem). The Pub/Sub messages must be in the correct format (this is handled for you when
octue.resources.child.Childis used to communicate with your service).
Will automatically stop shortly after finishing the analyses asked for in the Pub/Sub message (although you can set a minimum container count so one is always running to minimise cold starts).
How to deploy¶
Ensuring you are in the desired project, go to the Google Cloud Run page and create a new service
Give your service a unique and useful name
Choose a low-carbon region that supports Eventarc triggers and is in a convenient geographic location for you (e.g. physically close to you for low latency or in a region compatible with your data protection requirements).
Click “Next”. When changes are made to the source code, we want them to be deployed automatically. So, we need to connect the repository to GCP to enable this. Select “Continuously deploy new revisions from a source repository” and then “Set up with cloud build”.
Choose your source code repository provider and the repository containing the code you’d like to deploy. You’ll have to give the provider permission to access the repository. If your provider isn’t GitHub, BitBucket, or Google Cloud Source Repositories (GCSR), you’ll need to mirror the repository to GCSR before completing this step as Google Cloud Build only supports these three providers currently.
Click “Next”, enter a regular expression for the branches you want to automatically deploy from (
mainby default). As the services will be a docker container, select “Dockerfile” and click “Save”.
Click “Next”, select “Allow internal traffic only” and “Require authentication”. This stops anyone without permission from using the service.
The service needs a trigger to start up and respond to. We’ll be using Google Pub/Sub. Click “Add eventarc trigger”, choose “Cloud Pub/Sub topic” as the trigger event, click on the menu called “Select a Cloud Pub/Sub topic”, then click “Create a topic”. Any services that want to ask your service a question will publish their question to this topic.
To create the topic ID, use python or similar to generate a new UUID, prefixing it with “octue.services.” e.g.
octue.services.3cd3298d-90f5-4bc7-bae6-3fdbe735d42a. Click “Create topic”.
Under “Invocation settings”, click on the “Service account” menu and then “Create new service account”.
Make a new service account with a related name e.g. “my-service”, then click “Create”. Add the “octue-service-user” and “Cloud Run Invoker” roles to the service account.
Click “Save” and then “Create”.