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

Open
3 tasks done
tomlnd opened this issue Dec 30, 2024 · 1 comment
Open
3 tasks done

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

tomlnd opened this issue Dec 30, 2024 · 1 comment
Labels
bug Something isn't working component:application-sets Bulk application management related 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component:application-sets Bulk application management related version:2.12 Latest confirmed affected version is 2.12
Projects
None yet
Development

No branches or pull requests

2 participants