-
Notifications
You must be signed in to change notification settings - Fork 278
Git generator with condition #598
Comments
can anyone look into this please? |
Hi @rshiva777 try matrix generator it works perfectly for your usecase
|
To make it more clear, please find the below structure i have the below directory structure
test-applicationset.yaml
Now i have to deploy the application on to the cluster which have "app: test" label in the argocd secret of cluster, even though both configs are present in the cluster-configs/*.yaml path As per my testing, i added the label "app: test" on clusterA, and deployed the applicationset, but seems to be that test application is deployed on both clusterA and clusterB which is not expected. |
Since you have added matchLabels app: test in cluster genrator nested inside matrix generator Your applications will be deployed on cluster which has app: test label Since in argocd cluster is stored as secret , secret matching label app:test will be selected for deployment by applicationset |
Yes, but the application is deployed on the clusterB as well, where the label "app: test" is not added in the argocd secret. |
Any news on this ? @rishabh625 you matrix solution does not work, explanation below. The typical directory structure for this issue is: one config file per cluster and one directory including all (root) charts per cluster too, with argocd apps always targeting HEAD (and avoid the ugliness and headaches of using git branches with argocd). 1] With git generators only, I woud not be using the final 2] With your matrix suggestion and the directory structure, it is possible to filter the cluster we want the app to be deployed to, good point, but a matrix is generated: I would not have one application per environment/cluster, but Now that the case is described, you see that this is a very common case, and this is the case of @rshiva777 as he inputted in his original post: spec:
generators:
- git:
...
files:
- path: "applicationsets/git-generator/cluster-config/**/config.yaml" <--- a config file per cluster
template:
...
source:
...
path: applicationsets/git-generator/overlays/{{cluster.overlay}} <--- a chart directory per cluster Finally, the original suggestion of @rishabh625 would fix the issue: no matrix generated, and we would be able to filter the clusters we want an app to be deployed (not all envs, only dev for example if divided by envs). |
After checking, the merge generator is the solution to this problem. Simply set the cluster generator as parent, and the git generator as (only) child, merging on The issue can be closed. |
@leotomas837 , would you mind sharing an example of your working manifest using |
I am using git generator for deploying applications. I want to deploy an application on to a cluster only if the cluster has particular labels matched in applicationset, else ignore it
If i remove the cluster generator part from the manifest and keep only git generator, application are creating on all the cluster configs that are present on the below path
applicationsets/git-generator/cluster-config/**/config.yaml
I want an feature where i can restrict the app deployment to destination cluster, it should happen only when the secret of cluster in argocd has the below label:
app: testapp
Below is a sample manifest
Here is the sample config file of a single cluster:
applicationsets/git-generator/cluster-config/testcluster/config.yaml
The above applicationset should create an application on if the destination cluster has the below labels in argocd secret:
app: testapp
I tried to check on merge generator with git and cluster generators, but didnt find any clues to use.
The text was updated successfully, but these errors were encountered: