Provider Operator Example
The GitHub repository provides an operator example for integrating database providers with the OpenShift Database Access/DBaaS Operator. The examples is intended to help developers understand how to create their operator that is integrated with DBaaS operator.
Create Your Operator
Reqs:
- go v1.18
- operator-sdk-v1.24
operator-sdk init --domain redhat.com --repo github.com/RHEcosystemAppEng/provider-operator-example.git
operator-sdk edit --multigroup=true
operator-sdk create api --group dbaas --version v1beta1 --kind ProviderInventory --resource --controller
operator-sdk create api --group dbaas --version v1beta1 --kind ProviderConnection --resource --controller
operator-sdk create api --group dbaas --version v1beta1 --kind ProviderInstance --resource --controller
**Note : You need to change the "Kind" accordingly with the Provider Name for example : Instance, Connection, see example for crunchy bridge operator
Add the DBaaS API to your go.mod file github.com/RHEcosystemAppEng/dbaas-operator v0.4.1-0.20230403142057-6112a98be1a6
and add DBaaSInventorySpec/DBaaSInventoryStatus, DBaaSInstanceSpec/DBaaSInstanceStatus, and DBaaSConnectionSpec/DBaaSConnectionStatus as the Spec/Status to the ProviderInventory, ProviderInstance, and ProviderConnection data structures, respectively.
Build Your Operator
Run the following commands to build operator, bundle, catalog and push on quay.io or another registry, and make sure the images in the registry have public access:
make docker-build
make docker-push
make bundle
make bundle-build
make bundle-push
make catalog-build
make catalog-push
Implement Your Operator Controllers
Please read the DBaaS Provider guide for more details here and you can follow this operator controller implementation for your reference,
1- Add Provider Controller and CR details to register with DBaaS Operator.
This will be a new controller you can follow or copied the same controller, and update the registration CR accordingly your provider details.
2- Inventory Controller Implementation reference
3- Connection Controller Implementation reference
4- Instance Controller Implementation reference
Test Your Operator
Read these reference docs to understand the flow of DBaaS Operator:
Test With DBaaS Operator
Before testing your operator, make sure to deploy the DBaaS Operator from OLM. Once the DBaaS Operator is installed, you can proceed to install your own operator.
- Verify DBaaS Registration CR: once the operator deployed it will automatically create a cluster level DBaaSProvider custom resource (CR) object and register itself with the DBaaS Operator.
- Create the Provider Account: using DBaaS UI as explained here
- Create new Instance: you can create the new Instance by going DBaaS UI by clicking Create Database Instance
- Create the Connection with Instance : using DBaaS UI as explained here
- Create your provider application sample: You need to create the application according to Service binding libraries structure :
Test Standalone Operator
kubectl create secret generic dbaas-vendor-credentials --from-literal="CredentialField1=<Application ID>" --from-literal="CredentialField2=<Application Secret>" -n openshift-dbaas-operator
- Create the Provider Account like here
- Create connection Object like here
- Create the Instance Object like here