github.com/argoproj/argo-cd/v3@v3.2.1/applicationset/examples/matrix/matrix-and-union-in-matrix.yaml (about)

     1  # The matrix generator can contain other combination-type generators (matrix and union). But nested matrix and union
     2  # generators cannot contain further-nested matrix or union generators.
     3  #
     4  # The generators are evaluated from most-nested to least-nested. In this case:
     5  #  1. The union generator joins two lists to make 3 parameter sets.
     6  #  2. The inner matrix generator takes the cartesian product of the two lists to make 4 parameters sets.
     7  #  3. The outer matrix generator takes the cartesian product of the 3 union and the 4 inner matrix parameter sets to
     8  #     make 3*4=12 final parameter sets.
     9  #  4. The 12 final parameter sets are evaluated against the top-level template to generate 12 Applications.
    10  apiVersion: argoproj.io/v1alpha1
    11  kind: ApplicationSet
    12  metadata:
    13    name: matrix-and-union-in-matrix
    14  spec:
    15    goTemplate: true
    16    goTemplateOptions: ["missingkey=error"]
    17    generators:
    18      - matrix:
    19          generators:
    20            - union:
    21                mergeKeys:
    22                  - cluster
    23                generators:
    24                  - list:
    25                      elements:
    26                        - cluster: engineering-dev
    27                          url: https://kubernetes.default.svc
    28                          values:
    29                            project: default
    30                        - cluster: engineering-prod
    31                          url: https://kubernetes.default.svc
    32                          values:
    33                            project: default
    34                  - list:
    35                      elements:
    36                        - cluster: engineering-dev
    37                          url: https://kubernetes.default.svc
    38                          values:
    39                            project: default
    40                        - cluster: engineering-test
    41                          url: https://kubernetes.default.svc
    42                          values:
    43                            project: default
    44            - matrix:
    45                generators:
    46                  - list:
    47                      elements:
    48                        - values:
    49                            suffix: '1'
    50                        - values:
    51                            suffix: '2'
    52                  - list:
    53                      elements:
    54                        - values:
    55                            prefix: 'first'
    56                        - values:
    57                            prefix: 'second'
    58    template:
    59      metadata:
    60        name: '{{.values.prefix}}-{{.cluster}}-{{.values.suffix}}'
    61      spec:
    62        project: '{{.values.project}}'
    63        source:
    64          repoURL: https://github.com/argoproj/argo-cd.git
    65          targetRevision: HEAD
    66          path: '{{.path.path}}'
    67        destination:
    68          server: '{{.url}}'
    69          namespace: '{{.path.basename}}'