@@ -11,86 +11,58 @@ spec:
11
11
goTemplate : true
12
12
goTemplateOptions : ["missingkey=error"]
13
13
generators :
14
+ # matrixes clusters with the applications
14
15
- matrix :
15
16
generators :
16
- - clusters :
17
- selector :
18
- matchExpressions :
19
- - key : understack.rackspace.com/role
20
- operator : In
17
+ - merge :
18
+ mergeKeys :
19
+ # merge cluster configs based on cluster name
20
+ - name
21
+ generators :
22
+ # load all clusters
23
+ - clusters :
24
+ selector :
25
+ matchExpressions :
26
+ - key : understack.rackspace.com/role
27
+ operator : In
28
+ values :
29
+ - " global"
30
+ - " site"
31
+ - " aio"
32
+ # dev clusters allow some overrides
33
+ - clusters :
34
+ selector :
35
+ matchLabels :
36
+ understack.rackspace.com/env : dev
21
37
values :
22
- - " global"
23
- - " regional"
24
- - " aio"
25
- values :
26
- uc_skip_components : ' {{ default "[]" (index .metadata.annotations "uc_skip_components") }}'
27
- uc_repo_git_url : ' {{index .metadata.annotations "uc_repo_git_url"}}'
28
- uc_repo_ref : ' {{index .metadata.annotations "uc_repo_ref"}}'
29
- uc_deploy_git_url : ' {{index .metadata.annotations "uc_deploy_git_url"}}'
30
- uc_deploy_ref : ' {{index .metadata.annotations "uc_deploy_ref"}}'
31
- uc_role : ' {{index .metadata.labels "understack.rackspace.com/role"}}'
32
- uc_dns_zone : ' {{index .metadata.annotations "dns_zone" }}'
33
- uc_cluster_issuer : ' {{index .metadata.annotations "uc_cluster_issuer" }}'
34
- uc_global_dns_zone : ' {{index .metadata.annotations "uc_global_dns_zone" }}'
35
- - list :
36
- elements :
37
- - component : cert-manager
38
- skipComponent : ' {{has "cert-manager" (.values.uc_skip_components | fromJson)}}'
39
- sources :
40
- - repoURL : https://charts.jetstack.io
41
- chart : cert-manager
42
- targetRevision : ' 1.15.2'
43
- helm :
44
- releaseName : cert-manager
45
- valuesObject :
46
- crds :
47
- enabled : true
48
- - component : ingress-nginx
49
- skipComponent : ' {{has "ingress-nginx" (.values.uc_skip_components | fromJson)}}'
50
- sources :
51
- - repoURL : https://kubernetes.github.io/ingress-nginx
52
- chart : ingress-nginx
53
- targetRevision : 4.12.1
54
- helm :
55
- releaseName : ingress-nginx
56
- valueFiles :
57
- - $deploy/{{.name}}/helm-configs/ingress-nginx.yaml
58
- ignoreMissingValueFiles : true
59
- - repoURL : ' {{ .values.uc_deploy_git_url }}'
60
- targetRevision : ' {{ .values.uc_deploy_ref }}'
61
- ref : deploy
62
- - component : cilium
63
- skipComponent : ' {{or (has "cilium" (.values.uc_skip_components | fromJson)) (eq "global" .values.uc_role)}}'
64
- sources :
65
- # Cilium itself is deployed before ArgoCD so we only include project
66
- # and environment specific stuff here
67
- - repoURL : ' {{ .values.uc_deploy_git_url }}'
68
- targetRevision : ' {{ .values.uc_deploy_ref }}'
69
- path : ' {{.name}}/manifests/cilium'
70
- - component : etcdbackup
71
- componentNamespace : kube-system
72
- skipComponent : ' {{has "etcdbackup" (.values.uc_skip_components | fromJson)}}'
73
- sources :
74
- - repoURL : ' {{ .values.uc_repo_git_url }}'
75
- targetRevision : ' {{ .values.uc_repo_ref }}'
76
- path : ' components/etcdbackup'
77
- ref : understack
78
- helm :
79
- valueFiles :
80
- - $understack/components/etcdbackup/values.yaml
81
- - $deploy/{{.name}}/helm-configs/etcdbackup.yaml
82
- ignoreMissingValueFiles : true
83
- - repoURL : ' {{ .values.uc_deploy_git_url }}'
84
- targetRevision : ' {{ .values.uc_deploy_ref }}'
85
- ref : deploy
86
- selector :
87
- # by setting the key in the elements 'skipComponent' to 'true' it will skip installing it
88
- # ArgoCD's templating operates with strings so it's the string "true"
89
- matchExpressions :
90
- - key : skipComponent
91
- operator : NotIn
92
- values :
93
- - " true"
38
+ understack_url : ' {{index .metadata.annotations "uc_repo_git_url"}}'
39
+ understack_ref : ' {{index .metadata.annotations "uc_repo_ref"}}'
40
+ deploy_url : ' {{index .metadata.annotations "uc_deploy_git_url"}}'
41
+ deploy_ref : ' {{index .metadata.annotations "uc_deploy_ref"}}'
42
+ # now the applications matrixed with the clusters
43
+ - merge :
44
+ mergeKeys :
45
+ # merge config based on component name
46
+ - component
47
+ generators :
48
+ - git :
49
+ repoURL : ' {{ .values.understack_url }}'
50
+ revision : ' {{ .values.understack_ref }}'
51
+ files :
52
+ - path : " apps/infra/*.yaml"
53
+ - git :
54
+ repoURL : ' {{ .values.deploy_url }}'
55
+ revision : ' {{ .values.deploy_ref }}'
56
+ files :
57
+ # due to https://github.com/argoproj/argo-cd/issues/22051
58
+ # we need to do this workaround. this reads the apps.yaml
59
+ # for per cluster
60
+ - path : ' {{ "{{.name}}" }}/apps.yaml'
61
+ selector :
62
+ matchExpressions :
63
+ # if you set skip to any value for the component in apps.yaml, this will disable it
64
+ - key : skip
65
+ operator : DoesNotExist
94
66
template :
95
67
metadata :
96
68
name : ' {{.name}}-{{.component}}'
@@ -115,12 +87,61 @@ spec:
115
87
argocd.argoproj.io/sync-options : Delete=false
116
88
templatePatch : |
117
89
spec:
90
+ {{- $root := . }}
91
+ {{- if hasKey . "sources" }}
118
92
sources:
119
- {{- range $source := .sources }}
120
- # indentation matters so collapse to single line with toJson to keep it
121
- - {{ $source | toJson }}
93
+ {{- range $source := .sources }}
94
+ {{- if hasKey $source "ref" }}
95
+ - ref: {{ $source.ref }}
96
+ {{- if eq $source.ref "understack" }}
97
+ repoURL: {{ $root.values.understack_url }}
98
+ targetRevision: {{ $root.values.understack_ref }}
99
+ {{- else if eq $source.ref "deploy" }}
100
+ repoURL: {{ $root.values.deploy_url }}
101
+ targetRevision: {{ $root.values.deploy_ref }}
102
+ {{- end }}
103
+ {{- else }}
104
+ - repoURL: {{ $source.repoURL }}
105
+ targetRevision: {{ $source.targetRevision }}
106
+ {{- end }}
107
+ {{- if hasKey $source "chart" }}
108
+ chart: {{ $source.chart }}
109
+ {{- end }}
110
+ {{- if hasKey $source "helm" }}
111
+ helm:
112
+ {{- if hasKey $source "chart" }}
113
+ releaseName: {{ $source.chart }}
114
+ {{- end }}
115
+ {{- if hasKey $source.helm "valueFiles" }}
116
+ valueFiles:
117
+ {{- range $vf := $source.helm.valueFiles }}
118
+ # until dynamic parameters exist this must be done
119
+ - {{ $vf | replace "{{.name}}" $root.name }}
120
+ {{- end }}
121
+ ignoreMissingValueFiles: true
122
+ {{- end }}
123
+ {{- if hasKey $source.helm "fileParameters" }}
124
+ fileParameters:
125
+ {{- range $fp := $source.helm.fileParameters }}
126
+ # until dynamic parameters exist this must be done
127
+ - name: {{ $fp.name }}
128
+ path: {{ $fp.path | replace "{{.name}}" $root.name }}
129
+ {{- end }}
130
+ {{- end }}
131
+ {{- if hasKey $source.helm "valuesObject" }}
132
+ valuesObject: {{ $source.helm.valuesObject | toJson }}
133
+ # indentation matters so collapse to single line with toJson to keep it
134
+ {{- end }}
135
+ {{- end }}
136
+ {{- if hasKey $source "kustomize" }}
137
+ kustomize: {{ $source.kustomize | toJson }}
138
+ {{- end }}
139
+ {{- if hasKey $source "path" }}
140
+ path: {{ $source.path | replace "{{.name}}" $root.name }}
141
+ {{- end }}
142
+ {{- end }}
122
143
{{- end }}
123
- {{- if hasKey . "ignoreDifferences" }}
144
+ {{- if hasKey . "ignoreDifferences" }}
124
145
# indentation matters so collapse to single line with toJson to keep it
125
146
ignoreDifferences: {{ .ignoreDifferences | toJson }}
126
- {{- end }}
147
+ {{- end }}
0 commit comments