github.com/argoproj/argo-cd/v2@v2.10.9/applicationset/examples/matrix/matrix-and-union-in-matrix-fasttemplate.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    generators:
    16      - matrix:
    17          generators:
    18            - union:
    19                mergeKeys:
    20                  - cluster
    21                generators:
    22                  - list:
    23                      elements:
    24                        - cluster: engineering-dev
    25                          url: https://kubernetes.default.svc
    26                          values:
    27                            project: default
    28                        - cluster: engineering-prod
    29                          url: https://kubernetes.default.svc
    30                          values:
    31                            project: default
    32                  - list:
    33                      elements:
    34                        - cluster: engineering-dev
    35                          url: https://kubernetes.default.svc
    36                          values:
    37                            project: default
    38                        - cluster: engineering-test
    39                          url: https://kubernetes.default.svc
    40                          values:
    41                            project: default
    42            - matrix:
    43                generators:
    44                  - list:
    45                      elements:
    46                        - values:
    47                            suffix: '1'
    48                        - values:
    49                            suffix: '2'
    50                  - list:
    51                      elements:
    52                        - values:
    53                            prefix: 'first'
    54                        - values:
    55                            prefix: 'second'
    56    template:
    57      metadata:
    58        name: '{{values.prefix}}-{{cluster}}-{{values.suffix}}'
    59      spec:
    60        project: '{{values.project}}'
    61        source:
    62          repoURL: https://github.com/argoproj/argo-cd.git
    63          targetRevision: HEAD
    64          path: '{{path}}'
    65        destination:
    66          server: '{{url}}'
    67          namespace: '{{path.basename}}'