LogoLogo
Login to CortexBook a DemoCortex Academycortex.io
  • Cortex Docs
  • Cortex Quick Start
  • Ingesting data into Cortex
    • Managing Entities
      • Adding entities
        • Add services
        • Add domains
        • Add teams
        • Add custom entity types
        • Defining dependencies
      • Entity details page
      • Defining ownership
      • Defining relationship types
      • Grouping entities
      • Adding external documentation
      • Adding Deploy data
      • Adding custom data
      • Viewing discovered entities
      • Archiving entities
      • Relationship graph
      • Using On-call Assistant for incidents
      • Managing Terraform infra in Cortex
    • Managing Catalogs
    • Integrations
      • Internally hosted integrations
      • ArgoCD
      • AWS
      • Azure DevOps
      • Azure Resources
      • BambooHR
      • Bitbucket
      • BugSnag
      • Buildkite
      • Checkmarx
      • CircleCI
      • ClickUp
      • Codecov
      • Coralogix
      • Custom webhook integrations
      • Datadog
      • Dynatrace
      • Entra ID (Azure AD)
      • FireHydrant
      • GitHub
      • GitLab
      • Google
      • Grafana
      • incident.io
      • Instana
      • Jenkins
      • Jira
      • Kubernetes
      • LaunchDarkly
      • Lightstep
      • Mend
      • Microsoft Teams
      • New Relic
      • Okta
      • Opsgenie
      • PagerDuty
      • Prometheus
      • Rollbar
      • Rootly
      • Sentry
      • ServiceNow
      • Slack
      • Snyk
      • SonarQube
      • Splunk Observability Cloud (SignalFx)
      • Splunk On-Call (VictorOps)
      • Sumo Logic
      • Veracode
      • Wiz
      • Workday
      • xMatters
  • Scorecards
    • Initiatives and Action items
      • Creating issues based on Initiatives
    • Scorecard rule exemptions
    • Scorecard rule filters
    • Scorecard examples
    • Scorecards as code
  • Reports
    • Executive report
    • All Scorecards report
    • Bird's eye report
    • Progress report
    • Report card
  • Eng Intelligence
    • Custom Metrics
    • Jira Metrics
    • Metrics Explorer (Beta)
  • Cortex Query Language (CQL)
    • Using CQL reports
    • Using JQ in Cortex
  • Workflows
    • Creating a Workflow
      • Workflows as code
    • Blocks
    • Running a Workflow
    • Registering a Scaffolder template
      • Scaffolder advanced usage
    • Using a Workflow to sync in ArgoCD
    • Kicking off a Jenkins pipeline in a Workflow
    • Calling internal service endpoints in a Workflow
  • Plugins
    • Creating a plugin
      • Creating a plugin proxy
    • Migrating Backstage plugins to Cortex
  • Engineering homepage
  • Workspace Settings
    • Using GitOps for Cortex
      • GitOps logs
    • Managing users
      • Roles and permissions
        • Custom roles
        • Team ownership entity editing
      • Configuring SSO
        • Microsoft Entra ID
        • Google
        • Other OIDC providers
        • Okta
          • Okta SCIM
      • Configuring identity mappings
      • Onboarding management
    • API keys, secrets, and tokens
      • Secrets
      • Personal tokens
    • Audit logs
    • Entity settings
      • Data verification
      • Auto archiving entities
    • IP allowlist
    • Notifications
      • Notification logs
    • Customizing your workspace
    • Using search in Cortex
  • Cortex API
    • REST API operations
      • API Keys
      • Audit Logs
      • Catalog Entities
      • Custom Data
        • Custom Data (Advanced)
      • Custom Events
      • Custom Metrics
      • Dependencies
      • Deploys
      • Discovery Audit
      • Docs
      • Eng Intel: User Labels
      • Entity Relationship Types (Beta)
      • Entity Relationships (Beta)
      • Entity Types
      • GitOps Logs
      • Groups
      • Initiatives
      • Integrations APIs
        • Azure Active Directory (Entra ID) API
        • Azure Resources API
        • AWS API
        • Azure DevOps API
        • CircleCI API
        • Coralogix API
        • Datadog API
        • GitHub API
        • GitLab API
        • incident.io API
        • LaunchDarkly API
        • New Relic API
        • PagerDuty API
        • Prometheus API
        • SonarQube API
      • IP Allowlist
      • Notification Logs
      • On call
      • Packages
      • Plugins
      • Queries
      • SCIM
      • Scorecards
      • Secrets
      • Team Hierarchies
      • Teams
      • Workflows
