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

Google Cloud Functions Traffic Shift

Shift traffic between revisions on a Google Cloud Function's backing Cloud Run service.

The traffic shift step routes a percentage of traffic to a target revision on a Google Cloud Function's backing Cloud Run service. Use it after a deploy step to progressively shift traffic, or to complete a cutover in a single step.


Traffic shift YAML

Minimal form:

- name: Google Cloud Function Traffic Shift
  id: googleCloudFunctionTrafficShiftStep
  template:
    uses: googleCloudFunctionTrafficShiftStep
    with:
      function: ${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.functionName}}
      is_first_deployment: ${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.isFirstDeployment}}
      target_revision: ${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.revision}}
      target_traffic_percent: "100"

With explicit overrides:

- name: Google Cloud Function Traffic Shift
  id: googleCloudFunctionTrafficShiftStep
  template:
    uses: googleCloudFunctionTrafficShiftStep
    with:
      function: ${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.functionName}}
      is_first_deployment: ${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.isFirstDeployment}}
      target_revision: ${{stage.steps.googleCloudFunctionDeployStep.output.outputVariables.revision}}
      target_traffic_percent: "10"
      command_timeout: 15m
      log_level: debug

How the traffic shift step works

When the step runs, Harness executes the following actions in order:

  1. Authenticates with Google Cloud using the connector configured on the infrastructure definition.

  2. Resolves Cloud Function Name, Target Revision, and First Deployment, typically from a preceding deploy step's output.

  3. If First Deployment is true, skips the traffic shift because there is no previous revision to balance traffic against.

  4. Otherwise, shifts Target Traffic Percent of traffic on the backing Cloud Run service to Target Revision.

  5. Saves the resulting traffic split as rollback data for the rollback step.


Traffic shift fields

The following fields configure which function and revision receive traffic, and how much.

Field
Default
Description

Cloud Function Name

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

The function to shift traffic for. Typically resolved from a preceding deploy step's output.

Target Traffic Percent

—

The percentage of traffic to shift to Target Revision.

Target Revision

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

The revision to shift traffic to. Typically resolved from a preceding deploy step's output.

GCP Connector

—

The Google Cloud connector used to authenticate and shift traffic. Required.

GCP Region

${{infra.region}}

The Google Cloud region of the function. Auto-resolved from the infrastructure definition.

GCP Project

${{infra.project}}

The Google Cloud project of the function. Auto-resolved from the infrastructure definition.

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. Typically resolved from a preceding deploy step's output.

Cloud Function State (legacy)

—

The serialized Cloud Function state to shift traffic for. A legacy fallback used only when Cloud Function Name is empty.

Cloud Run Service State (legacy)

—

The serialized backing Cloud Run service state to shift traffic for. A legacy fallback used only when Cloud Function Name is empty.

Command Timeout

10m

Maximum time for the step to complete.

Log Level

info

Log verbosity for the step execution.

Advanced and Container sections

The step template also has collapsible Advanced and Container sections for additional overrides not covered above.


Next steps

Last updated

Was this helpful?