ApplicationSet basics
Understand ApplicationSet concepts, generators, and sync policy options in Harness GitOps.
This topic describes Harness ApplicationSet concepts.
A typical GitOps application syncs a source manifest to a destination cluster. If you have multiple target clusters, you could create separate GitOps applications for each one, but that makes management more challenging. What if you want to sync an application with hundreds of target clusters? Managing hundreds of GitOps applications is not easy.
To solve this use case, GitOps provides ApplicationSets.
What you will learn from this topic
Understand what an ApplicationSet is and the capabilities it offers.
Understand how the templates and generators in an ApplicationSet spec work together.
Review the generator types Harness supports, with examples.
Review the sync policy options Harness supports.
ApplicationSet overview
An ApplicationSet works like an application factory. It defines one application template and syncs it to multiple target environments. It is similar to an application but uses a template to achieve application automation with multiple target environments.
The ApplicationSet CRD is managed by the dedicated Kubernetes controller, applicationset-controller, similar to the Application CRD being managed by application-controller.
ApplicationSets offer the following capabilities:
Use a single manifest to target multiple Kubernetes clusters.
Use a single manifest to deploy multiple applications from single or multiple git repositories.
Enhanced support for the monorepos, where multiple application resources are defined within a single Git repository.
Go to the Argo CD ApplicationSets documentation to review the full ApplicationSet feature set.
In Harness, ApplicationSets are often used with a PR pipeline. Go to Create Harness GitOps PR pipelines to configure a PR pipeline that updates the config and syncs changes to the application in just one of the target environments.
ApplicationSet resource
Each ApplicationSet spec has two main fields: templates and generators.
Templates
An ApplicationSet template is the template for the application to be created. It has parameterized fields that can be substituted to create the application.
Parameters should be in the format {{parameter name}}.
Generators
An ApplicationSet generator generates parameters to be substituted in the template section of the ApplicationSet resource.
There are many types of generators. Harness supports all ApplicationSet generators. You can add an ApplicationSet for any generator as an application in Harness.
Go to the Argo CD documentation to review every available generator type.
Each generator solves a different use case, but gives you the same end result: a deployed application. Which generator you select depends on factors such as the number of clusters managed, and the git repository layout.
Generator support in PR pipelines
Harness PR pipelines support ApplicationSet generators in these ways:
The Git generator is fully supported by the Update Release Repo and Merge PR steps in the Harness PR pipeline.
All generators can be used in Shell Script steps. For example, you could create a cluster generator YAML spec in a Shell Script step as a bash variable, and then use Git commands in the script to update the ApplicationSet in your repo with the spec in the step. The updated repo spec is used in the next Application sync (manual or automatic).
Go to Create Harness GitOps PR pipelines to review the execution steps that integrate with PR pipelines.
Supported generator types
Harness supports all Argo CD ApplicationSet generators. Each generator reads from a different source and produces parameters for creating applications.
Generate from custom resources
Dynamic cluster selection based on custom logic
List generator example
The List generator is ideal for initial setup and testing ApplicationSets. It uses a static list of parameters to generate applications.
The following example uses the List generator.
This example creates two applications, one for the engineering-dev namespace and one for the engineering-prod namespace, from a static list of parameters.
Git generator example
The Git generator is the most common pattern for production use cases. It follows the GitOps methodology by storing application configurations in Git, so you can track changes through Git history and use Git workflows to manage applications.
The following example uses the Git Directory generator.
This example:
Scans the specified Git repository path for directories
Creates one application per directory found
Uses the directory name as the application name and namespace
Includes Harness-specific labels for Service and Environment tracking
When to use List vs Git generators:
List Generator: Best for initial setup, testing, and scenarios with a small, fixed number of environments that rarely change
Git Generator: Recommended for production use as it stores application change logs in Git, follows GitOps principles, and scales better for managing multiple applications
Go to the Argo CD Git Generator documentation for additional generator examples, including the Git Files generator. Go to Argo CD ApplicationSet examples for more sample specs.
Sync policy options
When creating an ApplicationSet, you can configure sync policies that govern how the ApplicationSet manages its child applications. These policies are set during ApplicationSet creation and determine the lifecycle management of generated applications.
Sync options
Preserve Resource On Deletion
When enabled, this option preserves Kubernetes resources even when the application is deleted from Argo CD. This is useful when you want to remove the application from Argo CD management but keep the deployed resources running in the cluster.
Applications sync
The Applications Sync policy controls how the ApplicationSet controller manages the lifecycle of its child applications. This policy is configured in the ApplicationSet manifest and determines whether the controller can create, update, or delete applications.
You can select one of the following options:
Create-Only (applicationsSync: create-only)
Behavior: Only creates new applications when they are generated by the ApplicationSet. Prevents the ApplicationSet controller from modifying or deleting applications.
Updates: Does not update existing applications automatically
Deletions: Does not delete applications when they are no longer generated
Use Case: When you want manual control over application updates and deletions after initial creation
Create-Update (applicationsSync: create-update)
Behavior: Creates new applications and updates existing ones. Prevents the ApplicationSet controller from deleting applications but allows updates.
Updates: Automatically updates applications when generator parameters change
Deletions: Does not delete applications when they are no longer generated
Use Case: When you want automatic updates but manual control over deletions
Create-Delete (applicationsSync: create-delete)
Behavior: Creates new applications and deletes removed ones. Prevents the ApplicationSet controller from modifying applications but allows deletion.
Updates: Does not update existing applications automatically
Deletions: Automatically deletes applications when they are no longer generated
Use Case: When you want automatic cleanup but manual control over updates
Sync (default behavior)
Behavior: Fully automated lifecycle management. The ApplicationSet controller can create, update, and delete applications.
Updates: Automatically updates applications when generator parameters change
Deletions: Automatically deletes applications when they are no longer generated
Use Case: Recommended for most scenarios where you want full automation
Next steps
Create and manage ApplicationSets: Walk through creating an ApplicationSet in Harness.
Argo CD ApplicationSet generators: Review every generator type Argo CD supports.
Argo CD ApplicationSet specification: Review the full ApplicationSet resource schema.
Harness GitOps PR pipelines: Use a PR pipeline to update and sync ApplicationSet changes.
Last updated
Was this helpful?