-
Notifications
You must be signed in to change notification settings - Fork 2
/
composition.yaml
193 lines (193 loc) · 7.74 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
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: xsqlinstances.gcp.platform.upbound.io
labels:
provider: gcp
spec:
writeConnectionSecretsToNamespace: upbound-system
compositeTypeRef:
apiVersion: gcp.platform.upbound.io/v1alpha1
kind: XSQLInstance
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.region
type: FromCompositeFieldPath
resources:
- name: PrivateIPAddress
base:
apiVersion: compute.gcp.upbound.io/v1beta1
kind: GlobalAddress
spec:
forProvider:
addressType: INTERNAL
prefixLength: 16
purpose: VPC_PEERING
patches:
- type: PatchSet
patchSetName: providerConfigRef
- type: PatchSet
patchSetName: deletionPolicy
- fromFieldPath: spec.parameters.networkRef.id
toFieldPath: spec.forProvider.networkSelector.matchLabels[networks.gcp.platform.upbound.io/network-id]
- name: PrivateConnection
base:
apiVersion: servicenetworking.gcp.upbound.io/v1beta1
kind: Connection
spec:
forProvider:
reservedPeeringRangesSelector:
matchControllerRef: true
service: servicenetworking.googleapis.com
patches:
- type: PatchSet
patchSetName: providerConfigRef
- type: PatchSet
patchSetName: deletionPolicy
- fromFieldPath: spec.parameters.networkRef.id
toFieldPath: spec.forProvider.networkSelector.matchLabels[networks.gcp.platform.upbound.io/network-id]
- name: DatabaseUser
base:
apiVersion: sql.gcp.upbound.io/v1beta1
kind: User
spec:
forProvider:
instanceSelector:
matchControllerRef: true
patches:
- type: PatchSet
patchSetName: providerConfigRef
- type: PatchSet
patchSetName: deletionPolicy
- fromFieldPath: spec.parameters.passwordSecretRef.namespace
toFieldPath: spec.forProvider.passwordSecretRef.namespace
- fromFieldPath: spec.parameters.passwordSecretRef.name
toFieldPath: spec.forProvider.passwordSecretRef.name
- fromFieldPath: spec.parameters.passwordSecretRef.key
toFieldPath: spec.forProvider.passwordSecretRef.key
- type: CombineFromComposite
combine:
variables:
- fromFieldPath: spec.parameters.engine
- fromFieldPath: metadata.uid
strategy: string
string:
fmt: "%suser-%.8s" # mysql has a limit of 32 chars for users thus we need to limit the length
toFieldPath: metadata.annotations[crossplane.io/external-name]
- type: CombineFromComposite
combine:
variables:
- fromFieldPath: metadata.uid
- fromFieldPath: spec.parameters.engine
strategy: string
string:
fmt: "%s-gcp-%s-user"
toFieldPath: spec.writeConnectionSecretToRef.name
- fromFieldPath: spec.writeConnectionSecretToRef.namespace
toFieldPath: spec.writeConnectionSecretToRef.namespace
connectionDetails:
- name: username
type: FromFieldPath
fromFieldPath: metadata.annotations[crossplane.io/external-name]
- name: password
type: FromConnectionSecretKey
fromConnectionSecretKey: attribute.password
- name: UpboundDatabase
base:
apiVersion: sql.gcp.upbound.io/v1beta1
kind: Database
spec:
forProvider:
instanceSelector:
matchControllerRef: true
patches:
- type: PatchSet
patchSetName: providerConfigRef
- type: PatchSet
patchSetName: deletionPolicy
- type: FromCompositeFieldPath
fromFieldPath: metadata.name
toFieldPath: metadata.annotations[crossplane.io/external-name]
transforms:
- type: match
match:
fallbackValue: null
patterns:
- regexp: .*
result: upbound
type: regexp
- name: DBInstance
base:
apiVersion: sql.gcp.upbound.io/v1beta1
kind: DatabaseInstance
spec:
forProvider:
deletionProtection: false
settings:
- diskSize: 20
tier: db-f1-micro
ipConfiguration:
- ipv4Enabled: false
patches:
- type: PatchSet
patchSetName: providerConfigRef
- type: PatchSet
patchSetName: deletionPolicy
- type: PatchSet
patchSetName: region
- type: CombineFromComposite
combine:
variables:
- fromFieldPath: metadata.uid
- fromFieldPath: spec.parameters.engine
strategy: string
string:
fmt: "%s-gcp-%s"
toFieldPath: spec.writeConnectionSecretToRef.name
- fromFieldPath: spec.writeConnectionSecretToRef.namespace
toFieldPath: spec.writeConnectionSecretToRef.namespace
- fromFieldPath: spec.parameters.storageGB
toFieldPath: spec.forProvider.settings[0].diskSize
- fromFieldPath: spec.parameters.networkRef.id
toFieldPath: spec.forProvider.settings[0].ipConfiguration[0].privateNetworkRef.name
- type: CombineFromComposite
combine:
variables:
- fromFieldPath: spec.parameters.engine
- fromFieldPath: spec.parameters.engineVersion
strategy: string
string:
fmt: "%s_%s"
toFieldPath: spec.forProvider.databaseVersion
transforms:
- type: string
string:
type: Convert
convert: "ToUpper"
connectionDetails:
- name: host
type: FromConnectionSecretKey
fromConnectionSecretKey: privateIP
- name: serverCACertificateCert
type: FromConnectionSecretKey
fromConnectionSecretKey: serverCACertificateCert