Google Cloud Run Workloads with Deployment Templates in Harness

Run your Google Cloud Run Workloads with Deployment Templates in Harness

Hello, my fellow canaries, I’m one of the Product Managers for our Continuous Delivery Product and today I will be walking you all through a Google Cloud Run Deployment in Harness. @lukehertert designed this workflow leveraging our new feature Deployment Templates. Some of you may have seen our teammate @luisredda’s work on Google Cloud Functions with the Deployment Templates feature and the process is very similar.


  • Permissions to the Template Library
  • Permissions to perform Workflow, Service, and Environment Creation
  • Permission to Manage Delegate Profiles
  • Deployment Templates need to be enabled (the feature is in Beta)

Delegate Profile Configuration

# gcloud cli
echo "deb [signed-by=/usr/share/keyrings/] cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl | apt-key --keyring /usr/share/keyrings/  add - && apt-get update -y && apt-get install google-cloud-sdk -y

1. Creating the Template

Navigate to the Harness Template Library, and Select “Add Template” and click and click on Deployment Templates Type

2. Configure the Deployment Templates Type Form

  • We will be configuring how Harness will map to the user’s infrastructure and query for deployed instances on the configured infrastructure.

  • User should configure the Display Name
  • Any variables needed for Infrastructure, could be ProjectID, Region, and the type of Platform.
  • In the Fetch Instance field, we will provide the script to collect the instances deployed by Harness on the target infrastructure
  • The user will need to provide a Host Array path, this is the path in the JSON to the host object we are looking for.
  • Since Google Cloud Run doesn’t expose individual instances we treat the deployment of the service as a single instance. We identify it with the name of the service. We can use this service name in the verify step to run continuous verification.
# Script is expected to query Infrastructure and dump json
# in $INSTANCE_OUTPUT_PATH file path
# Harness is expected to initialize ${INSTANCE_OUTPUT_PATH}
# environment variable - a random unique file path on delegate,
# so script execution can save the result.

  "data": [
      "name": "${}"

This is what @lukehertert configures for us down below:

3. Configure the Service

  • User will navigate to their Harness Application and create a new service. This service will be of the type of Deployment Templates. So since we called the template Google Cloud Run, the Deployment type should appear like this:

Google Cloud Run (Custom)

  • User can configure the docker image for the Google Cloud Run Service and configure environment variables and service variables needed for deployment.

@lukehertert configures it like so:

4. Configure the Environment

  • Where are we going to deploy this service? You should navigate to your environment section and configure an Environment and an Infrastructure Definition.
  • The Infrastructure definition takes in the Infrastructure variables you configured in the Deployment Templates in step 1.

5. Configure the Workflow

  • We are going to deploy this new service to the target infrastructure we defined. In order to do so, we will create a basic workflow.
  • This workflow will already come with Fetch Instances, which allows the user to track and manage the deployed instance. It also lets the user perform CV on their deployed instances as well.

@lukehertert configures the workflow for us down below:

  • As you can see he configures a shell script step called gcloud run deploy
  • This step is actually performing the deployment
cat <<EOF | gcloud auth activate-service-account --key-file=-

gcloud run deploy ${} \
  --image=${artifact.metadata.image} \
  --allow-unauthenticated \
  --port=${serviceVariable.port} \
  --platform=${infra.custom.vars.Platform} \
  --max-instances=${serviceVariable.maxInstances} \
  --region=${infra.custom.vars.Region} \

  • With delegate selectors, the user can pick which delegates they wish to be preferenced to run the shell script.

6. Time to Deploy

  • Finally, after the configuration, we can deploy our Google Cloud Run Service!
  • Hit Deploy and you should see something like this!

@lukehertert has already deployed this :smile:

You should navigate to your Google Cloud Run instance in the GCP Console and you will see your service up and running to validate!


The new Harness Deployment Templates Type allows our users to bring in their own deployment styles and types and leverage Harness to manage the workloads and track the instances that are deployed. Users can now define how they want to deploy and how they want to monitor and verify it!

Check out the docs on Deployment Templates: Create a Custom Deployment using Deployment Templates - Docs