Skip to content

Commit ce506a8

Browse files
Jianrong Zhangtchughesiv
Jianrong Zhang
authored andcommitted
Integrate Atlas Operator with Openshift Database Access
1 parent ce9caba commit ce506a8

File tree

64 files changed

+9574
-401
lines changed

Some content is hidden

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

64 files changed

+9574
-401
lines changed

Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ WORKDIR /workspace
55
# Copy the Go Modules manifests
66
COPY go.mod go.mod
77
COPY go.sum go.sum
8+
# Copy DBaaSProvider config
9+
COPY config/dbaasprovider/dbaas_provider.yaml dbaas_provider.yaml
10+
811
# cache deps before building and copying source so that we don't need to re-download as much
912
# and so that source changes don't invalidate our downloaded layer
1013
RUN go mod download
@@ -55,6 +58,7 @@ LABEL name="MongoDB Atlas Operator" \
5558
WORKDIR /
5659
COPY --from=builder /workspace/bin/manager .
5760
COPY hack/licenses licenses
61+
COPY --from=builder /workspace/dbaas_provider.yaml .
5862

5963
USER 1001:0
6064
ENTRYPOINT ["/manager"]

PROJECT

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
domain: mongodb.com
22
layout:
3-
- go.kubebuilder.io/v2
3+
- go.kubebuilder.io/v3
44
plugins:
55
manifests.sdk.operatorframework.io/v2: {}
66
scorecard.sdk.operatorframework.io/v2: {}
@@ -15,7 +15,33 @@ resources:
1515
group: atlas
1616
kind: AtlasDeployment
1717
path: github.com/mongodb/mongodb-atlas-kubernetes/api/v1
18-
version: v1
18+
- api:
19+
crdVersion: v1
20+
namespaced: true
21+
controller: true
22+
domain: redhat.com
23+
group: dbaas
24+
kind: MongoDBAtlasConnection
25+
path: github.com/mongodb/mongodb-atlas-kubernetes/pkg/api/dbaas
26+
version: v1beta1
27+
- api:
28+
crdVersion: v1
29+
namespaced: true
30+
controller: true
31+
domain: redhat.com
32+
group: dbaas
33+
kind: MongoDBAtlasInventory
34+
path: github.com/mongodb/mongodb-atlas-kubernetes/pkg/api/dbaas
35+
version: v1beta1
36+
- api:
37+
crdVersion: v1
38+
namespaced: true
39+
controller: true
40+
domain: redhat.com
41+
group: dbaas
42+
kind: MongoDBAtlasInstance
43+
path: github.com/mongodb/mongodb-atlas-kubernetes/pkg/api/dbaas
44+
version: v1beta1
1945
- api:
2046
crdVersion: v1
2147
namespaced: true

README.md

