Open arnitolog opened 3 years ago
Hi @arnitolog , if I am understanding your question correctly, take a look at https://argocd-applicationset.readthedocs.io/en/stable/Generators/#cluster-generator under metadata.labels.<key>
and the label selector section.
Hello @jgwest let's imagine that we have 3 clusters (dev-a and dev-b and prod-a). For dev clusters we have the following labels:
cluster-type: aks
env: dev
and for prod cluster:
cluster-type: aks
env: prod
So, what I'm talking about is the ability to use these labels in the templating like the example below:
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: test-appset
spec:
generators:
- clusters:
selector:
matchLabels:
argocd.argoproj.io/secret-type: cluster
template:
metadata:
name: 'demoservice-{{name}}'
spec:
project: "demo"
source:
path: helm/demo
repoURL: git@gitlab.com:demo.git
targetRevision: HEAD
helm:
releaseName: demo-k8s
valueFiles:
- values.{{labels.cluster-type}}.{{labels.env}}.yaml
syncPolicy:
syncOptions:
- CreateNamespace=true
destination:
server: '{{server}}'
namespace: demons
This applicationset will generate 3 apps with the following names:
demoservice-dev-a demoservice-dev-b demoservice-prod-a
but for demoservice-dev-a and demoservice-dev-b the same values file will be used: values.aks.dev.yaml
This actually will allow to dynamically add any number of "dev" clusters and all of them will use the same values file
Why not use the Git File generator?
but with git generator, I have to have a config file with static cluster endpoints. But what I'm looking for is a way to generate/deploy the application to any newly registered cluster of the specific type (line Dev/Prod/UAT) without the need to add/modify values files and/or destination endpoints
@arnitolog I had the same thought about an enhancement to the cluster generator. It could also be used to add cluster specific labels to the Application
.
I also think this would be a good enhancement to the cluster generator.
Is there any way (and if not, does it make sense to consider it as an enhancement) to use labels from cluster secrets in templating? Here is my use case: we have several clusters. Some of them in Azure (AKS), some in AWS(EKS), some managed ourselves. for each cluster, we have a secret in argocd which set of labels like below:
Also, we have an application (helm chart) with values files per type/env:
But the problem that we can have multiple "dev" clusters of the same type. Like dev-alfa, dev-bravo, etc So, I can't use {{name}} because in this case, I have to have a specific values file per cluster name. At the same time, all "dev" clusters will have the same set of labels. So using labels will provide more flexibility and remove unwanted efforts to configure values file per cluster name.