-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcomposition.yaml
325 lines (308 loc) · 14.1 KB
/
composition.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: xargo.gitops.platform.upbound.io
labels:
type: gitops
spec:
writeConnectionSecretsToNamespace: upbound-system
compositeTypeRef:
apiVersion: gitops.platform.upbound.io/v1alpha1
kind: XArgo
mode: Pipeline
pipeline:
- step: patch-and-transform
functionRef:
name: crossplane-contrib-function-patch-and-transform
input:
apiVersion: pt.fn.crossplane.io/v1beta1
kind: Resources
patchSets:
- name: Common
patches:
- type: FromCompositeFieldPath
fromFieldPath: metadata.labels
toFieldPath: metadata.labels
- type: FromCompositeFieldPath
fromFieldPath: metadata.annotations
toFieldPath: metadata.annotations
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.providerConfigName
toFieldPath: spec.providerConfigRef.name
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.deletionPolicy
toFieldPath: spec.deletionPolicy
resources:
- name: releaseArgo
base:
apiVersion: helm.crossplane.io/v1beta1
kind: Release
spec:
forProvider:
chart:
name: argo-cd
repository: https://argoproj.github.io/argo-helm
namespace: argocd
values:
applicationSet:
metrics:
enabled: true
service:
annotations:
prometheus.io/scrape: true
replicaCount: 1
configs:
cm:
application.resourceTrackingMethod: annotation
resource.customizations: |
"*.upbound.io/*":
health.lua: |
health_status = {
status = "Progressing",
message = "Provisioning ..."
}
local function contains (table, val)
for i, v in ipairs(table) do
if v == val then
return true
end
end
return false
end
local has_no_status = {
"ProviderConfig",
"ProviderConfigUsage"
}
if obj.status == nil and contains(has_no_status, obj.kind) then
health_status.status = "Healthy"
health_status.message = "Resource is up-to-date."
return health_status
end
if obj.status == nil or obj.status.conditions == nil then
if obj.kind == "ProviderConfig" and obj.status.users ~= nil then
health_status.status = "Healthy"
health_status.message = "Resource is in use."
return health_status
end
return health_status
end
for i, condition in ipairs(obj.status.conditions) do
if condition.type == "LastAsyncOperation" then
if condition.status == "False" then
health_status.status = "Degraded"
health_status.message = condition.message
return health_status
end
end
if condition.type == "Synced" then
if condition.status == "False" then
health_status.status = "Degraded"
health_status.message = condition.message
return health_status
end
end
if condition.type == "Ready" then
if condition.status == "True" then
health_status.status = "Healthy"
health_status.message = "Resource is up-to-date."
return health_status
end
end
end
return health_status
"*.crossplane.io/*":
health.lua: |
health_status = {
status = "Progressing",
message = "Provisioning ..."
}
local function contains (table, val)
for i, v in ipairs(table) do
if v == val then
return true
end
end
return false
end
local has_no_status = {
"Composition",
"CompositionRevision",
"DeploymentRuntimeConfig",
"ControllerConfig"
}
if obj.status == nil and contains(has_no_status, obj.kind) then
health_status.status = "Healthy"
health_status.message = "Resource is up-to-date."
return health_status
end
if obj.status == nil or obj.status.conditions == nil then
return health_status
end
for i, condition in ipairs(obj.status.conditions) do
if condition.type == "LastAsyncOperation" then
if condition.status == "False" then
health_status.status = "Degraded"
health_status.message = condition.message
return health_status
end
end
if condition.type == "Synced" then
if condition.status == "False" then
health_status.status = "Degraded"
health_status.message = condition.message
return health_status
end
end
if contains({"Ready", "Healthy", "Offered", "Established"}, condition.type) then
if condition.status == "True" then
health_status.status = "Healthy"
health_status.message = "Resource is up-to-date."
return health_status
end
end
end
return health_status
params:
application.namespaces: cluster-*
controller:
env:
- name: ARGOCD_K8S_CLIENT_QPS
value: "300"
metrics:
enabled: true
service:
annotations:
prometheus.io/scrape: true
replicas: 1
dex:
enabled: false
redis-ha:
enabled: true
repoServer:
autoscaling:
enabled: true
minReplicas: 1
metrics:
enabled: true
service:
annotations:
prometheus.io/scrape: true
resources:
limits:
cpu: 200m
memory: 512Mi
requests:
cpu: 100m
memory: 256Mi
server:
autoscaling:
enabled: true
minReplicas: 1
ingress:
enabled: true
metrics:
enabled: true
service:
annotations:
prometheus.io/scrape: true
resources:
limits:
cpu: 200m
memory: 512Mi
requests:
cpu: 100m
memory: 256Mi
patches:
- type: PatchSet
patchSetName: Common
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.ingressUrl
toFieldPath: spec.forProvider.values.global.domain
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.ingressUrl
toFieldPath: spec.forProvider.values.server.url
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.ingressUrl
toFieldPath: spec.forProvider.values.configs.cm.url
transforms:
- string:
fmt: 'https://%s'
type: Format
type: string
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.oidcConfig
toFieldPath: spec.forProvider.values.server.config[oidc.config]
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.resourceInclusions
toFieldPath: spec.forProvider.values.configs.cm[resource.inclusions]
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.resourceExclusions
toFieldPath: spec.forProvider.values.configs.cm[resource.exclusions]
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.operators.argocd.version
toFieldPath: spec.forProvider.chart.version
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.providerConfigName
toFieldPath: metadata.annotations[crossplane.io/external-name]
transforms:
- match:
fallbackValue: null
patterns:
- regexp: .*
result: argocd
type: regexp
type: match
- name: argoApplicationSet
base:
apiVersion: kubernetes.crossplane.io/v1alpha2
kind: Object
spec:
forProvider:
manifest:
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
namespace: argocd
spec:
generators:
- matrix:
generators:
- git: {}
- list:
elements: []
elementsYaml: '{{ .key.components | toJson }}'
goTemplate: true
goTemplateOptions:
- missingkey=error
template:
metadata:
name: '{{.name}}'
spec:
destination:
namespace: '{{.namespace}}'
server: '{{.server}}'
project: '{{.project}}'
source:
repoURL: '{{.repoUrl}}'
targetRevision: '{{.version}}'
path: '{{.folder}}'
syncPolicy:
automated:
selfHeal: true
syncOptions:
- CreateNamespace=true
patches:
- type: PatchSet
patchSetName: Common
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.providerConfigName
toFieldPath: spec.forProvider.manifest.metadata.name
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.source.git.url
toFieldPath: spec.forProvider.manifest.spec.generators[0].matrix.generators[0].git.repoURL
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.source.git.path
toFieldPath: spec.forProvider.manifest.spec.generators[0].matrix.generators[0].git.files[0].path
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.source.git.ref.name
toFieldPath: spec.forProvider.manifest.spec.generators[0].matrix.generators[0].git.revision