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

GitOps Sync with Multiple Rollout Steps

Learn how to pass values between GitOps Rollout steps using Harness expressions

This advanced example demonstrates a complete pipeline that starts with a GitOps sync step followed by multiple GitOps Rollout steps, showing how to pass values between steps.

Overview

Harness provides a powerful expression system to access outputs from previous steps. This enables dynamic configuration where steps automatically discover and use the correct rollout details without hardcoding values.

Key Benefits

  1. Dynamic Configuration: Steps automatically discover and use the correct rollout details

  2. Reusability: The same pipeline can work across different environments and applications

  3. Error Reduction: No hardcoded values that could become outdated

  4. Maintainability: Changes to rollout names or namespaces are automatically reflected

Pipeline Overview

Here's a visual representation of the pipeline:

IMPORTANT

To use Argo Rollouts with Harness GitOps pipelines, ensure the CDS_GITOPS_ENABLE_ROLLOUTS_PIPELINE_UX feature flag is enabled in your Harness account.

GitOps Pipeline with multiple Rollout steps

This pipeline consists of the following key steps:

  1. Update Rollout Image: Updates the image tag in your GitOps Application's manifest

  2. GitOps Sync: Synchronizes the GitOps Application to apply the image update, which triggers a new rollout

  3. Resume First Pause for Rollout: Resumes the rollout from the first pause step

  4. Any Intermediate Steps: Optional placeholder steps for custom logic

  5. Resume Second Pause for Rollout: Resumes the rollout from the second pause step

  6. Handle Degraded Rollout: Handles degraded rollout states with retry action

  7. Conditional Execution For Rollout: Conditional execution based on application name

Pipeline YAML

How to Get Values from Previous Steps

Harness provides a powerful expression system to access outputs from previous steps. Here's how it works:

1. Accessing GitOps Sync Outputs

The GitOps Sync step outputs discovered rollouts that can be used in subsequent steps:

Expression Syntax

Available fields:

  • agentIdentifier - The GitOps agent identifier

  • appName - The GitOps application name

  • rolloutName - The Rollout resource name

  • namespace - The namespace where the rollout is deployed

2. Expression Examples

3. Multiple Rollouts

If you have multiple rollouts, access them by index:

4. Accessing Other Step Outputs

You can also access outputs from other step types:

Step-by-Step Explanation

Step 1: Update Rollout Image

  • Purpose: Updates the container image in your GitOps Application's manifest

  • Configuration: Uses the UpdateGitOpsApp step to modify the image tag in the rollout manifest

  • Key Settings:

    • targetRevision: Git branch containing your manifests

    • kustomize.images: Specify the new image to deploy

    • applicationName: Your GitOps Application name

    • agentId: GitOps Agent identifier

Step 2: GitOps Sync

  • Purpose: Synchronizes the GitOps Application to apply the image update

  • Configuration: Uses the GitOpsSync step to trigger a sync operation

  • Key Settings:

    • applicationsList: List of applications to sync

    • syncOptions: Various sync configuration options

    • timeout: Maximum time to wait for sync completion

Step 3: Resume First Pause for Rollout

  • Purpose: Resumes the rollout from the first pause step

  • Configuration: Uses the GitOpsRollout step with resume action

  • Key Settings:

    • autoRolloutAction: Set to resume

    • waitUntilHealthStatus: Set to Suspended to wait for pause state

    • Uses expressions from the Sync step to get rollout details

    • failureStrategies: Ignore errors to continue pipeline

Step 4: Any Intermediate Steps

  • Purpose: Placeholder for custom logic or additional processing

  • Configuration: Uses the Wait step for simple delays

  • Use Cases:

    • Add custom validation logic

    • Insert additional processing steps

    • Create delays between operations

Step 5: Resume Second Pause for Rollout

  • Purpose: Resumes the rollout from the second pause step

  • Configuration: Uses the GitOpsRollout step with resume action

  • Key Settings:

    • autoRolloutAction: Set to resume

    • waitUntilHealthStatus: Set to Suspended to wait for pause state

    • Uses expressions from the Sync step to get rollout details

Step 6: Handle Degraded Rollout

  • Purpose: Handles degraded rollout states with retry action

  • Configuration: Uses the GitOpsRollout step with retry action

  • Key Settings:

    • autoRolloutAction: Set to retry

    • when: Set to Failure to only run on stage failure

    • Uses expressions from the Sync step to get rollout details

Step 7: Conditional Execution For Rollout

  • Purpose: Conditional execution based on application name

  • Configuration: Uses the GitOpsRollout step with restart action

  • Key Settings:

    • autoRolloutAction: Set to restart

    • when: Conditional execution with custom condition

    • Uses expressions to check application name

Best Practices

  1. Use descriptive step identifiers for easier reference

  2. Add timeout values appropriate for your deployment size

  3. Include health checks for critical production deployments

  4. Consider manual approval steps for production environments

  5. Test expressions in the pipeline editor before saving

Last updated

Was this helpful?