ApplicationSet basics
Understand the basics for ApplicationSet.
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 100s of target clusters? Managing 100s of GitOps applications is not easy.
To solve this use case, GitOps provides ApplicationSets.
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.
You can find more information about ApplicationSets in Argo CD ApplicationSets documentation.
In Harness, ApplicationSets are often used with a PR pipeline. A Harness PR pipeline has the power to update the config and sync changes to the application in just one of the target environments.
ApplicationSet resource
Each ApplicationSet spec has 2 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.
For more information on available generators, go to the Argo CD documentation.
Each generator solves a different use case, but gives you the same end result: a deployed application. Which generator you select depends factors such as the number of clusters managed, git repository layout, etc.
Generator support in PR pipelines
The Git generator has first class support with 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 will be used in the next Application sync (manual or automatic).
For information on PR pipeline integration, review the execution steps in Create Harness GitOps 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.
Here's an example using the List generator:
This example creates two applications (one for dev, one for prod) 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, allowing you to track changes through Git history and leverage Git workflows for managing applications.
Here's an example using 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
For more information and examples of Git generators (including Git Files generator), refer to the Argo CD Git Generator documentation and Argo CD ApplicationSet examples.
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
Additional Resources
Last updated
Was this helpful?