+190
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,196 @@ Operator support Third Party Integration.
151151
- [Mongodb Atlas Operator sample](docs/project-integration.md)
152152
- [Atlas documentation Atlas](https://docs.atlas.mongodb.com/reference/api/third-party-integration-settings/)
153153

154+
### Step 4. Test Database as a Service (DBaaS) on OpenShift
155+
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).
157+
158+
**1.** Check DBaaS Registration
159+
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.
161+
If the Atlas Operator is undeployed with the OLM, the above registration CR gets cleaned up automatically.
162+
163+
**2.** Check MongoDBAtlasInventory Custom Resource
164+
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.
166+
Here is an example of MongoDBAtlasInventory CR.
167+
```
168+
apiVersion: dbaas.redhat.com/v1beta1
169+
kind: MongoDBAtlasInventory
170+
metadata:
171+
name: dbaas-mytest
172+
namespace: openshift-operators
173+
ownerReferences:
174+
- apiVersion: dbaas.redhat.com/v1beta1
175+
blockOwnerDeletion: true
176+
controller: true
177+
kind: DBaaSInventory
178+
name: dbaas-mytest
179+
uid: 01f5a690-c640-462f-b6e8-ccb9db95df70
180+
spec:
181+
credentialsRef:
182+
name: my-atlas-key
183+
namespace: openshift-operators
184+
status:
185+
conditions:
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
248+
status: "True"
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
259+
```
260+
**4.** Check MongoDBAtlasConnection Custom Resource
261+
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.
263+
264+
Here is an example of MongoDBAtlasConnection CR.
265+
```
266+
apiVersion: dbaas.redhat.com/v1beta1
267+
kind: MongoDBAtlasConnection
268+
metadata:
269+
name: test-dbaas-connection
270+
namespace: test-namespace
271+
ownerReferences:
272+
- apiVersion: dbaas.redhat.com/v1beta1
273+
blockOwnerDeletion: true
274+
controller: true
275+
kind: DBaaSConnection
276+
name: test-dbaas-connection
277+
uid: 77193619-6ab1-43c9-acf2-a40c2cfe7703
278+
spec:
279+
databaseServiceID: 12345ffbc9a90e310e642482
280+
inventoryRef:
281+
name: dbaas-mytest
282+
namespace: openshift-operators
283+
status:
284+
conditions:
285+
- lastTransitionTime: "2023-03-28T20:06:56Z"
286+
message: ""
287+
reason: Ready
288+
status: "True"
289+
type: ReadyForBinding
290+
connectionInfoRef:
291+
name: atlas-connection-cm-knp9z
292+
credentialsRef:
293+
name: atlas-db-user-5pc8b
294+
```
295+
The corresponding generated secret:
296+
```
297+
apiVersion: v1
298+
data:
299+
password: cGFzczEyM3dAcmQ=
300+
username: ZGJVc2VyXzEwMQ==
301+
kind: Secret
302+
metadata:
303+
labels:
304+
managed-by: atlas-operator
305+
owner: test-dbaas-connection
306+
owner.kind: MongoDBAtlasConnection
307+
owner.namespace: test-namespace
308+
name: atlas-db-user-5pc8b
309+
namespace: test-namespace
310+
ownerReferences:
311+
- apiVersion: dbaas.redhat.com/v1beta1
312+
blockOwnerDeletion: false
313+
controller: true
314+
kind: MongoDBAtlasConnection
315+
name: test-dbaas-connection
316+
uid: a50b06db-8fa1-45c9-9893-833a028dfccc
317+
type: Opaque
318+
```
319+
The corresponding generated configmap:
320+
```
321+
apiVersion: v1
322+
data:
323+
host: cluster0.ubajs.mongodb.net
324+
provider: OpenShift Datase Access / MongoDB Atlas
325+
srv: "true"
326+
type: mongodb
327+
kind: ConfigMap
328+
metadata:
329+
labels:
330+
managed-by: atlas-operator
331+
owner: test-dbaas-connection
332+
owner.kind: MongoDBAtlasConnection
333+
owner.namespace: test-namespace
334+
name: atlas-connection-cm-knp9z
335+
namespace: test-namespace
336+
ownerReferences:
337+
- apiVersion: dbaas.redhat.com/v1beta1
338+
blockOwnerDeletion: false
339+
controller: true
340+
kind: MongoDBAtlasConnection
341+
name: test-dbaas-connection
342+
uid: a50b06db-8fa1-45c9-9893-833a028dfccc
343+
```
154344
## How to Contribute
155345

156346
Please file issues before filing PRs. For PRs to be accepted, contributors must sign

bundle.Dockerfile

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
FROM scratch
22

3-
LABEL com.redhat.openshift.versions="v4.8"
4-
LABEL com.redhat.delivery.backport=true
5-
LABEL com.redhat.delivery.operator.bundle=true
6-
73
# Core bundle labels.
84
LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
95
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
106
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
117
LABEL operators.operatorframework.io.bundle.package.v1=mongodb-atlas-kubernetes
12-
LABEL operators.operatorframework.io.bundle.channels.v1=stable
13-
LABEL operators.operatorframework.io.bundle.channel.default.v1=stable
14-
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.15.0+git
8+
LABEL operators.operatorframework.io.bundle.channels.v1=beta
9+
LABEL operators.operatorframework.io.bundle.channel.default.v1=beta
10+
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.19.0+git
1511
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
16-
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v2
12+
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3
1713

1814
# Labels for testing.
1915
LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1

0 commit comments

Comments
 (0)