Skip to content

gcloud setup deploy cloud run pipeline

devonfw-core edited this page Dec 30, 2022 · 4 revisions

Setting up a Deploy in Cloud Run pipeline on Google Cloud

In this section we will create a pipeline to deploy the project application as a service in Google Cloud Run. This pipeline will be configured in order to be triggered every time package pipeline is executed successfully on a commit for `release/*` and `develop` branches, requiring manual launch for other branches.

The creation of the pipeline will follow the project workflow, so a new branch named feature/deploy-cloud-run will be created and the YAML file for the pipeline will be pushed to it.

Then, the new branch will be merged into the appropriate branch (provided in -b flag).

The script located at /scripts/pipelines/gcloud/pipeline_generator.sh will automatically create this new branch, create a deploy pipeline based on a YAML template appropriate for targeting Cloud Run, create the Pull Request and, if it is possible, merge this new branch into the specified branch.

Prerequisites

  • This script will commit and push the corresponding YAML template into your repository, so please be sure your local repository is up-to-date (i.e you have pulled latest changes with git pull).

  • This pipeline consumes variables set by the package pipeline, so be sure to correctly setup it before creating this one.

Creating the pipeline using provided script

Usage

pipeline_generator.sh \
  -c <config file path> \
  -n <{pipeline_type} name> \
  -d <project local path> \
  --service-name  <service name> \
  --gcloud-region <gcloud region> \
  [--package-pipeline-name <{pipeline_type} name>] \
  [--port <listening port>] \
  [-b <branch>] \
  [-m <machine type for {pipeline_type} runner>]]
  [--env-vars <env vars list>]
  [--secret-vars <secret vars list>]
Note
The config file for the deploy pipeline is located at /scripts/pipelines/gcloud/templates/deploy-cloud-run/deploy-cloud-run-pipeline.cfg.
Note
For this pipeline, the environment and secret variables will be made available on the containers created in Cloud Run.

Flags

-c, --config-file            [Required] Configuration file containing {pipeline_type} definition.
-n, --pipeline-name          [Required] Name that will be set to the {pipeline_type}.
-d, --local-directory        [Required] Local directory of your project.
    --service-name           [Required] Name for the Cloud Run service.
    --gcloud-region          [Required] Region where the service will be deployed.
    --package-pipeline-name             Package {pipeline_type} name.
    --port                              Listening port of the service. Default: 8080.
-b, --target-branch                     Name of the branch to which the Pull Request will target. PR is not created if the flag is not provided.
-m, --machine-type                      Machine type for {pipeline_type} runner. Accepted values: E2_HIGHCPU_8, E2_HIGHCPU_32, N1_HIGHCPU_8, N1_HIGHCPU_32.]
    --env-vars                          List of environment variables to be made available in pipeline. Syntax: "var1=val1 var2=val2 ...".
    --secret-vars                       List of environment variables (saved as secrets in Secret Manager) to be made available in pipeline. Syntax: "var1=val1 var2=val2 ...".

Examples

./pipeline_generator.sh -c ./templates/deploy-cloud-run/deploy-cloud-run-pipeline.cfg -n project-deploy -d C:/Users/$USERNAME/Desktop/project --service-name application --gcloud-region europe-southwest1 --port 80 -b develop {openBrowserFlag}

Guides per provider

Clone this wiki locally