argoproj / applicationset

The ApplicationSet controller manages multiple Argo CD Applications as a single ApplicationSet unit, supporting deployments to large numbers of clusters, deployments of large monorepos, and enabling secure Application self-service.
https://argocd-applicationset.readthedocs.io/
Apache License 2.0
586 stars 279 forks source link

Can ApplicationSets and App of Apps be used together in a monorepo? #488

Closed AnjaliSrivastava29 closed 2 years ago

AnjaliSrivastava29 commented 2 years ago

I am trying to deploy a very big service consisting of different components with ArgoCD. I'm using a single repo to define all the components and using ApplicationSets to divide config based on environments, so each environment gets one ApplicationSet (dev, staging, prod..) each. For each environment, the targetRevision will be different.

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: dev
spec:
  generators:
  - git:
      repoURL:<repoURL>
      revision: <dev-commit>
      files:
      - path: deployments/dev/**/config.yaml
template:
...
    spec:
...
      source:
        repoURL: <repoURL>
        targetRevision: <dev-commit>
        path: **apps**
...

Here, my source path apps has a Helm Chart format with multiple App definitions inside, to signify each different component of the over-all service which makes the structure as an ApplicationSet deploying a single app per cluster. And that app brings up several child apps on the target cluster. However, the problem is that all these App definitions need repoURL and targetRevision to be valid. Is there a way I can send the targetRevision from the ApplicationSet to these child apps?

Otherwise, even if ApplicationSets are defining a new config for each environment based on the targetRevision mentioned in the AppSet yaml, the several Apps inside apps folder will have a static spec for targetRevision which is shared across environments, which is not desirable. I want to be able to change only 1 value(targetRevision in this case) in ApplicationSet YAMLs and have all the downstream apps use this value as well.

AnjaliSrivastava29 commented 2 years ago

@jgwest Do you have any comments on the above question?

PS: I'm using AppofApps to be able to control the order of the deployment of each component. With each app(that deploys one single component) having its own sync wave.

faraktingi commented 2 years ago

Hello @AnjaliSrivastava29 We are also facing the same issue as we are trying to use ApplicationSet deploying a first Application which will then deploy others Applications. Based on the following schema:

ApplicationSets  deploys
      -> Combined-App  which creates
                 -> App1
                 -> App2

This architecture supposes to control the Sync wave between waves. Deploying applications in a specific order.

AnjaliSrivastava29 commented 2 years ago

I was able to use Helm plugin in the Appset and Application YAMLs to deliver the values to the most bottom level.

glyhood commented 2 years ago

I was able to achieve this by doing the following.

ApplicationSet:

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: dev-appset
  namespace: argocd
spec:
  generators:
  - git:
      repoURL: https://<repo where values.yaml file exist>
      revision: main
      files:
      - path: "apps/**/*.yaml"
  template:
    metadata:
      name: '{{name}}'
    spec:
      project: '{{project}}'
      source:
        chart: xyz
        repoURL: https://<packaged helm chart url>
        targetRevision: 1.0
        helm:
          values: |-
            {{values}}
      destination:
        name: cluster-1
        namespace: '{{namespace}}'

      syncPolicy:
        automated:
          prune: true
        syncOptions:
          - CreateNamespace=true

And this is how my different yaml files with values looked like. I discarded the I discarded my parent App of Apps manifest and also the child application manifests too. Unlike App of Apps which shows the parent app with its child apps in the UI, the ApplicationSet does not show in the UI, only the child apps show.

name: app1
project: testing
namespace: app1
values: |
    fullnameOverride: app1
    image:
        repository: <docker image repo url>
    namespace: app1
    containerPort: 7080
    autoscaling:
        enabled: true
    ingress:
        host: app1.test.com
kksudo commented 1 year ago

@faraktingi Why do you need an ApplicationSet in your schema? Why you can't use just AppOfApps approach?

Hello @AnjaliSrivastava29 We are also facing the same issue as we are trying to use ApplicationSet deploying a first Application which will then deploy others Applications. Based on the following schema:

ApplicationSets  deploys
      -> Combined-App  which creates
                 -> App1
                 -> App2

This architecture supposes to control the Sync wave between waves. Deploying applications in a specific order.