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

Allow interpolation of variables from generators in ApplicationSet SyncPolicy #13190

Closed
DaThumpingRabbit opened this issue Apr 11, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@DaThumpingRabbit
Copy link

Summary

We would like to have the ability to use variables inside the syncPolicy field of an applicationSet, based on the values of the cluster generator.

Motivation

We are using argocd to bootstrap kubernetes clusters, meaning that we use the cluster registration in the secret to trigger the automatic creation of applications in order to deploy the helm charts that we need in the cluster.
We are using the cluster generator and it works very well like this:

  • an applicationset 'cluster-bootstrap' that has a cluster generator and templates a custom helm charts with the application inside
  • a set of applications for the helm charts we need

However, we encounter an issue that is the applicationSet syncPolicy is not able to interpolate variables from the generator (especially the preserveResourcesOnDeletion field). We would like to be able to have the ability ,from the cluster generator labels, to set this field to true or false, according to the context of the cluster (set it to true for prod for example in case of an issue with our argocd instance).

Proposal

I have seen that it is possible to interpolate variables outside of the template field in this pull request #9254 and wonder if the same kind of things could be done for the syncPolicy field.

@DaThumpingRabbit DaThumpingRabbit added the enhancement New feature or request label Apr 11, 2023
@riteshnanda09
Copy link

This feature #11567 would solve it. Looks targeted for release 2.7.0

@DaThumpingRabbit
Copy link
Author

DaThumpingRabbit commented Apr 20, 2023

Maybe I am missing some understanding of this feature #11567 but I don't think that is solving what I am trying to achieve
If I understand correctly, this will allow to template the spec.template.spec.syncPolicy path of an applicationSet, whereas I would like to be able to template this spec.syncPolicy path

Here is an example of what I had in mind with a list generator

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: my-clusters
spec:
  generators:
  - list:
      elements:
      - cluster: prod
        preserveResources: true
      - cluster: dev
        preserveResources: false
  syncPolicy:
    preserveResourcesOnDeletion: {{preserveResources}}
  template:
    metadata:
      name: '{{cluster}}'
    spec:
      source:
        path: '{{cluster}}'
        repoURL: https://<my-git-repository>.git
      destination:
        name: '{{cluster}}'

and with a cluster generator

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: my-clusters
spec:
  generators:
  - clusters: {}
  syncPolicy:
    preserveResourcesOnDeletion: '{{metadata.annotations.preserve-resources}}'
  template:
    metadata:
      name: '{{name}}'
    spec:
      source:
        path: '{{name}}'
        repoURL: https://<my-git-repository>.git
      destination:
        name: '{{name}}'

If that is indeed covered by the issue mentioned, I'll be glad to close this and wait for the 2.7.0 release

@blakepettersson
Copy link
Member

This should be fixed with #14893, feel free to reopen if that's not the case

@DaThumpingRabbit
Copy link
Author

Hey @blakepettersson
If I am not mistaken, #14893 only allows to template values under the path .spec.template
However, the ApplicationSet parameter that I need to template is .spec.syncPolicy.preservResourcesOnDeletion and I don't think that it is part of this update
Let me know if I am mistaken and if there is already a solution for my issue
Thanks

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

No branches or pull requests

3 participants