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

ApplicationSet in ArgoCD Helm Chart #1

Open
JimFran opened this issue Nov 18, 2021 · 6 comments
Open

ApplicationSet in ArgoCD Helm Chart #1

JimFran opened this issue Nov 18, 2021 · 6 comments

Comments

@JimFran
Copy link

JimFran commented Nov 18, 2021

Hello,

When using ArgoCD Helm Chart. How can I use ApplicationSet in Values.yml files? I cannot see the option to add the application set file.

I just want to setup a single applicationset file in values.yml and point to the clusters and folders where applications are located.

In case that is not possible to add this applicaitonset in values.yml file how can I pass this file?

Thank you in advance.

@JimFran
Copy link
Author

JimFran commented Nov 21, 2021

My question is about ApplicationSet in ArgoCD Helm.

In a regular ArgoCD deployment in order to use applicationset we use this kind of deployment:

** I want to use ApplicationSet to deploy applications to more than one AKS server **

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: guestbook
spec:
  generators:
  - list:
      elements:
      - cluster: engineering-dev
        url: https://1.2.3.4
      - cluster: engineering-prod
        url: https://2.4.6.8
      - cluster: finance-preprod
        url: https://9.8.7.6
  template:
    metadata:
      name: '{{cluster}}-guestbook'
    spec:
      source:
        repoURL: https://github.com/infra-team/cluster-deployments.git
        targetRevision: HEAD
        path: guestbook/{{cluster}}
      destination:
        server: '{{url}}'
        namespace: guestbook

In ArgoCD Helm Values.yml file I can see this section to add applications but not to use applicationset:

dditionalApplications: []
  # - name: guestbook
  #   namespace: argocd
  #   additionalLabels: {}
  #   additionalAnnotations: {}
  #   finalizers:
  #   - resources-finalizer.argocd.argoproj.io
  #   project: guestbook
  #   source:
  #     repoURL: https://github.com/argoproj/argocd-example-apps.git
  #     targetRevision: HEAD
  #     path: guestbook
  #     directory:
  #       recurse: true
  #   destination:
  #     server: https://kubernetes.default.svc
  #     namespace: guestbook
  #   syncPolicy:
  #     automated:
  #       prune: false
  #       selfHeal: false
  #   ignoreDifferences:
  #   - group: apps
  #     kind: Deployment
  #     jsonPointers:
  #     - /spec/replicas
  #   info:
  #   - name: url
  #     value: https://argoproj.github.io/

My question then:

Can I use ApplicationSet in ArgoCD Helm values.yml file? Instead of deploy an applicationset.yml I want to do this using argocd helm values.yml file.

Hope this clarifies my question.

@xsreality
Copy link
Owner

@JimFran The Argo CD Helm Chart does not have a configuration for declaring ApplicationSets. The workaround is to declare an Application that creates the ApplicationSet (remember Argo CD application can be used to deploy anything including ApplicationSet :D).

Here's an example: https://github.com/xsreality/argocd-applicationset-demo/blob/main/top-level-app/TopLevelApplication.yaml

@JimFran
Copy link
Author

JimFran commented Nov 22, 2021

@JimFran The Argo CD Helm Chart does not have a configuration for declaring ApplicationSets. The workaround is to declare an Application that creates the ApplicationSet (remember Argo CD application can be used to deploy anything including ApplicationSet :D).

Here's an example: https://github.com/xsreality/argocd-applicationset-demo/blob/main/top-level-app/TopLevelApplication.yaml

Thanks for your message @xsreality

I'm doing something that's not working... not sure if I'm following the correct approarch to deploy applicationset.

This is my override_values.yml file that I use to deploy argocd helm chart:

In "additional applications", in override_values.yml file, I specified the path to my ApplicationSet.yml file So basically inside additional application i will deploy an applicationset file which is located in another folder inside the same repo.

I'm deploying two applications (argocd for self managed and sonarqube). ArgoCD is located at "argocd/argocd-install/argocd" and SonarQube applicationset in "app/applicationfiles" path

