github.com/argoproj/argo-cd/v3@v3.2.1/docs/operator-manual/applicationset.yaml (about)

     1  apiVersion: argoproj.io/v1alpha1
     2  kind: ApplicationSet
     3  metadata:
     4    name: test-hello-world-appset
     5    namespace: argocd
     6  spec:
     7    generators:
     8      # The list generator generates a set of two application which then filter by the key value to only select the env with value staging
     9      - list:
    10          elements:
    11            - cluster: engineering-dev
    12              url: https://kubernetes.default.svc
    13              env: staging
    14            - cluster: engineering-prod
    15              url: https://kubernetes.default.svc
    16              env: prod
    17          # The generator's template field takes precedence over the spec's template fields
    18          template:
    19            metadata: {}
    20            spec:
    21              project: "default"
    22              source:
    23                revision: HEAD
    24                repoURL: https://github.com/argoproj/argo-cd.git
    25                # New path value is generated here:
    26                path: 'applicationset/examples/template-override/{{cluster}}-override'
    27              destination: {}
    28  
    29        # Selector allows to post-filter all generator.
    30        selector:
    31          matchLabels:
    32            env: staging
    33            
    34      # It is also possible to use matchExpressions for more powerful selectors
    35      - clusters: {}
    36        selector:
    37          matchExpressions:
    38            - key: server
    39              operator: In
    40              values:
    41                - https://kubernetes.default.svc
    42                - https://some-other-cluster
    43  
    44      # Git generator generates parametes either from directory structure of files within a git repo
    45      - git:
    46          repoURL: https://github.com/argoproj/argo-cd.git
    47          # OPTIONAL: use directory structure of git repo to generate parameters
    48          directories:
    49          - path: applicationset/examples/git-generator-directory/excludes/cluster-addons/*
    50          - path: applicationset/examples/git-generator-directory/excludes/cluster-addons/exclude-helm-guestbook
    51            exclude: true # Exclude directory when generating parameters
    52          # OPTIONAL: generates parameters using the contents of JSON/YAML files found in git repo
    53          files:
    54          - path: "applicationset/examples/git-generator-files-discovery/cluster-config/**/config.json"
    55          - path: "applicationset/examples/git-generator-files-discovery/cluster-config/*/dev/config.json"
    56            exclude: true # Exclude file when generating parameters
    57          revision: HEAD
    58          # OPTIONAL: Checks for changes every 60sec (default 3min)
    59          requeueAfterSeconds: 60
    60          # The generator's template field takes precedence over the spec's template fields
    61          template:
    62          # OPTIONAL: all path-related parameter names will be prefixed with the specified value and a dot separator
    63          pathParamPrefix: myRepo
    64          # OPTIONAL: Values contains key/value pairs which are passed directly as parameters to the template
    65          values:
    66            cluster: '{{.path.basename}}'
    67  
    68  
    69      # to automatically discover repositories within an organization
    70      - scmProvider:
    71          # Which protocol to clone using.
    72          cloneProtocol: ssh
    73          # The GitHub mode uses the GitHub API to scan an organization in either github.com or GitHub Enterprise
    74          github:
    75            # The GitHub organization to scan.
    76            organization: myorg
    77            # For GitHub Enterprise:
    78            api: https://git.example.com/
    79            # If true, scan every branch of every repository. If false, scan only the default branch. Defaults to false.
    80            allBranches: true
    81            # Reference to a Secret containing an access token. (optional)
    82            tokenRef:
    83              secretName: github-token
    84              key: token
    85            # (optional) use a GitHub App to access the API instead of a PAT.
    86            appSecretName: gh-app-repo-creds
    87            #Pass additional key-value pairs via values field
    88            values:
    89              name: "{{organization}}-{{repository}}"
    90  
    91          #The GitLab mode uses the GitLab API to scan and organization in either gitlab.com or self-hosted GitLab.  
    92          gitlab:
    93          #The Gitea mode uses the Gitea API to scan organizations in your instance
    94          gitea:
    95          #Use the Bitbucket Server API (1.0) to scan repos in a project.
    96          bitbucketServer:
    97          #Uses the Azure DevOps API to look up eligible repositories 
    98          azureDevOps:
    99          # The Bitbucket mode uses the Bitbucket API V2 to scan a workspace in bitbucket.org
   100          bitbucket:
   101          #Uses AWS ResourceGroupsTagging and AWS CodeCommit APIs to scan repos across AWS accounts and regionsz
   102          awsCodeCommit:
   103  
   104          #Filters allow selecting which repositories to generate for. 
   105          filters:
   106          # Include any repository starting with "myapp" AND including a Kustomize config AND labeled with "deploy-ok" ...
   107          - repositoryMatch: ^myapp
   108            pathsExist: [kubernetes/kustomization.yaml]
   109            labelMatch: deploy-ok
   110          # ... OR include any repository starting with "otherapp" AND a Helm folder and doesn't have file disabledrepo.txt.
   111          - repositoryMatch: ^otherapp
   112            pathsExist: [helm]
   113            pathsDoNotExist: [disabledrepo.txt]
   114  
   115      # Cluster-decision-resource-based ApplicationSet generator
   116      - clusterDecisionResource:
   117        # ConfigMap with GVK information for the duck type resource
   118        configMapRef: my-configmap  
   119        name: quak           # Choose either "name" of the resource or "labelSelector"
   120        labelSelector:
   121          matchLabels:       # OPTIONAL
   122            duck: spotted
   123          matchExpressions:  # OPTIONAL
   124          - key: duck
   125            operator: In
   126            values:
   127            - "spotted"
   128            - "canvasback"   
   129        # OPTIONAL: Checks for changes every 60sec (default 3min)
   130        requeueAfterSeconds: 60
   131    
   132      # The Pull Request generator uses the API of an SCMaaS provider to automatically discover open pull requests within a repository
   133      - pullRequest:
   134          # When using a Pull Request generator, the ApplicationSet controller polls every `requeueAfterSeconds` interval (defaulting to every 30 minutes) to detect changes.
   135          requeueAfterSeconds: 1800
   136          # When set to true, the ApplicationSet controller will continue to generate Applications even if the repository is not found, and will not enter a failed state.
   137          # One example use case is when a pull request generator is combined with a Git generator in a matrix generator.
   138          # NOTE, that if a repository exists but is inaccessible due to
   139          # access rights, SCM providers usually return a "404 Not Found" error
   140          # instead of a "403 Permission Denied" error. Consequently, using this
   141          # option may lead to the deletion of Argo CD applications if the SCM
   142          # user associated with the token loses access to the repository.
   143  
   144          continueOnRepoNotFoundError: false
   145          # See below for provider specific options.
   146          # Specify the repository from which to fetch the GitHub Pull requests.
   147          github:
   148            # The GitHub organization or user.
   149            owner: myorg
   150            # The Github repository
   151            repo: myrepository
   152            # For GitHub Enterprise (optional)
   153            api: https://git.example.com/
   154            # Reference to a Secret containing an access token. (optional)
   155            tokenRef:
   156              secretName: github-token
   157              key: token
   158            # (optional) use a GitHub App to access the API instead of a PAT.
   159            appSecretName: github-app-repo-creds
   160            # Labels is used to filter the PRs that you want to target. (optional)
   161            labels:
   162            - preview
   163  
   164          # Filters allow selecting which pull requests to generate for
   165          # Include any pull request branch ending with "argocd" 
   166          # and pull request title starting with "feat:". (optional)
   167          filters:
   168          - branchMatch: ".*-argocd"
   169          - titleMatch: "^feat:"
   170  
   171          # Specify the project from which to fetch the GitLab merge requests.
   172          gitlab:
   173          # Specify the repository from which to fetch the Gitea Pull requests.
   174          gitea:
   175          # Fetch pull requests from a repo hosted on a Bitbucket Server (not the same as Bitbucket Cloud).
   176          bitbucketServer:
   177          # Fetch pull requests from a repo hosted on a Bitbucket Cloud.
   178          bitbucket:
   179          # Specify the organization, project and repository from which you want to fetch pull requests.
   180          azuredevops:
   181          # Fetch pull requests from AWS CodeCommit repositories.
   182          awsCodeCommit:
   183     
   184      # matrix 'parent' generator
   185      - matrix:
   186          generators:
   187          # any of the top-level generators may be used here instead.
   188    
   189      # merge 'parent' generator
   190      # Use the selector set by both child generators to combine them.
   191      - merge:
   192          mergeKeys:
   193            - server
   194            # Note that this would not work with goTemplate enabled,
   195            # nested merge keys are not supported there.
   196            - values.selector
   197          generators:
   198            - clusters:
   199                values:
   200                  kafka: 'true'
   201                  redis: 'false'
   202            # For clusters with a specific label, enable Kafka.
   203            - clusters:
   204                selector:
   205                  matchLabels:
   206                    use-kafka: 'false'
   207                values:
   208                  kafka: 'false'
   209            # For a specific cluster, enable Redis.
   210            - list:
   211                elements: 
   212                  - server: https://2.4.6.8
   213                    values.redis: 'true'
   214  
   215      # Using a generator plugin without combining it with Matrix or Merge
   216      # Plugins allow you to provide your own generator
   217      - plugin:
   218        # Specify the configMap where the plugin configuration is located.
   219        configMapRef:
   220          name: my-plugin
   221        # You can pass arbitrary parameters to the plugin. `input.parameters` is a map, but values may be any type.
   222        # These parameters will also be available on the generator's output under the `generator.input.parameters` key.
   223        input:
   224          parameters:
   225            key1: "value1"
   226            key2: "value2"
   227            list: ["list", "of", "values"]
   228            boolean: true
   229            map:
   230              key1: "value1"
   231              key2: "value2"
   232              key3: "value3"
   233          # You can also attach arbitrary values to the generator's output under the `values` key. These values will be
   234          # available in templates under the `values` key.
   235          values:
   236            value1: something
   237          # When using a Plugin generator, the ApplicationSet controller polls every `requeueAfterSeconds` interval (defaulting to every 30 minutes) to detect changes.
   238          requeueAfterSeconds: 30
   239                  
   240                
   241    # Determines whether go templating will be used in the `template` field below.
   242    goTemplate: true
   243    # Optional list of go templating options, see https://pkg.go.dev/text/template#Template.Option
   244    # This is only relevant if `goTemplate` is true
   245    goTemplateOptions: ["missingkey=error"]
   246  
   247    # These fields are identical to the Application spec.
   248    # The generator's template field takes precedence over the spec's template fields
   249    template:
   250      metadata:
   251        name: test-hello-world-app
   252      spec:
   253        project: my-project
   254        syncPolicy: 
   255          automated:
   256            selfHeal: true    
   257          syncOptions:
   258          - CreateNamespace=true  
   259        # defines from which Git repository to extract the desired Application manifests
   260        source:
   261          - chart: '{{.chart}}'
   262          # developers may customize app details using JSON files from above repo URL
   263            repoURL: https://github.com/argoproj/argo-cd.git
   264            targetRevision: HEAD
   265            # Path within the repository where Kubernetes manifests are located
   266            path: applicationset/examples/list-generator/guestbook/{{cluster}}
   267            helm:
   268              useCredentials: "{{.useCredentials}}"  # This field may NOT be templated, because it is a boolean field
   269            parameters:
   270            - name: "image.tag"
   271              value: "pull-{{head_sha}}"
   272            - name: "{{.name}}"
   273              value: "{{.value}}"
   274            - name: throw-away
   275              value: "{{end}}"
   276        destination:
   277          # Only one of name or server may be specified: if both are specified, an error is returned.
   278          #  Name of the cluster (within Argo CD) to deploy to
   279          name: production-cluster # cluster is restricted
   280          #  API Server URL for the cluster
   281          server: '{{.url}}'
   282          # Target namespace in which to deploy the manifests from source 
   283          namespace: dev-team-one # namespace is restricted
   284  
   285    # This sync policy pertains to the ApplicationSet, not to the Applications it creates.
   286    syncPolicy:
   287      # Prevents ApplicationSet controller from modifying or deleting Applications
   288      applicationsSync: create-only
   289  
   290      # Prevents ApplicationSet controller from deleting Applications. Update is allowed
   291      # applicationsSync: create-update
   292  
   293      # Prevents ApplicationSet controller from modifying Applications. Delete is allowed.
   294      # applicationsSync: create-delete
   295  
   296      # Prevent an Application's child resources from being deleted, when the parent Application is deleted
   297      preserveResourcesOnDeletion: true
   298  
   299    strategy:
   300       # The RollingSync update strategy allows you to group Applications by labels present on the generated Application resources
   301       # See documentation for "Progressive Syncs"
   302       type: RollingSync
   303       rollingSync:
   304        steps:
   305          # Application groups are selected using their labels and matchExpressions
   306          - matchExpressions:
   307              - key: envLabel
   308                operator: In
   309                values:
   310                  - env-dev
   311          # maxUpdate: 100%  # if undefined, all applications matched are updated together (default is 100%)
   312          - matchExpressions:
   313              - key: envLabel
   314                operator: In
   315                values:
   316                  - env-qa
   317            maxUpdate: 0      # if 0, no matched applications will be synced unless they're synced manually
   318          - matchExpressions:
   319              - key: envLabel
   320                operator: In
   321                values:
   322                  - env-prod
   323            maxUpdate: 10%    # maxUpdate supports both integer and percentage string values (rounds down, but floored at 1 Application for >0%)
   324  
   325    # Define annotations and labels of the Application that this ApplicationSet will ignore
   326    # ignoreApplicationDifferences is the preferred way to accomplish this now.
   327    preservedFields:
   328      annotations: [ some-annotation-key ]
   329      labels: [ some-label-key ]
   330  
   331    # Define fields of the that should be ignored when comparing Applications
   332    ignoreApplicationDifferences:
   333    - jsonPointers:
   334      - /spec/source/targetRevision
   335    - name: some-app
   336      jqPathExpressions:
   337      - .spec.source.helm.values
   338  
   339