Skip to content

Commit 52df71c

Browse files
jianrongzhang89tchughesiv
authored andcommitted
Update operator to use OpenShift Database Access v1beta1 API
1 parent c7f495c commit 52df71c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2363
-794
lines changed

PROJECT

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ resources:
2323
group: dbaas
2424
kind: MongoDBAtlasConnection
2525
path: github.com/mongodb/mongodb-atlas-kubernetes/pkg/api/dbaas
26-
version: v1alpha1
26+
version: v1beta1
2727
- api:
2828
crdVersion: v1
2929
namespaced: true
@@ -32,7 +32,7 @@ resources:
3232
group: dbaas
3333
kind: MongoDBAtlasInventory
3434
path: github.com/mongodb/mongodb-atlas-kubernetes/pkg/api/dbaas
35-
version: v1alpha1
35+
version: v1beta1
3636
- api:
3737
crdVersion: v1
3838
namespaced: true
@@ -41,7 +41,7 @@ resources:
4141
group: dbaas
4242
kind: MongoDBAtlasInstance
4343
path: github.com/mongodb/mongodb-atlas-kubernetes/pkg/api/dbaas
44-
version: v1alpha1
44+
version: v1beta1
4545
- api:
4646
crdVersion: v1
4747
namespaced: true

README.md

+86-90
Original file line numberDiff line numberDiff line change
@@ -153,60 +153,25 @@ Operator support Third Party Integration.
153153

154154
### Step 4. Test Database as a Service (DBaaS) on OpenShift
155155

156-
The Atlas Operator is integrated with the [Red Hat Database-as-a-Service (DBaaS) Operator](https://github.com/RHEcosystemAppEng/dbaas-operator) which allows application developers to import database instances and connect to the databases through the [Service Binding Operator](https://github.com/redhat-developer/service-binding-operator). More information can be found [here](https://github.com/RHEcosystemAppEng/dbaas-operator#readme).
157-
158-
Note that both the DBaaS Operator and Atlas Operator should be installed through the [Operator Lifecyle Manager (OLM)](https://github.com/operator-framework/operator-lifecycle-manager).
156+
The Atlas Operator is integrated with the [OpenShift Database Access Operator, a.k.a. Database-as-a-Service (DBaaS) Operator](https://github.com/RHEcosystemAppEng/dbaas-operator) which allows application developers to import database instances and connect to the databases through the [Service Binding Operator](https://github.com/redhat-developer/service-binding-operator). More information can be found [here](https://github.com/RHEcosystemAppEng/dbaas-operator#readme).
159157

160158
**1.** Check DBaaS Registration
161159

162-
If the DBaaS Operator has been deployed in the OpenShift Cluster, the Atlas Operator automatically creates a cluster level [DBaaSProvider](https://github.com/RHEcosystemAppEng/dbaas-operator/blob/main/config/crd/bases/dbaas.redhat.com_dbaasproviders.yaml) custom resource (CR) object `mongodb-atlas-registration` to automatically register itself with the DBaaS Operator.
163-
164-
```
165-
apiVersion: dbaas.redhat.com/v1alpha1
166-
kind: DBaaSProvider
167-
metadata:
168-
labels:
169-
related-to: dbaas-operator
170-
type: dbaas-provider-registration
171-
name: mongodb-atlas-registration
172-
spec:
173-
connectionKind: MongoDBAtlasConnection
174-
credentialFields:
175-
- displayName: Organization ID
176-
key: orgId
177-
required: true
178-
type: string
179-
- displayName: Public API Key
180-
key: publicApiKey
181-
required: true
182-
type: string
183-
- displayName: Private API Key
184-
key: privateApiKey
185-
required: true
186-
type: maskedstring
187-
inventoryKind: MongoDBAtlasInventory
188-
provider:
189-
displayDescription: Cloud-hosted MongoDB service on AWS, Azure and Google Cloud
190-
displayName: MongoDB Atlas Cloud Database Service
191-
icon:
192-
base64data: <icon image data>
193-
mediatype: image/png
194-
name: Red Hat DBaaS / MongoDB Atlas
195-
```
160+
If the DBaaS Operator has been deployed in the OpenShift Cluster, the Atlas Operator automatically creates a cluster level [DBaaSProvider](https://github.com/RHEcosystemAppEng/dbaas-operator/blob/main/config/crd/bases/dbaas.redhat.com_dbaasproviders.yaml) custom resource (CR) object `mongodb-atlas-registration` to automatically register itself with the DBaaS Operator. See file `config/dbaasprovider/dbaas_provider.yaml` for the content of the registration CR.
196161
If the Atlas Operator is undeployed with the OLM, the above registration CR gets cleaned up automatically.
197162

198163
**2.** Check MongoDBAtlasInventory Custom Resource
199164

200-
First an administrator creates a [DBaaSInventory](https://github.com/RHEcosystemAppEng/dbaas-operator/blob/main/config/crd/bases/dbaas.redhat.com_dbaasinventories.yaml) CR for MongoDB. The DBaaS Operator automatically creates a MongoDBAtlasInventory CR, and the Atlas Operator discovers the clusters and instances, and sets the result in the CR status.
165+
First an administrator imports a provider account by creating a [DBaaSInventory](https://github.com/RHEcosystemAppEng/dbaas-operator/blob/main/config/crd/bases/dbaas.redhat.com_dbaasinventories.yaml) CR for MongoDB. The DBaaS Operator automatically creates a MongoDBAtlasInventory CR, and the Atlas Operator discovers the clusters and instances, and sets the result in the CR status.
201166
Here is an example of MongoDBAtlasInventory CR.
202167
```
203-
apiVersion: dbaas.redhat.com/v1alpha1
168+
apiVersion: dbaas.redhat.com/v1beta1
204169
kind: MongoDBAtlasInventory
205170
metadata:
206171
name: dbaas-mytest
207172
namespace: openshift-operators
208173
ownerReferences:
209-
- apiVersion: dbaas.redhat.com/v1alpha1
174+
- apiVersion: dbaas.redhat.com/v1beta1
210175
blockOwnerDeletion: true
211176
controller: true
212177
kind: DBaaSInventory
@@ -218,75 +183,106 @@ spec:
218183
namespace: openshift-operators
219184
status:
220185
conditions:
221-
- lastTransitionTime: "2021-08-18T20:06:47Z"
222-
message: Spec sync OK
223-
reason: SyncOK
186+
- lastTransitionTime: "2023-03-28T16:41:55Z"
187+
message: Spec sync OK
188+
reason: SyncOK
189+
status: "True"
190+
type: SpecSynced
191+
databaseServices:
192+
- serviceID: 62c2c8a362b69c2cddfd7092
193+
serviceInfo:
194+
connectionStringsStandardSrv: mongodb+srv://test-cluster-1.uokag.mongodb.net
195+
instanceSizeName: M0
196+
projectID: 62c2c89d1072f947cc60b38a
197+
projectName: testproject1
198+
providerName: AWS
199+
regionName: US_EAST_1
200+
state: Ready
201+
serviceName: test-cluster-1
202+
- serviceID: 630db3bc7d0eac3a77881c9b
203+
serviceInfo:
204+
connectionStringsStandardSrv: mongodb+srv://test-cluster-2.vrfxrzl.mongodb.net
205+
instanceSizeName: M0
206+
projectID: 630db3b67d0eac3a77881c0e
207+
projectName: testproject2
208+
providerName: AWS
209+
regionName: US_EAST_1
210+
state: Ready
211+
serviceName: test-cluster-2
212+
```
213+
**3.** Provision a MongoDB Atlas Deployment
214+
The administrator or developer can then optionally provision an Atlas Deployment by creating a [DBaaSInstance](https://github.com/RHEcosystemAppEng/dbaas-operator/blob/main/config/crd/bases/dbaas.redhat.com_dbaasinstances.yaml) CR. The DBaaS Operator automatically creates a MongoDBAtlasInstance CR, and the Atlas Operator provisions the Atlas Deployment and sets the result in the CR status.
215+
216+
Here is an example of MongoDBAtlasInstance CR.
217+
```
218+
apiVersion: dbaas.redhat.com/v1beta1
219+
kind: MongoDBAtlasInstance
220+
metadata:
221+
creationTimestamp: "2023-03-28T15:46:29Z"
222+
generation: 1
223+
name: dbaas-mytest
224+
namespace: openshift-dbaas-operator
225+
ownerReferences:
226+
- apiVersion: dbaas.redhat.com/v1beta1
227+
blockOwnerDeletion: true
228+
controller: true
229+
kind: DBaaSInstance
230+
name: dbaas-mytest
231+
uid: fe931f44-bb2c-4e8b-8bab-e5174346eb09
232+
resourceVersion: "447263"
233+
uid: 291acf9d-3fa9-4ee5-823f-425e9fa31c87
234+
spec:
235+
inventoryRef:
236+
name: dbaas-mytest
237+
namespace: openshift-dbaas-operator
238+
provisioningParameters:
239+
cloudProvider: AWS
240+
name: mytestinstance
241+
plan: FREETRIAL
242+
teamProject: mytestproject
243+
status:
244+
conditions:
245+
- lastTransitionTime: "2023-03-28T17:14:56Z"
246+
message: ""
247+
reason: Ready
224248
status: "True"
225-
type: SpecSynced
226-
instances:
227-
- instanceID: 608df625aa94426b4169999
228-
instanceInfo:
229-
dbaas-cluster1.a00aa.Srv: mongodb+srv://dbaas-cluster1.a00aa.mongodb.net
230-
instanceSizeName: M0
231-
projectID: 608df5e652e1944293e11111
232-
projectName: Project 1
233-
providerName: TENANT
234-
regionName: US_EAST_1
235-
name: DBaaS-Cluster1
236-
- instanceID: 60807282b4ab8d3b3c123456
237-
instanceInfo:
238-
dbaas-cluster1.a00aa.Srv: mongodb+srv://test123.edbca.mongodb.net
239-
instanceSizeName: M10
240-
projectID: 6065e15b16c0731bf3a12333
241-
projectName: Project 2
242-
providerName: AWS
243-
regionName: US_EAST_1
244-
name: test
245-
- instanceID: 12345ffbc9a90e310e642482
246-
instanceInfo:
247-
dbaas-cluster1.a00aa.Srv: mongodb+srv://testcluster1.edbca.mongodb.net
248-
instanceSizeName: M0
249-
projectID: 6065e15b16c0731bf3a12333
250-
projectName: Project 2
251-
providerName: TENANT
252-
regionName: US_EAST_1
253-
name: DBCreatedInAtalas
254-
- instanceID: 60b7a72f4877d05881234567
255-
instanceInfo:
256-
dbaas-cluster1.a00aa.Srv: mongodb+srv://test.abcd9.mongodb.net
257-
instanceSizeName: M10
258-
projectID: 60b798fea37f9f09acc12345
259-
projectName: mytest
260-
providerName: AWS
261-
regionName: US_EAST_1
262-
name: test
249+
type: ProvisionReady
250+
instanceID: 64231ff384042d1c6822f55e
251+
instanceInfo:
252+
connectionStringsStandardSrv: mongodb+srv://mytestinstance.uuvk4lr.mongodb.net
253+
instanceSizeName: M0
254+
projectID: 64231fe609d3af11d356962d
255+
projectName: mytestproject
256+
providerName: AWS
257+
regionName: US_EAST_1
258+
phase: Ready
263259
```
264-
**3.** Check MongoDBAtlasConnection Custom Resource
260+
**4.** Check MongoDBAtlasConnection Custom Resource
265261

266-
Now the application developer can create a [DBaaSConnection](https://github.com/RHEcosystemAppEng/dbaas-operator/blob/main/config/crd/bases/dbaas.redhat.com_dbaasconnections.yaml) CR for connection to the MongoDB database instance found, the DBaaS Operator automatically creates a MongoDBAtlasConnection CR. The Atlas Operator creates a database user in Atlas for the cluster with the default database `admin`. The Atlas Operator stores the db user credentials in a kubernetes secret, and the remaining connection information in a configmap, and then updates the MongoDBAtlasConnection CR status.
262+
Now the application developer can create a [DBaaSConnection](https://github.com/RHEcosystemAppEng/dbaas-operator/blob/main/config/crd/bases/dbaas.redhat.com_dbaasconnections.yaml) CR for connection to the MongoDB database instance found, the DBaaS Operator automatically creates a MongoDBAtlasConnection CR. The Atlas Operator creates a database user in Atlas for the cluster with the default database `admin`. The Atlas Operator stores the db user credentials in a kubernetes secret, and the remaining connection information in a configmap and then updates the MongoDBAtlasConnection CR status.
267263

268264
Here is an example of MongoDBAtlasConnection CR.
269265
```
270-
apiVersion: dbaas.redhat.com/v1alpha1
266+
apiVersion: dbaas.redhat.com/v1beta1
271267
kind: MongoDBAtlasConnection
272268
metadata:
273269
name: test-dbaas-connection
274270
namespace: test-namespace
275271
ownerReferences:
276-
- apiVersion: dbaas.redhat.com/v1alpha1
272+
- apiVersion: dbaas.redhat.com/v1beta1
277273
blockOwnerDeletion: true
278274
controller: true
279275
kind: DBaaSConnection
280276
name: test-dbaas-connection
281277
uid: 77193619-6ab1-43c9-acf2-a40c2cfe7703
282278
spec:
283-
instanceID: 12345ffbc9a90e310e642482
279+
databaseServiceID: 12345ffbc9a90e310e642482
284280
inventoryRef:
285281
name: dbaas-mytest
286282
namespace: openshift-operators
287283
status:
288284
conditions:
289-
- lastTransitionTime: "2021-08-18T20:07:51Z"
285+
- lastTransitionTime: "2023-03-28T20:06:56Z"
290286
message: ""
291287
reason: Ready
292288
status: "True"
@@ -312,7 +308,7 @@ metadata:
312308
name: atlas-db-user-5pc8b
313309
namespace: test-namespace
314310
ownerReferences:
315-
- apiVersion: dbaas.redhat.com/v1alpha1
311+
- apiVersion: dbaas.redhat.com/v1beta1
316312
blockOwnerDeletion: false
317313
controller: true
318314
kind: MongoDBAtlasConnection
@@ -325,7 +321,7 @@ The corresponding generated configmap:
325321
apiVersion: v1
326322
data:
327323
host: cluster0.ubajs.mongodb.net
328-
provider: Red Hat DBaaS / MongoDB Atlas
324+
provider: OpenShift Datase Access / MongoDB Atlas
329325
srv: "true"
330326
type: mongodb
331327
kind: ConfigMap
@@ -338,7 +334,7 @@ metadata:
338334
name: atlas-connection-cm-knp9z
339335
namespace: test-namespace
340336
ownerReferences:
341-
- apiVersion: dbaas.redhat.com/v1alpha1
337+
- apiVersion: dbaas.redhat.com/v1beta1
342338
blockOwnerDeletion: false
343339
controller: true
344340
kind: MongoDBAtlasConnection

bundle/manifests/dbaas.redhat.com_mongodbatlasconnections.yaml

+35-14
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ spec:
1818
singular: mongodbatlasconnection
1919
scope: Namespaced
2020
versions:
21-
- name: v1alpha1
21+
- name: v1beta1
2222
schema:
2323
openAPIV3Schema:
2424
description: MongoDBAtlasConnection is the Schema for the MongoDBAtlasConnections
@@ -37,30 +37,51 @@ spec:
3737
metadata:
3838
type: object
3939
spec:
40-
description: DBaaSConnectionSpec defines the desired state of DBaaSConnection
40+
description: DBaaSConnectionSpec defines the desired state of a DBaaSConnection
41+
object.
4142
properties:
42-
instanceID:
43-
description: The ID of the instance to connect to, as seen in the
44-
Status of the referenced DBaaSInventory
43+
databaseServiceID:
44+
description: The ID of the database service to connect to, as seen
45+
in the status of the referenced DBaaSInventory.
46+
type: string
47+
databaseServiceRef:
48+
description: A reference to the database service CR used, if the DatabaseServiceID
49+
is not specified.
50+
properties:
51+
name:
52+
description: The name for object of a known type.
53+
type: string
54+
namespace:
55+
description: The namespace where an object of a known type is
56+
stored.
57+
type: string
58+
required:
59+
- name
60+
type: object
61+
databaseServiceType:
62+
description: The type of the database service to connect to, as seen
63+
in the status of the referenced DBaaSInventory.
4564
type: string
4665
inventoryRef:
47-
description: A reference to the relevant DBaaSInventory CR
66+
description: A reference to the relevant DBaaSInventory custom resource
67+
(CR).
4868
properties:
4969
name:
50-
description: The name for object of known type
70+
description: The name for object of a known type.
5171
type: string
5272
namespace:
53-
description: The namespace where object of known type is stored
73+
description: The namespace where an object of a known type is
74+
stored.
5475
type: string
5576
required:
5677
- name
5778
type: object
5879
required:
59-
- instanceID
6080
- inventoryRef
6181
type: object
6282
status:
63-
description: DBaaSConnectionStatus defines the observed state of DBaaSConnection
83+
description: DBaaSConnectionStatus defines the observed state of a DBaaSConnection
84+
object.
6485
properties:
6586
conditions:
6687
items:
@@ -131,8 +152,8 @@ spec:
131152
type: object
132153
type: array
133154
connectionInfoRef:
134-
description: A ConfigMap holding non-sensitive information needed
135-
for connecting to the DB instance
155+
description: A ConfigMap object holding non-sensitive information
156+
for connecting to the database instance.
136157
properties:
137158
name:
138159
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
@@ -141,8 +162,8 @@ spec:
141162
type: object
142163
x-kubernetes-map-type: atomic
143164
credentialsRef:
144-
description: Secret holding the credentials needed for accessing the
145-
DB instance
165+
description: The secret holding account credentials for accessing
166+
the database instance.
146167
properties:
147168
name:
148169
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

0 commit comments

Comments
 (0)