-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcomposition.yaml
360 lines (353 loc) · 14.3 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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: xgke.gcp.platform.upbound.io
labels:
provider: gcp
spec:
writeConnectionSecretsToNamespace: upbound-system
compositeTypeRef:
apiVersion: gcp.platform.upbound.io/v1alpha1
kind: XGKE
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: providerConfigRef
patches:
- fromFieldPath: spec.parameters.providerConfigName
toFieldPath: spec.providerConfigRef.name
type: FromCompositeFieldPath
- name: deletionPolicy
patches:
- fromFieldPath: spec.parameters.deletionPolicy
toFieldPath: spec.deletionPolicy
type: FromCompositeFieldPath
- name: region
patches:
- fromFieldPath: spec.parameters.region
toFieldPath: spec.forProvider.location
type: FromCompositeFieldPath
resources:
- name: serviceaccount
base:
apiVersion: cloudplatform.gcp.upbound.io/v1beta1
kind: ServiceAccount
patches:
- type: PatchSet
patchSetName: providerConfigRef
- type: PatchSet
patchSetName: deletionPolicy
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.id
toFieldPath: metadata.annotations[crossplane.io/external-name]
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.id
toFieldPath: spec.forProvider.displayName
- type: ToCompositeFieldPath
fromFieldPath: status.atProvider.email
toFieldPath: status.gke.serviceAccount
- type: ToCompositeFieldPath
fromFieldPath: status.atProvider.id
toFieldPath: status.gke.project
transforms:
- type: string
string:
regexp:
group: 1
match: projects\/(.+)\/serviceAccounts\/.*
type: Regexp
- name: serviceaccountkey
base:
apiVersion: cloudplatform.gcp.upbound.io/v1beta1
kind: ServiceAccountKey
spec:
forProvider:
serviceAccountIdSelector:
matchControllerRef: true
patches:
- type: PatchSet
patchSetName: providerConfigRef
- type: PatchSet
patchSetName: deletionPolicy
- type: FromCompositeFieldPath
fromFieldPath: metadata.uid
toFieldPath: spec.writeConnectionSecretToRef.name
transforms:
- type: string
string:
fmt: '%s-sakey'
type: Format
- type: FromCompositeFieldPath
fromFieldPath: spec.writeConnectionSecretToRef.namespace
toFieldPath: spec.writeConnectionSecretToRef.namespace
- name: projectiammember
base:
apiVersion: cloudplatform.gcp.upbound.io/v1beta1
kind: ProjectIAMMember
spec:
forProvider:
role: roles/container.admin
patches:
- type: PatchSet
patchSetName: providerConfigRef
- type: PatchSet
patchSetName: deletionPolicy
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.id
toFieldPath: metadata.annotations[crossplane.io/external-name]
- type: FromCompositeFieldPath
fromFieldPath: status.gke.serviceAccount
toFieldPath: spec.forProvider.member
policy:
fromFieldPath: Required
transforms:
- type: string
string:
fmt: serviceAccount:%s
type: Format
- type: FromCompositeFieldPath
fromFieldPath: status.gke.project
toFieldPath: spec.forProvider.project
policy:
fromFieldPath: Required
- name: gkecluster
base:
apiVersion: container.gcp.upbound.io/v1beta1
kind: Cluster
spec:
forProvider:
deletionProtection: false
enableIntranodeVisibility: true
initialNodeCount: 1
ipAllocationPolicy:
- clusterSecondaryRangeName: pods
servicesSecondaryRangeName: services
loggingService: logging.googleapis.com/kubernetes
monitoringService: monitoring.googleapis.com/kubernetes
connectionDetails:
- fromConnectionSecretKey: kubeconfig
name: kubeconfig
type: FromConnectionSecretKey
patches:
- type: PatchSet
patchSetName: providerConfigRef
- type: PatchSet
patchSetName: deletionPolicy
- type: PatchSet
patchSetName: region
- type: FromCompositeFieldPath
fromFieldPath: metadata.uid
toFieldPath: spec.writeConnectionSecretToRef.name
transforms:
- type: string
string:
fmt: '%s-gkecluster'
type: Format
- type: FromCompositeFieldPath
fromFieldPath: spec.writeConnectionSecretToRef.namespace
toFieldPath: spec.writeConnectionSecretToRef.namespace
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.id
toFieldPath: spec.forProvider.networkSelector.matchLabels[networks.gcp.platform.upbound.io/network-id]
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.id
toFieldPath: spec.forProvider.subnetworkSelector.matchLabels[networks.gcp.platform.upbound.io/network-id]
- type: FromCompositeFieldPath
fromFieldPath: status.gke.serviceAccount
toFieldPath: spec.forProvider.nodeConfig[0].serviceAccount
policy:
fromFieldPath: Required
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.version
toFieldPath: spec.forProvider.nodeVersion
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.version
toFieldPath: spec.forProvider.minMasterVersion
- fromFieldPath: status.atProvider.project
toFieldPath: status.gke.project
type: ToCompositeFieldPath
- fromFieldPath: status.gke.project
toFieldPath: spec.forProvider.workloadIdentityConfig[0].workloadPool
type: FromCompositeFieldPath
transforms:
- type: string
string:
fmt: '%s.svc.id.goog'
type: Format
- name: node-pool
base:
apiVersion: container.gcp.upbound.io/v1beta1
kind: NodePool
spec:
forProvider:
autoscaling:
- maxNodeCount: 1
minNodeCount: 1
clusterSelector:
matchControllerRef: true
initialNodeCount: 1
management:
- autoRepair: true
autoUpgrade: true
maxPodsPerNode: 55
nodeConfig:
- diskSizeGb: 10
imageType: COS_CONTAINERD
machineType: e2-medium
metadata:
disable-legacy-endpoints: "true"
oauthScopes:
- https://www.googleapis.com/auth/cloud-platform
preemptible: true
shieldedInstanceConfig:
- enableIntegrityMonitoring: true
enableSecureBoot: true
patches:
- type: PatchSet
patchSetName: providerConfigRef
- type: PatchSet
patchSetName: deletionPolicy
- type: PatchSet
patchSetName: region
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.nodes.instanceType
toFieldPath: spec.forProvider.nodeConfig[0].machineType
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.nodes.count
toFieldPath: spec.forProvider.initialNodeCount
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.nodes.count
toFieldPath: spec.forProvider.autoscaling[0].minNodeCount
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.nodes.count
toFieldPath: spec.forProvider.autoscaling[0].maxNodeCount
- type: FromCompositeFieldPath
fromFieldPath: status.gke.serviceAccount
toFieldPath: spec.forProvider.nodeConfig[0].serviceAccount
policy:
fromFieldPath: Required
- name: providerConfigHelm
base:
apiVersion: helm.crossplane.io/v1beta1
kind: ProviderConfig
spec:
credentials:
secretRef:
key: kubeconfig
source: Secret
identity:
secretRef:
key: private_key
source: Secret
type: GoogleApplicationCredentials
patches:
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.id
toFieldPath: metadata.name
- type: FromCompositeFieldPath
fromFieldPath: spec.writeConnectionSecretToRef.namespace
toFieldPath: spec.credentials.secretRef.namespace
- type: FromCompositeFieldPath
fromFieldPath: metadata.uid
toFieldPath: spec.credentials.secretRef.name
transforms:
- type: string
string:
fmt: '%s-gkecluster'
type: Format
- type: FromCompositeFieldPath
fromFieldPath: spec.writeConnectionSecretToRef.namespace
toFieldPath: spec.identity.secretRef.namespace
- type: FromCompositeFieldPath
fromFieldPath: metadata.uid
toFieldPath: spec.identity.secretRef.name
transforms:
- type: string
string:
fmt: '%s-sakey'
type: Format
readinessChecks:
- type: None
- name: providerConfigKubernetes
base:
apiVersion: kubernetes.crossplane.io/v1alpha1
kind: ProviderConfig
spec:
credentials:
secretRef:
key: kubeconfig
source: Secret
identity:
secretRef:
key: private_key
source: Secret
type: GoogleApplicationCredentials
patches:
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.id
toFieldPath: metadata.name
- type: FromCompositeFieldPath
fromFieldPath: spec.writeConnectionSecretToRef.namespace
toFieldPath: spec.credentials.secretRef.namespace
- type: FromCompositeFieldPath
fromFieldPath: metadata.uid
toFieldPath: spec.credentials.secretRef.name
transforms:
- type: string
string:
fmt: '%s-gkecluster'
type: Format
- type: FromCompositeFieldPath
fromFieldPath: spec.writeConnectionSecretToRef.namespace
toFieldPath: spec.identity.secretRef.namespace
- type: FromCompositeFieldPath
fromFieldPath: metadata.uid
toFieldPath: spec.identity.secretRef.name
transforms:
- type: string
string:
fmt: '%s-sakey'
type: Format
readinessChecks:
- type: None
- name: workloadIdentitySettings
base:
apiVersion: kubernetes.crossplane.io/v1alpha2
kind: Object
spec:
deletionPolicy: Orphan
forProvider:
manifest:
apiVersion: v1
kind: ConfigMap
metadata:
namespace: default
patches:
- fromFieldPath: spec.parameters.id
toFieldPath: spec.providerConfigRef.name
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.id
toFieldPath: metadata.name
transforms:
- string:
fmt: '%s-workload-identity-settings'
type: Format
type: string
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.id
toFieldPath: spec.forProvider.manifest.metadata.name
transforms:
- string:
fmt: '%s-workload-identity-settings'
type: Format
type: string
type: FromCompositeFieldPath
- fromFieldPath: status.gke.project
toFieldPath: spec.forProvider.manifest.data.gkeProject
type: FromCompositeFieldPath