Deploying a Container to Google Cloud
Having created the container, we now need to deploy it to the Google cloud. We create a deploy project. This was created for me, I believe from our Boilerplate Google Cloud Deployment project This project can currently only be viewed from within the University. The gitlab-ci.yml contained the following at the time of writing:
|
|
What it does is to take the deploy template from the devops CI templates in
the University GitLab (This is publicly viewable as I write this) and use them to
deploy using some environment
variables to control what is being deployed. We can see the in the deploy.yml
the CI is instructed to do a docker pull
on the container that we built, tag it with the Google container name, then
push it to the Google cloud.
There is another entry for staging, but first let’s understand development.
As the comment notes, this is expected to be triggered manually having the following variables set:
Variable | Value |
---|---|
DEPLOY_ENABLED | “development” |
WEBAPP_DOCKER_IMAGE | set to the image to deploy |
These are set in GitLab when the job is triggered. There are also some
variables set in GitLab for the development environment under
Settings->CI/CD->Variables
Notice they all
start with WEBAPP
and all end with DEVELOPMENT
. This is important
as noted in the comments in
autodevops/deploy.yml
which was included in gitlab-ci.yml
.
Variable | Value |
---|---|
WEBAPP_DEPLOY_CREDENTIALS_DEVELOPMENT | JSON snippet containing deploy credentials. These were given to me when I ran set up. |
WEBAPP_PROJECT_DEVELOPMENT | Project ID in the Google Cloud. This was given to me, the hands on guide explains how to to create it. |
WEBAPP_RUN_SERVICE_NAME_DEVELOPMENT | Service Name inside the project. The hands on guide says “etherpad” |
WEBAPP_RUN_SERVICE_REGION_DEVELOPMENT | Google Cloud Region. e.g. “europe-west1” |
WEBAPP_URL_DEVELOPMENT | Development URL. This was set up for me. |
Going to the URL now shows Etherpad rather than the unicorn picture!
This seems a little backwards - we have deployed the container into some infrastructure. How come the infrastructure was there? I know my colleague created it, but how? That is the subject of the next post.