applicationset icon indicating copy to clipboard operation
applicationset copied to clipboard

skip or exclude some applications deployment from particular env

Open parasappafluke opened this issue 2 years ago • 6 comments

Hi, is there way we can exclude some directories/apps for particular cluster? below is my repository structure(mono repo). I'm using Matrix generator with git and list generator to deploy all the applications in the apps dir. Some application we want to skip deployment to prod cluster e.g app2 in below structure . Currently i have created a single applicationset-matrix.yaml file. . ├── applicationset-matrix.yaml └── apps ├── app1 │ ├── Chart.yaml │ ├── dev │ │ └── values.yaml │ ├── preprod │ │ └── values.yaml │ ├── prod │ │ └── values.yaml │ ├── templates │ │ ├── NOTES.txt │ │ ├── _helpers.tpl │ │ ├── deployment.yaml │ │ ├── ingress.yaml │ │ ├── service.yaml │ │ ├── serviceaccount.yaml │ └── values.yaml └── app2 (Helm Chart)

parasappafluke avatar Jul 12 '21 10:07 parasappafluke

I am also interested in this

annabarnes1138 avatar Aug 24 '21 15:08 annabarnes1138

It sounds like you were looking for ways to exclude particular combinations generated by the matrix generator?

For example, if matrix generator:

- matrix
    generator1: (...)
    generator2: (...)

If generator1 produced a, b, c and generator2 produced d, e, f then the matrix generator will generate ad, ae, af, bc, be, bf, cd, ce, cf, etc. Do I have it right that you are looking for a mechanism to prevent some of those combinations from being emitted?

jgwest avatar Sep 13 '21 16:09 jgwest

Have a similar use case:

spec:
  generators:
  - matrix:
      generators:
      - git:
          repoURL: <..>
          revision: HEAD
          directories:
          - path: "apps/production/*"
      - clusters:
          selector:
            matchLabels:
              argocd.argoproj.io/secret-type: cluster
              environment: production
      template:
        metadata: {}
        spec:
          project: production
          source:
            repoURL: <..>
            targetRevision: HEAD
            path: '{{path}}'
            helm:
              releaseName: '{{path.basename}}'
              valueFiles:
              - '{{name}}.yaml'
              - values.yaml
          destination: {}
  template:
    metadata:
      name: '{{path.basename}}.{{name}}'
    spec:
      project: production
      source:
        repoURL: <..>
        targetRevision: HEAD
        path: '{{path}}'
        helm:
          releaseName: '{{path.basename}}'
      destination:
        name: '{{name}}'
        namespace: '{{path.basename}}'

Here I want to override helm.valueFiles to include cluster specific values along with defaults by using '{{name}}.yaml.

At the same time, it's desired for some apps to be excluded from certain clusters and only target a single production cluster. It would be nice to achieve this with a single ApplicationSet and not have to separate production applications into separate folders.

kazysgurskas avatar Sep 16 '21 06:09 kazysgurskas

It sounds like you were looking for ways to exclude particular combinations generated by the matrix generator?

For example, if matrix generator:

- matrix
    generator1: (...)
    generator2: (...)

If generator1 produced a, b, c and generator2 produced d, e, f then the matrix generator will generate ad, ae, af, bc, be, bf, cd, ce, cf, etc. Do I have it right that you are looking for a mechanism to prevent some of those combinations from being emitted?

Yes, you are right.

parasappafluke avatar Sep 30 '21 05:09 parasappafluke

I managed to achieve the same request using Post selector all generators (introduced in #361).

adabuleanu avatar Nov 16 '22 08:11 adabuleanu

Also interested in this. The current workaround we are thinking of is having an AppSet per cluster, but it is not good enough, we would really to like use one AppSet to install all apps on all clusters, having the freedom to exclude particular apps from particular clusters.

reggie-k avatar Nov 21 '22 19:11 reggie-k