Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrix list generator with elementsYaml not working with git repos #21336

Closed
3 tasks done
tomlnd opened this issue Dec 30, 2024 · 2 comments
Closed
3 tasks done

Matrix list generator with elementsYaml not working with git repos #21336

tomlnd opened this issue Dec 30, 2024 · 2 comments
Labels
component:application-sets Bulk application management related user-issue An issue caused by the user ecosystem, misconfiguration or misuse of Argo CD version:2.12 Latest confirmed affected version is 2.12

Comments

@tomlnd
Copy link

tomlnd commented Dec 30, 2024

Checklist:

  • I've searched in the docs and FAQ for my answer: https://bit.ly/argocd-faq.
  • I've included steps to reproduce the bug.
  • I've pasted the output of argocd version.

Describe the bug

ArgoCD's applicationsets allows fetching deployable charts from a file in a gitops repository, as seen in the docs. This feature works fine with helm charts (by using template.spec.sources.chart), but seems to fail when trying to deploy pure manifests from a git repository (by using template.spec.sources.path).

Here's a working Application CRD:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: ingress-nginx
  namespace: argocd
spec:
  project: infrastructure
  sources:
    - repoURL: 'https://github.com/kubernetes/ingress-nginx.git'
      path: "deploy/static/provider/cloud"
      targetRevision: HEAD
  destination:
    server: 'https://kubernetes.default.svc'
    namespace: ingress-nginx
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

But when converting it to an ApplicationSet like below where the first source's values are being feeded from the yaml-file, while the second source allows me to supply additional custom manifests to the applications:

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: infrastructure-appset
  namespace: argocd
spec:
  goTemplate: true
  goTemplateOptions: ["missingkey=error"]
  generators:
  - matrix:
      generators:
        - git:
            repoURL: 'https://gitlab.com/xxx/example-repo.git'
            revision: master
            files:
              - path: 'appsets/configs/infrastructure-config.yaml'
        - list:
            elementsYaml: '{{ .app.charts | toJson }}'
  template:
    metadata:
      name: '{{.name}}'
    spec:
      project: infrastructure
      syncPolicy:
        automated:
          prune: true
          selfHeal: true
        syncOptions:
          - CreateNamespace=true
          - ServerSideApply=true
      sources:
        - repoURL: '{{.repoUrl}}'
          path: '{{.path}}' # see this
          chart: '{{.chart}}'
          targetRevision: '{{.version}}'
        - repoURL: 'https://gitlab.com/xxx/example-repo.git'
          targetRevision: master
          path: 'apps/infrastructure/{{.name}}'
      destination:
        server: 'https://kubernetes.default.svc'
        namespace: '{{.namespace}}'

And using the following example appsets/configs/infrastructure-config.yaml file to deploy 2 applications:

app:
  charts:
    - name: ingress-nginx
      path: "deploy/static/provider/cloud" # the path in the repoUrl repository
      chart: "" # empty since it's a git repo
      version: "main"
      repoUrl: "https://github.com/kubernetes/ingress-nginx.git"
      namespace: ingress-nginx
    - name: cert-manager
      chart: cert-manager
      path: ""
      version: "v1.16.1"
      repoUrl: "https://charts.jetstack.io"
      namespace: cert-manager

The cert-manager application will deploy successfully, but the ingress-nginx application will fail with the following error:

ComparisonError
Failed to load target state: failed to generate manifest for source 1 of 2: rpc error: code = Unknown desc = map[basename:configs basenameNormalized:configs filename:infrastructure-config.yaml filenameNormalized:infrastructure-config.yaml path:appsets/configs segments:[appsets configs]]: app path does not exist

Version

argocd: v2.12.6+4dab5bd
@tomlnd tomlnd added the bug Something isn't working label Dec 30, 2024
@tomlnd
Copy link
Author

tomlnd commented Dec 31, 2024

Seems like ArgoCD is parsing the path as a map instead of a string. The sources tab in the dashboard shows this as the path:

map[basename:configs basenameNormalized:configs filename:infrastructure-config.yaml filenameNormalized:infrastructure-config.yaml path:appsets/configs segments:[appsets configs]]

And clicking on that will literally redirect to https://github.com/kubernetes/ingress-nginx/tree/main/map[basename:configs%20basenameNormalized:configs%20filename:infrastructure-config.yaml%20filenameNormalized:infrastructure-config.yaml%20path:appsets/configs%20segments:[appsets%20configs]].

@andrii-korotkov-verkada andrii-korotkov-verkada added version:2.12 Latest confirmed affected version is 2.12 component:application-sets Bulk application management related labels Jan 1, 2025
@agaudreault agaudreault added user-issue An issue caused by the user ecosystem, misconfiguration or misuse of Argo CD and removed bug Something isn't working labels Jan 14, 2025
@agaudreault
Copy link
Member

agaudreault commented Jan 14, 2025

I think what happens is that matrix merges all property in the same object (.). When you are doing, in your go template, .path, you are using the .path variable of the git generator, and not the one from the list. In the docs, it mention the usage of pathParamPrefix. I think you should try that, or rename rename path from app.charts to something else.

https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/Generators-Matrix/#example-two-git-generators-using-pathparamprefix

Closing. Feel free to reopen if that didn't fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:application-sets Bulk application management related user-issue An issue caused by the user ecosystem, misconfiguration or misuse of Argo CD version:2.12 Latest confirmed affected version is 2.12
Projects
None yet
Development

No branches or pull requests

3 participants