Course contentsShow
← Cloud and Infrastructure
Lesson 1910 of 2,98940. ArgoCDFree lesson

Matrix and Merge Generators

Combining multiple generators with matrix and merge strategies for complex application generation scenarios.

Matrix and Merge Generators

What you'll learn: How to combine multiple ApplicationSet generators using matrix and merge strategies to handle complex, multi-dimensional application deployments.

The Challenge of Complex Combinations

You've learned individual generators (Git, Cluster) that produce lists of parameters. But what if you need to deploy every Helm chart variant to every cluster, or combine Git repository data with cluster-specific configurations? Manually creating each combination is tedious and error-prone.

Matrix Generator: Cartesian Product

The Matrix generator combines two or more generators by creating every possible combination (Cartesian product). Think of it like a multiplication table: if you have 3 clusters and 2 environments, you get 6 application variants.

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
spec:
  generators:
  - matrix:
      generators:
      - clusters:
          selector:
            matchLabels:
              env: prod
      - git:
          repoURL: https://github.com/org/configs
          directories:
          - path: apps/*

This creates one application for each cluster × each app directory.

Merge Generator: Selective Override

The Merge generator combines generators sequentially, with later generators overriding parameters from earlier ones. It's like layering: start with defaults, then apply cluster-specific overrides.

Use merge when you want a base set of parameters enhanced with context-specific values, rather than every possible combination.

When to Use Each

  • Matrix: Multi-environment deployments where every app should exist in every cluster
  • Merge: Applying progressive overrides (base config → cluster overrides → environment overrides)

Key Takeaway: Matrix generators multiply possibilities for comprehensive coverage, while merge generators layer and override for progressive customization—both enable sophisticated, multi-dimensional GitOps automation without manual duplication.