Powered by GitBook
On this page
  • How to automate an ArgoCD sync with a Workflow in Cortex
  • Prerequisites
  • Step 1: Create a Workflow
  • Step 2: Add blocks to the Workflow

Was this helpful?

Export as PDF
  1. Workflows

Using a Workflow to sync in ArgoCD

Last updated 2 months ago

Was this helpful?

After integrating Cortex with ArgoCD, you can use to streamline and automate daily tasks. Rather than manually performing a sync through the ArgoCD UI, you can automate syncs by leveraging the ArgoCD API in a Workflow.

This guide walks through a Workflow that will sync the ArgoCD application to the same cluster that ArgoCD is running, but to a different namespace, and will allow the user to choose options for the sync.

How to automate an ArgoCD sync with a Workflow in Cortex

Prerequisites

Before getting started:

  • Create an .

    • In ArgoCD, navigate to your account settings then click Tokens > Generate New. Copy the token and store it in a secure location, as you will need it in the next steps.

  • Create a secret in Cortex.

    • Give the secret the name argocd.

    • For the secret value, enter the value of your ArgoCD API token.

Step 1: Create a Workflow

  1. In the main nav of Cortex, click Workflows.

  2. Follow the steps of the to start creating a Workflow from scratch and configure its settings.

    • Give the Workflow a descriptive name such as "Create and sync application."

    • In the Response template field you can pass a blank response body or use to create messages depending on what the user enters in each field.

      • For example, you may want to configure a response to confirm whether a sync was successful when the workflow is run. You could add the following to check the sync.status field. This example assumes you add an HTTP request action with the slug http-request in your Workflow:

      {{#actions.http-request.outputs.body.status.sync.status}}
      Successfully synced application!
      {{/actions.http-request.outputs.body.status.sync.status}}
      {{^actions.http-request.outputs.body.status.sync.status}}
      Unable to sync application. Are you sure this application exists in ArgoCD?
      {{/actions.http-request.outputs.body.status.sync.status}}

Step 2: Add blocks to the Workflow

  1. In the Workflow, click + to add a block. Select User input. Configure the block:

    • Block name: Enter a name for the block (e.g., User input).

    • Slug: The slug field is automatically populated based on the block name.

    • Under "User input fields," click Add input. Configure the input:

      • Type: Select Text.

      • Name: Enter Revision.

      • Placeholder: Enter HEAD.

      • At the bottom of the modal, click Add input field.

    • Under "User input fields," click Add input. Configure another input:

      • Type: Select Toggle.

      • Name: Enter Dry run.

      • At the bottom of the modal, click Add input field.

    • Under "User input fields," click Add input. Configure another input:

      • Type: Select Toggle.

      • Name: Enter Prune.

      • At the bottom of the modal, click Add input field.

  2. Click Save.

  3. In the Workflow, click + to add another block. Select HTTP request. Configure the block:

    • Block name: Enter a name for the block (e.g., HTTP request).

    • Slug: The slug field is automatically populated based on the block name.

    • HTTP method: Select POST.

    • URL: Enter the target URL.

    • Headers: Enter the following key/value pairs:

      • Header Key: Authorization, Header Value: Bearer {{{context.secrets.argocd}}}

        • If you used a different name for your secret, replace argocd with your secret's name.

    • Payload: Enter the payload referencing the output of the "User input" block. The payload that you supply can be templated and can reference an entity that the Workflow is being run with.

      • In this example, you could enter:

      {
        "prune": {{context.actions.user-input.outputs.prune}},
        "dryRun": {{context.actions.user-input.outputs.dry-run}},
        "revision": "{{context.actions.user-input.outputs.revision}}"
      }
  4. Click Save.

  5. Click Save Workflow.

In your Workflow, you will add an HTTP request block to call the ArgoCD sync via the , and a user input block where you define inputs that map to the JSON body of the block. The inputs should be the same sync options shown under Sync in your ArgoCD instance. The instructions below map REVISION, DRY RUN, and PRUNE as the sync options.

See the for more information on configuring blocks.

ArgoCD API
Workflows
API token in ArgoCD
Workflows documentation
Mustache templating
Workflows documentation