For the complete documentation index, see llms.txt. This page is also available as Markdown.

Blue-green deployment

Deploy a Google Cloud Function and cut traffic over to the new revision in a single step.

Blue-green deployment deploys a new function revision without traffic, then shifts all traffic to it in a single cutover. Use this strategy when you want the new revision fully deployed and verified before it serves any traffic.


What you will learn from this topic

  • Understand how Harness deploys a new function revision out of traffic, then cuts over to it in a single step.

  • See how the deploy and traffic shift steps pass data to each other, and how Harness handles it if the deployment fails.


Before you begin


Blue-green strategy step sequence

When you select Blue-green, Harness adds the following steps to your stage execution:

  1. Google Cloud Function Deploy: Deploys the new function revision with Skip Traffic set to true, so the revision does not receive traffic yet.

  2. Google Cloud Function Traffic Shift: Shifts 100% of traffic to the newly deployed revision, using the function name, revision, and first-deployment flag from the deploy step's output.

On rollback, Harness runs the Google Cloud Function Rollback step inside a Google Cloud Function Blue Green Rollback step group.


Stage YAML

A minimal blue-green stage looks like this.

This example runs on a delegate and deploys to every infrastructure definition in the environment:

This example runs on Harness Cloud and deploys to a single, specific infrastructure definition:


Configure the Google Cloud Function Deploy step

For the blue-green strategy, the deploy step sets Skip Traffic to true so the new revision does not receive traffic until the traffic shift step runs.

Field
Default
Description

Skip Traffic

false

When true, the deployed revision does not receive traffic until a separate traffic shift step runs. Blue-green sets this to true.

Command Timeout

10m

Maximum time for the step to complete.

Log Level

info

Log verbosity for the step execution.


Configure the Google Cloud Function Traffic Shift step

The traffic shift step reads the function name, revision, and first-deployment flag from the deploy step's output, and shifts the specified percentage of traffic to that revision. Blue-green shifts 100% of traffic in a single cutover.

Field
Default
Description

Cloud Function Name

${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.functionName}}

The function to shift traffic for. Automatically resolved from the deploy step output.

First Deployment

${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.isFirstDeployment}}

Whether this is the first deployment of the function. When true, the step skips the traffic shift. Automatically resolved from the deploy step output.

Target Revision

${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.revision}}

The revision to shift traffic to. Automatically resolved from the deploy step output.

Target Traffic Percent

—

The percentage of traffic to shift to the target revision. Blue-green sets this to 100.

Command Timeout

10m

Maximum time for the step to complete.

Log Level

info

Log verbosity for the step execution.


Rollback behavior

When the stage failure strategy triggers rollback, the Google Cloud Function Rollback step inside the Google Cloud Function Blue Green Rollback step group runs automatically.

The rollback step receives the following inputs:

Field
Value
Description

Cloud Function Name

${{rollback.data.FUNCTION_NAME}}

The function to roll back.

Previous Traffic Split

${{rollback.data.ACTIVE_CLOUD_RUN_REVISIONS}}

The revisions that were active before the deployment. Used to restore traffic during rollback.

Gen 2 functions run on a backing Cloud Run service

Google Cloud Functions Gen 2 deploys each function as a Cloud Run service. The deploy and traffic shift steps read and modify this backing service directly, which is why rollback data stores Cloud Run revisions.

Rollback behavior differs by deployment history:

  • Subsequent deployments: Harness restores the previous serving traffic split on the backing Cloud Run service. Previous Traffic Split holds the revision and traffic percentage that were active before the deployment, and the rollback step applies that split back to the service.

  • First deployment: There is no previous revision to restore traffic to, so Previous Traffic Split has nothing to roll back to.


Next steps

  • Go to Basic for a single-phase deployment without a traffic cutover.

  • Go to Canary for a progressively rolled out deployment.

  • Go to Blank canvas to compose steps manually.

Last updated

Was this helpful?