## ArgoCD configuration
## Ref: https://github.com/argoproj/argo-cd
##
## Server
server:

  extraArgs:
    - --rootpath=/argocd

  ## ArgoCD config
  ## reference https://github.com/argoproj/argo-cd/blob/master/docs/operator-manual/argocd-cm.yaml
  configEnabled: true
  config:
    repositories: |
      - type: git
        url: https://xxx@dev.azure.com/xxx/Test/_git/sonarqube
      - name: argo-helm
        type: helm
        url: https://argoproj.github.io/argo-helm
  configs:
    credentialTemplates:
      https-creds:
        url: https://xxx@dev.azure.com/xxx/Test/_git/sonarqube
        username: ***
        password: ***
  additionalApplications: 

    - name: argocd
      namespace: argocd
      destination:
        namespace: argocd
        server: https://kubernetes.default.svc
      project: argocd
      source:
        helm:
          version: v3
          valueFiles:
          - values.yaml
          - ../values-override.yaml
        path: argocd/argocd-install/argocd
        repoURL: https://xxx@dev.azure.com/xxx/Test/_git/sonarqube
        targetRevision: HEAD
      syncPolicy:
        syncOptions:
        - CreateNamespace=true

    - name: sonarqube
      namespace: argocd 
      destination:
        namespace: argocd
        server: https://kubernetes.default.svc
      project: argocd
      source:
        path: app/applicationfiles
        repoURL: https://xxx@dev.azure.com/xxx/Test/_git/sonarqube
        targetRevision: HEAD
        directory:
          recurse: true
          jsonnet: {}
      syncPolicy:
        automated:
          selfHeal: true
          prune: true

    - name: argocd-appprojects
      namespace: argocd
      destination:
        namespace: argocd
        server: https://kubernetes.default.svc
      project: argocd
      source:
        path: argocd-appprojects
        repoURL: xxx
        targetRevision: HEAD
        directory:
          recurse: true
          jsonnet: {}
      syncPolicy:
        automated:
          selfHeal: true
          prune: true

  additionalProjects: 
    - name: argocd
      namespace: argocd
      additionalLabels: {}
      additionalAnnotations: {}
      description: Argocd Project
      sourceRepos:
      - '*'
      destinations:
      - namespace: argocd
        server: https://kubernetes.default.svc
      clusterResourceWhitelist:
      - group: '*'
        kind: '*'
      orphanedResources:
        warn: false

  config:
    url: https://xxx/argocd
    application.instanceLabelKey: argocd.argoproj.io/instance

    oidc.config: |
      name: Azure
      issuer: https://login.microsoftonline.com/yyy/v2.0
      clientID: zzz
      clientSecret: $oidc.azuread.clientSecret
      requestedIDTokenClaims:
        groups:
          essential: true
      requestedScopes:
        - openid
        - profile
        - email

  rbacConfig:
    policy.csv: |
      p, role:admin, applications, *, */*, allow
      p, role:admin, clusters, get, *, allow
      p, role:admin, repositories, get, *, allow
      p, role:admin, repositories, create, *, allow
      p, role:admin, repositories, update, *, allow
      p, role:admin, repositories, delete, *, allow
      g, xxx, role:admin
    policy.default: role:readonly

This is the applicationset.yml file that I'm using to deploy the SonarQube app in my AKS cluster (located at app/applicationfiles inside the repo). SonarQube app files are located at "sonarqube" folder inside the repo.

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: sonarqube
spec:
  generators:
  - list: 
      # Parameters are generated based on this cluster list, to be substituted
      # into the template below.
      elements: 
      - cluster: SonarQubeHelm
        url: https://kubernetes.default.svc
  template: 
    # An Argo CD Application template, with support for parameter substitution 
    # with values from parameters generated above.
    metadata:
      name: '{{cluster}}-sonarqube'
    spec:
      project: argocd
      source:
        repoURL: https://xxx@dev.azure.com/xxx/Test/_git/sonarqube
        targetRevision: HEAD
        path: sonarqube
      destination:
        server: '{{url}}'
        namespace: argocd

When deploying argocd helm it is not working.... I mean, I cannot even access the URL of argoCD and nothing is being deploied in AKS.

Paths are OK and Files of ArgoCD and SonarQube are fine because when I use this override_values.yml file specifying the exact path of SonarQube application (not using an applicationset.yml file) it is working fine.

Any idea why is not working?

@xsreality
Copy link
Owner

@JimFran I think you are trying to do too many things at once. As a first step, try to deploy the Argo CD helm charts with default values.yaml in the argocd namespace of the cluster and verify it is running correctly (accessing the UI etc). You can follow the official Argo CD docs. Just running this command should be enough: helm upgrade --install argocd-demo argo/argo-cd -n argocd.

Once you have Argo CD installed, then the next step can be to add a custom application by overriding the additionalApplications config of values.yaml.

@JimFran
Copy link
Author

JimFran commented Nov 22, 2021

Hello, it is already resolved. The issue was related to the naming of the applicationset.yml file. I had to use lowercase in cluster naming.

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: sonarqube
spec:
  generators:
  - list: 
      # Parameters are generated based on this cluster list, to be substituted
      # into the template below.
      elements: 
      - cluster: sonarqubehelm
        url: https://kubernetes.default.svc

Thanks for your support.
Regards,

@xsreality
Copy link
Owner

Glad to hear you got it working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants