argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
17.4k stars 5.29k forks source link

ApplicationSet with multiple sources for helm charts and values #19703

Closed Destrukcja95 closed 2 weeks ago

Destrukcja95 commented 2 weeks ago

Hello ! I want to ask about ApplicationSet configuration for argocd in version 2.10 It is possible something like that - I want to define multiple sources, one for helm charts, and the second for values for this chart. Chart repo - harbor, and values repo - git Also i want to configure ApplicationSet from git generator. Here is my ApplicationSet example, but it is not working

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: example
  namespace: argocd
spec:
  generators:
  - git:
      repoURL: http://git.com.pl/projects/example/argo-cd.git
      revision: HEAD
      files:
      - path: "applications/*.yaml"
  template:
    metadata:
      name: '{{ name }}-{{ cluster.name }}'
      labels:
        ENV_ID: '{{ labels.environment }}'
        OWNER: '{{ labels.triggerer }}'
    spec:
      project: example
      sources:
        - repoURL: 'http://harbor.com.pl/chartrepo/charts'
          chart: '{{ helm.chart }}'
          targetRevision: '{{ helm.chartVersion }}'
          helm:
            valueFiles:
            - $valuesRef/values/{{ helm.values }}
        - repoURL: 'http://git.com.pl/projects/example/argo-cd.git'
          targetRevision: HEAD
          ref: valuesRef
      destination:
        server: '{{cluster.url}}'
        namespace: '{{ namespace }}'
      syncPolicy:
        automated:
          prune: true
          selfHeal: true

Can anbody anserw me that this solution is possible ?

gdsoumya commented 2 weeks ago

@Destrukcja95 you can specify whatever configuration you want to for the Application source as long as it's valid for a normal application. So in your case helm repo + values from git is a supported pattern in apps so appsets will also support it.

Destrukcja95 commented 2 weeks ago

Ok. So one question more... What is wrong in my the configuration above. ArgoCD is depoloying the application on the cluster, ApplicationSet is reading from my chart repo correctly, but values file for this chart in not reading from git repo, but directly from chart ( basic values ) Here is my manifest from argo-cd-server directly image Can anybody help me ? @gdsoumya

gdsoumya commented 2 weeks ago

Comparing the screenshot with the docs I personally cannot see the difference. so it might not be a syntactical error but rather the gitrepo misconfiguration for eg. the path that is being expected for the values which is causing the issue.

Destrukcja95 commented 2 weeks ago

When i changed the path for valueFiles, argocd had a problem with reading the file. So the path is good i think and argocd is reading it correctly. It is something else necessary to define for ApplicationSet to deploy application from chart repo and only values from git repo ? I think configuration is ok, but maybe something else i need that i don't know , because valueFiles from git repo is not changing enything in application deployment on kubernetes cluster @gdsoumya

Destrukcja95 commented 2 weeks ago

Ok, i dit it. My values was baddly formated i had something like that

generic:
  args:
  - -jar
  - /webapps/Student.jar
  - --spring.config.location=file:/dane/application.properties
  command:
  - java
  containerName: java
  containerPort: 8080

and i changed it for

args:
- -jar
- /webapps/Student.jar
- --spring.config.location=file:/dane/application.properties
command:
- java
containerName: java
containerPort: 8080

and it works @gdsoumya thank you very much for help :)

gdsoumya commented 2 weeks ago

Awesome! Closing the issue as it's resolved.