Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

using helm and git repos inside ApplicationSet #609

Open
adabuleanu opened this issue Nov 16, 2022 · 2 comments
Open

using helm and git repos inside ApplicationSet #609

adabuleanu opened this issue Nov 16, 2022 · 2 comments

Comments

@adabuleanu
Copy link

Hello. Is there a possibility to configure an ApplicationSet to create Applications with helm or git sources?

Example:

    spec:
      source:
        repoURL: "{{source.repoURL}}"
        chart:  "{{source.chart}}" # how will this key be dynamic?
        path: "{{source.path}}" # how will this key be dynamic?
        targetRevision: '{{source.targetRevision}}'
        helm:
          values:
            "{{source.helm.values}}"

And parameters should look something like this (will be passed by generators):

- appName: app1
  source:
    repoURL: my-helm-repo
    targetRevision: my-chart-version
    chart: my-chart
    helm:
      values: {}
- appName: app2
  source:
    repoURL: my-git-repo
    targetRevision: my-git-branch
    path: my-chart
    helm:
      values: {}

My use case is that I am storing helm charts inside git repos and for development purposes I point the Application to the git repo (with repoURL being a git repo and targetRevision being a git branch). After development is finished, the helm chart is published to a helm repo and I am referencing that in the Application. I want to achieve the same using ApplicationSets.

I did some research and the only thing that might help is this feature #11213 (with variant #11183), so I can use something like this in the ApplicationSet definition

    spec:
      source: "{{source}}"

Is there any way of achieving this functionality?

@glyhood
Copy link

glyhood commented Dec 7, 2022

@adabuleanu
Yes it's possible. I recently did this and documented it here
https://www.linkedin.com/pulse/continuous-deployment-argocd-applicationset-ifeoluwa-oluwole/

Basically this:

apiVersion: argoproj.io/v1alpha
kind: ApplicationSet
metadata:
  name: example-appset
  namespace: argocd
spec:
  generators:
  - git:
      repoURL: https://gitlab.com/abcxyz/example-project/argocd.git
      revision: main
      files:
      - path: "apps/examples/"
  template:
    metadata:
      name: '{{name}}'
    spec:
      project: '{{project}}'
      source:
        chart: helm-chart-name
        repoURL: https://<packaged helm chart url>
        targetRevision: 2.0
        helm:
          values: |-
            {{values}} # see "values" snippet below 
      destination:
        name: staging-cluster
        namespace: '{{namespace}}'
      
      syncPolicy:
        automated:
          prune: true
        syncOptions:
          - CreateNamespace=true

and the parameters to be passed via the values.yaml will look like this:

# This section is for the Argo CD Application resource

name: app1-example # Argo CD application resource name
project: linkedin # Argo CD project
namespace: staging # Ensures namespace in destination cluster exists. 


# This section contains the values for the helm chart
values: |-
  fullnameOverride: app1-staging
  image:
    repository: 1234567890.dkr.ecr.us-west-1.amazonaws.com/app1:latest
  namespace: staging
  containerPort: 7080
  autoscaling:
    enabled: false
  ingress:
    host: app1.staging.com
  env:
    enabled: false

@adabuleanu
Copy link
Author

adabuleanu commented Dec 8, 2022

@glyhood in your example you are creating Applications from ApplicationSets that use a source of helm chart inside a helm repository, while your values files are stored in a git repository. My question (maybe not clear) was related to the fact if you can use charts inside a helm repository or a in git repository.

For charts inside helm repository the Application will look like this:

    spec:
      source:
        repoURL: "{{source.repoURL}}" <--------- this is a helm repo (same "repoURL" key)
        chart:  "{{source.chart}}" <--------- "chart" key is specific to helm repositories
        targetRevision: '{{source.targetRevision}}'  <--------- this is the helm chart version (same "targetRevision" key)

For charts inside git repository the Application will look like this:

    spec:
      source:
        repoURL: "{{source.repoURL}}" <--------- this is a git repo (same "repoURL" key)
        path: "{{source.path}}" <--------- "path" key is specific to helm repositories
        targetRevision: '{{source.targetRevision}}'  <--------- this can be a git branch or a git tag (same "targetRevision" key)

From my investigation this is not possible at the moment. I found this feature request that might help with better "templating" inside ApplicationSets: argoproj/argo-cd#11183

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

No branches or pull requests

2 participants