> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/3.0/use-deployments/google-cloud-functions.md).

# Google Cloud Functions

Deploy and manage Google Cloud Functions using Harness CD.

A Google Cloud Functions stage deploys a function to Google Cloud. You define the function definition manifest, the runtime environment version, and the artifact source, and Harness manages the deployment and rollback steps for the strategy you select.

***

### Set up a Google Cloud Functions deployment <a href="#set-up-a-google-cloud-functions-deployment" id="set-up-a-google-cloud-functions-deployment"></a>

Follow these steps to create a pipeline with a Deploy stage that targets Google Cloud Functions.

1. Go to **Pipelines** and click **Create Pipeline**.
2. Enter a pipeline name. Under **Storage**, select **Inline** or a Git repository. Click **Start**. Harness creates an empty pipeline with no stages.
3. Select **Add Stage**, then select **Deploy**.
4. In **Specify details**, enter a stage name and set **Deployment Target** to **Google Cloud Functions**. Click **Next**.

The wizard walks you through configuring the service, environment, and execution strategy in sequence. Once you select a strategy, the wizard shows the runtime option for the stage. Save the stage to open it in the pipeline studio, where the steps for that strategy are already set up and ready to configure.

***

### Service <a href="#service" id="service"></a>

A **service** represents what you deploy. For Google Cloud Functions, it holds the function definition manifest linked from your Git repository, the Google Cloud Function environment version, and the artifact source Harness fetches at deploy time. Services are independent of pipelines. Configure one once and reuse it across stages and pipelines.

Go to Google Cloud Functions services to configure the function definition manifest and artifact source.

***

### Environment and infrastructure <a href="#environment-and-infrastructure" id="environment-and-infrastructure"></a>

An **environment** is a logical deployment target such as development, staging, or production. An **infrastructure definition** within an environment points to the specific target where Harness deploys.

Go to Google Cloud Functions infrastructure to configure environments, infrastructure definitions, and authentication.

***

### Deployment strategies <a href="#deployment-strategies" id="deployment-strategies"></a>

Harness supports the following strategies for Google Cloud Functions:

| Strategy         | What it does                                                                                        |
| ---------------- | --------------------------------------------------------------------------------------------------- |
| **Basic**        | Deploys a new function revision and routes full traffic to it immediately.                          |
| **Canary**       | Progressively shifts traffic to a new function revision before completing the cutover.              |
| **Blue-green**   | Deploys a new function revision without traffic, then shifts all traffic to it in a single cutover. |
| **Blank canvas** | No managed step sequence, compose steps manually without a managed strategy.                        |

Go to Deployment strategies to configure each strategy.

***

### Stage settings <a href="#stage-settings" id="stage-settings"></a>

Each stage has settings accessible from the stage editor: **Inputs & outputs** and **Execution controls**. The **Runtime Environment** option is set in the wizard right after you select a deployment strategy, and remains editable from the stage editor afterward.

#### Inputs & outputs <a href="#inputs-and-outputs" id="inputs-and-outputs"></a>

The **Inputs & outputs** section defines the stage's inputs, environment variables, and outputs. Use this section to declare values the stage accepts as runtime inputs, environment variables available to step containers during execution, and outputs the stage exposes to downstream stages.

#### Execution controls <a href="#execution-controls" id="execution-controls"></a>

The **Execution controls** section sets conditions, looping strategy, concurrency, failure strategy, and timeout for the stage.

**On failure** defines what Harness does when the stage fails. For Google Cloud Functions, `stage-rollback` triggers the rollback step and restores the previous state.

```yaml
on-failure:
  errors: all
  action: stage-rollback
```

**Strategy** configures a looping strategy so the stage runs multiple times across a matrix of values.

```yaml
strategy:
  matrix:
    <dimension>: [<value1>, <value2>]
  max-concurrency: 2
```

#### Runtime Environment <a href="#runtime-environment" id="runtime-environment"></a>

The **Runtime Environment** section configures where the stage's steps execute. Google Cloud Functions steps do not require a delegate, so all three runtime options are supported:

| Runtime           | Description                                                                                                                                  |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| **Harness Cloud** | Steps run on Harness-hosted infrastructure. No delegate or cluster setup required.                                                           |
| **Delegate**      | Steps run on any available installed delegate. Harness selects one automatically, or you can target a specific delegate using selector tags. |
| **Kubernetes**    | Steps run as containers on a Kubernetes cluster you specify. Requires a Kubernetes connector and a namespace.                                |

In the stage YAML, these options correspond to `runtime: cloud`, `runtime: delegate`, and a `runtime: kubernetes` block with the fields below.

```yaml
runtime:
  kubernetes:
    namespace: <delegate-namespace>
    connector: <k8s-connector-id>
    service-account: <service-account>
    automount-service-token: true
```

| Field                       | Description                                                                |
| --------------------------- | -------------------------------------------------------------------------- |
| **Namespace**               | The Kubernetes namespace where the stage pod runs.                         |
| **Connector**               | A Kubernetes connector with access to the target cluster.                  |
| **Service Account**         | The Kubernetes service account used by the pod.                            |
| **Automount service token** | When enabled, automatically mounts the service account token into the pod. |

***

### Next steps <a href="#next-steps" id="next-steps"></a>

* Go to Google Cloud Functions services to configure a service with a manifest and artifact source.
* Go to Google Cloud Functions infrastructure to connect a Google Cloud account and configure authentication.
* Go to Deployment strategies to configure Basic, Canary, Blue-green, or Blank canvas.
