TL; DR: Here’s a working ArgoCD Application Set in YAML with probably all popular features + comments. I wouldn’t expect anyone got theirselves here without knowing what an ArgoCD ApplicationSet is for but just in case.
---
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
annotations: {}
labels:
name: argocd-application-set
name: argocd-application-set
namespace: argocd
spec:
generators:
# list is usually the most versatile generator
- list:
elements:
- cascadeDelete: false
destination_namespace: argocd
destination_server: https://kubernetes.default.svc
disableDefaultLibs: false
libs: []
name: argocd
path: argocd
project: ci-cd
prune: true
repoURL: https://github.com:my-account/my-argo-repo.git
selfHeal: true
syncOptions: []
targetRevision: HEAD
# top level arguments
tlas:
- name: env
value: nonprod
- name: foo
value: bar
- name: cluster
value: beta
- <next item> ...
goTemplate: true
goTemplateOptions:
- missingkey=error
template:
metadata:
# value of String type can go like this
name: '{{ .name }}'
spec:
destination:
namespace: '{{ .destination_namespace }}'
server: '{{ .destination_server }}'
ignoreDifferences: []
project: '{{ .project }}'
source:
path: '{{ .path }}'
repoURL: '{{ .repoURL }}'
targetRevision: '{{ .targetRevision }}'
syncPolicy:
syncOptions:
# common value for all ArgoCD Applications
- ApplyOutOfSyncOnly=true
# advanced patching usiong conditions and loops
# for values that are more than simple strings
templatePatch: |
metadata:
{{ -if .cascadeDelete }}
finalizers:
- resources-finalizer.argocd.argoproj.io
{{ -end }}
spec:
source:
directory:
jsonnet:
tlas:
{{ -range $tla in .tlas }}
- name: '{{ $tla.name }}'
value: '{{ $tla.value }}'
{{ -end }}
libs:
{{ -if not .disableDefaultLibs }}
- 'mylib.libsonnet'
{{ -end }}
{{ -range $lib in .libs }}
- '{{ $lib }}'
{{ -end }}
syncPolicy:
automated:
prune: '{{ .prune }}'
selfHeal: '{{ .selfHeal }}'A good reference: https://medium.com/@geoffrey.muselli/argocd-at-scale-with-applicationset-go-template-7f326d8a61f3
🙂
