Skip to content

Commit e0c85ce

Browse files
committed
DOC: Rewrite "deploying services" documentation
skipci
1 parent ad56feb commit e0c85ce

File tree

1 file changed

+55
-89
lines changed

1 file changed

+55
-89
lines changed

docs/source/deploying_services.rst

Lines changed: 55 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -6,93 +6,59 @@ Deploying services (developer's guide)
66
This is a guide for developers that want to deploy Twined services themselves - it is not needed if Octue manages your
77
services for you or if you are only asking questions to existing Twined services.
88

9-
.. attention::
10-
11-
The ``octue deploy`` CLI command can be used to deploy services automatically, but it:
12-
13-
- Is in alpha so may not work as intended
14-
- Requires the ``gcloud`` CLI tool with ``Google Cloud SDK 367.0.0`` and ``beta 2021.12.10`` to be available
15-
- Requires the correct permissions via the ``gcloud`` tool logged into a Google user account and/or with an
16-
appropriate service account available
17-
18-
For now, we recommend `contacting us <https://www.octue.com/contact>`_ to help set up deployments for you.
19-
209
What deployment enables
21-
-----------------------
22-
Deploying a Twined service to Google Cloud Run means it:
23-
24-
* Is deployed as a docker container
25-
* Is ready to be asked questions by any other Twined service that has the correct permissions (you can control this)
26-
* Can ask questions to any other Twined service for which it has the correct permissions
27-
* Will automatically build and redeploy upon the conditions you provide (e.g. pushes or merges into ``main``)
28-
* Will automatically start and run when Pub/Sub messages are received from the topic you created. The Pub/Sub
29-
messages can be sent from anywhere in the world, but the container will only run in the region you chose (you can
30-
create multiple Cloud Run services in different regions for the same repository if this is a problem).
31-
* Will automatically stop shortly after finishing the analyses asked for in the Pub/Sub message (although
32-
you can set a minimum container count so one is always running to minimise cold starts).
33-
34-
How to deploy
35-
-------------
36-
1. Ensuring you are in the desired project, go to the `Google Cloud Run <https://console.cloud.google.com/run>`_ page
37-
and create a new service
38-
39-
.. image:: images/deploying_services_advanced/create_service.png
40-
41-
2. Give your service a unique name
42-
43-
.. image:: images/deploying_services_advanced/service_name_and_region.png
44-
45-
3. Choose a `low-carbon region <https://cloud.google.com/sustainability/region-carbon#data>`_ that supports Eventarc
46-
triggers and is in a convenient geographic location for you (e.g. physically close to you for low latency or in a
47-
region compatible with your data protection requirements).
48-
49-
.. image:: images/deploying_services_advanced/low_carbon_regions.png
50-
51-
3. Click "Next". When changes are made to the source code, we want them to be deployed automatically. So, we need to
52-
connect the repository to GCP to enable this. Select "Continuously deploy new revisions from a source repository" and
53-
then "Set up with cloud build".
54-
55-
.. image:: images/deploying_services_advanced/set_up_with_cloud_build.png
56-
57-
4. Choose your source code repository provider and the repository containing the code you'd like to deploy. You'll have
58-
to give the provider permission to access the repository. If your provider isn't GitHub, BitBucket, or Google Cloud
59-
Source Repositories (GCSR), you'll need to mirror the repository to GCSR before completing this step as Google Cloud
60-
Build only supports these three providers currently.
61-
62-
.. image:: images/deploying_services_advanced/choose_repository.png
63-
64-
5. Click "Next", enter a regular expression for the branches you want to automatically deploy from (``main`` by default).
65-
As the service will run in a docker container, select "Dockerfile" and click "Save".
66-
67-
.. image:: images/deploying_services_advanced/choose_dockerfile.png
68-
69-
6. Click "Next". If you want your service to be private, select "Allow internal traffic only" and "Require
70-
authentication". This stops anyone without permission from using the service.
71-
72-
.. image:: images/deploying_services_advanced/set_traffic.png
73-
74-
7. The service needs a trigger to start up and respond to. We'll be using Google Pub/Sub. Click "Add eventarc trigger",
75-
choose "Cloud Pub/Sub topic" as the trigger event, click on the menu called "Select a Cloud Pub/Sub topic", then
76-
click "Create a topic". Any services that want to ask your service a question will publish their question to this
77-
topic.
78-
79-
.. image:: images/deploying_services_advanced/create_trigger.png
80-
81-
8. The topic ID should be in the form ``octue.services.my-organisation.my-service``. Click "Create topic".
82-
83-
9. Under "Invocation settings", click on the "Service account" menu and then "Create new service account".
84-
85-
.. image:: images/deploying_services_advanced/create_service_account.png
86-
87-
10. Make a new service account with a related name e.g. "my-service", then click "Create". Add the
88-
"octue-service-user" and "Cloud Run Invoker" roles to the service account. Contact us if the "octue-service-user"
89-
role is not available.
90-
91-
.. image:: images/deploying_services_advanced/add_roles_to_service_account.png
92-
93-
11. Click "Save" and then "Create".
94-
95-
.. image:: images/deploying_services_advanced/save_and_create.png
96-
97-
12. You can now view your service in the list of `Cloud Run services <https://console.cloud.google.com/run>`_ and view
98-
its build trigger in the list of `Cloud Build triggers <https://console.cloud.google.com/cloud-build>`_.
10+
=======================
11+
Deploying a Twined service means the service:
12+
13+
* Is a docker image that is spun up and down in a Kubernetes cluster on demand
14+
* Is ready at any time to answer questions from users and other Twined services in the service network
15+
* Can ask questions to any other Twined service in the service network
16+
* Will automatically spin down after it has finished answering a question
17+
* Will automatically build and redeploy after a relevant code change (e.g. on push or merge into ``main``)
18+
19+
Prerequisites
20+
=============
21+
Twined services are currently deployable to Google Cloud Platform (GCP). You must have "owner" level access to the GCP
22+
project you're deploying to and billing must be set up for it.
23+
24+
Deploying step-by-step
25+
======================
26+
The main part of deployment is deploying the service network infrastructure. Once this is done, services can be easily
27+
added as necessary.
28+
29+
There are three steps to a deployment:
30+
31+
1. Deploy the core infrastructure (e.g. storage bucket, event store, service accounts and roles)
32+
2. Deploy the Kubernetes cluster and partner cloud functions
33+
3. Build and push service docker images to the artifact registry
34+
35+
Deploy core infrastructure
36+
--------------------------
37+
38+
- Deploy the ``terraform-octue-twined-core`` Terraform module
39+
- This only needs to be done once per service network
40+
- Follow the instructions `here <https://github.com/octue/terraform-octue-twined-core>`_
41+
42+
Deploy Kubernetes cluster
43+
-------------------------
44+
45+
- Deploy the ``terraform-octue-twined-cluster`` Terraform module
46+
- This only needs to be done once per service network
47+
- Follow the instructions `here <https://github.com/octue/terraform-octue-twined-cluster>`_
48+
49+
Build and push service docker images
50+
------------------------------------
51+
Your service is available if its docker image is in the service network's artifact registry repository. We recommend
52+
pushing a new image for each merge into the ``main`` branch, corresponding to a new service revision.
53+
54+
- Add the `build-push-twined-service <https://github.com/octue/workflows/blob/main/.github/workflows/build-twined-service.yml>`_
55+
GitHub Actions workflow to your service's GitHub repository
56+
- This needs to be done for every service you want to deploy
57+
- Follow the instructions `here <https://github.com/octue/workflows#deploying-a-kuberneteskueue-octue-twined-service-revision>`_
58+
- A live example can be `found here <https://github.com/octue/example-service-kueue/blob/main/.github/workflows/release.yml>`_
59+
including automated pre-deployment testing and release of the code on GitHub
60+
61+
What next?
62+
==========
63+
:doc:`Ask your service some questions <asking_questions>`! It will be available in the service network as
64+
``<namespace>/<name>:<version>`` (e.g. ``octue/example-service-kueue:0.1.1``).

0 commit comments

Comments
 (0)