applicationset icon indicating copy to clipboard operation
applicationset copied to clipboard

Enhancement - Conditional plugin support

Open rbkaspr opened this issue 3 years ago • 3 comments

What's the issue?

For some organizations, a monorepo of application manifests can contain a mix of different deployment mechanisms, especially when different teams with different preferences for things like Helm/Kustomize/etc are handling different deployments. If each of those deployments uses a standard structure that Argo natively understands, ApplicationSets can handle that with no issue.

However, if some of those manifests require special deployment logic (kustomized-helm, for example), the current ApplicationSet generators are basically all-or-nothing deals, mainly because of the fact that pluginSpec is a map and an ApplicationSpec can't just contain a name field with an empty string (otherwise this could be handled by setting or not setting a plugin value in settings file if we were using the git file generator.

(Potential) Solution: Allow maps to be substituted

The current git file generator only seems to support substituting values as strings, adding map support could address this use case (and potentially others down the line)

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: sample
spec:
  generators:
  - git:
      repoURL: https://github.com/argoproj-labs/applicationset.git
      revision: HEAD
      files:
      - path: "examples/git-generator-files-discovery/cluster-config/**/config.json"
  template:
    metadata:
      name: '{{cluster.name}}-guestbook'
    spec:
      project: default
      source:
        repoURL: https://github.com/argoproj-labs/applicationset.git
        targetRevision: HEAD
        path: "examples/git-generator-files-discovery/apps/guestbook"
      destination:
        server: https://kubernetes.default.svc
        namespace: guestbook
        '{{ plugin }}'

If we want to include a plugin, we add this to our config.json for a given app

{
  "plugin": {
    "name": "kustomized-helm"
  }
}

If not, we either explicitly set plugin to be empty {}, or else omit the key, and the generator can just drop the plugin field from the generated ApplicationSpec

rbkaspr avatar Mar 24 '21 19:03 rbkaspr

@rbkaspr Did you ever a figure out a workaround for this?

I am in a similar boat where the entire cluster is deployed using a single ApplicationSet utilizing Helm. However, one of the deployments requires Kustomize and that means I need to either deploy it separately or add kustomization.yaml for every project. Neither is ideal.

gajus avatar Jan 31 '22 09:01 gajus

anyone found a workaround maybe with the latest changes as the gotemplate sprig functions https://github.com/Masterminds/sprig ? Or another workaround that allows applications with or without plugins from the same application set?

also noticed plugin: {} does not work the whole key should be ommited

else this would work as this results in 'plugin

spec:
  goTemplate: true      
  source:
    path: mypath
    plugin:
      name: '{{default "" .pluginName}}'	

with a json

{
  pluginName: "myplugin"
}

if no pluginName var is specified it wil result in plugin: {} but that still gives an error in argocd

rpc error: code = Unknown desc = Manifest generation error (cached): plugin sidecar failed. could not find plugin supporting the given repository

martijnvdp avatar May 22 '23 08:05 martijnvdp

Hello, is there already a solution to this problem available? I have the same requirement. Otherwise, I am not able to use the ApplicationSet Git Generator pattern when I have helm and kustomize applications in my repository.

amrap030 avatar Sep 25 '23 16:09 amrap030