Closed
Description
Summary
If we want to access a list of cluster used inside ArgoCD, we generally use the clusterGenerator
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: guestbook
namespace: argocd
spec:
goTemplate: true
goTemplateOptions: ["missingkey=error"]
generators:
- clusters:
selector:
matchLabels:
staging: "true"
template:
metadata:
name: '{{.name}}-guestbook' # 'name' field of the Secret
spec:
project: "my-project"
source:
repoURL: https://github.com/argoproj/argocd-example-apps/
targetRevision: HEAD
path: guestbook
destination:
server: '{{.server}}' # 'server' field of the secret
namespace: guestbook
However, this ends up creating one Application per cluster selected.
It is useful to create one Application in each of those clusters, but sometimes we only need to get the clusters info without using them as destination.
Would there be a way to get the list of cluster matched, and use them as a value list inside a single Application ?
Something like:
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: guestbook
namespace: argocd
spec:
goTemplate: true
goTemplateOptions: ["missingkey=error"]
generators:
- clusters:
flatClusterMode: true #<------ Dummy option to use it flat
selector:
matchLabels:
staging: "true"
template:
metadata:
name: 'my-guestbook'
spec:
project: "my-project"
source:
repoURL: https://github.com/argoproj/argocd-example-apps/
targetRevision: HEAD
path: guestbook
helm:
values: |
clusters:
{{ range .clusters }} #<--- access the cluster list
- name: {{ .name }}
{{ end }}
destination:
server: 'in-cluster' # <--- deploying it a single place
namespace: guestbook