Skip to content

Latest commit

 

History

History
203 lines (128 loc) · 12.5 KB

File metadata and controls

203 lines (128 loc) · 12.5 KB

Oracle On-Prem Database Controller

CDBs and PDBs are the part of the Oracle Database's Multitenant Architecture. The On-Prem Database Controller is a feature of Oracle DB Operator for Kubernetes (OraOperator) which helps to manage the life cycle of Pluggable Databases (PDBs) in an Oracle Container Database(CDB).

The target CDB (for which the PDB life cycle management is needed) can be running on an on-prem machine and to manage its PDBs, the Oracle DB Operator can run on an on-prem Kubernetes system (For Example: Oracle Linux Cloud Native Environment or OLCNE).

NOTE: The target CDB (for which the PDB life cycle management is needed) can also run in a Cloud environment as well (For Example: OCI's Oracle Base Database Service) and to manage its PDBs, the Oracle DB Operator can run on a Kubernetes Cluster running in cloud (For Example: OCI's Container Engine for Kubernetes or OKE)

Oracle DB Operator On-Prem Database Controller Deployment

To deploy OraOperator, use this Oracle Database Operator for Kubernetes step-by-step procedure.

After the Oracle Database Operator is deployed, you can see the DB Operator Pods running in the Kubernetes Cluster. As part of the OraOperator deployment, the On-Prem Database Controller is deployed and we can see the CRDs (Custom Resource Definition) for CDB and PDB in the list of CRDs. The following output is an example of such a deployment:

[root@test-server oracle-database-operator]# kubectl get ns
NAME                              STATUS   AGE
cert-manager                      Active   32h
default                           Active   245d
kube-node-lease                   Active   245d
kube-public                       Active   245d
kube-system                       Active   245d
oracle-database-operator-system   Active   24h    <<<< namespace to deploy the Oracle Database Operator


[root@test-server oracle-database-operator]# kubectl get all -n  oracle-database-operator-system
NAME                                                               READY   STATUS    RESTARTS   AGE
pod/oracle-database-operator-controller-manager-665874bd57-dlhls   1/1     Running   0          28s
pod/oracle-database-operator-controller-manager-665874bd57-g2cgw   1/1     Running   0          28s
pod/oracle-database-operator-controller-manager-665874bd57-q42f8   1/1     Running   0          28s

NAME                                                                  TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
service/oracle-database-operator-controller-manager-metrics-service   ClusterIP   10.96.130.124   <none>        8443/TCP   29s
service/oracle-database-operator-webhook-service                      ClusterIP   10.96.4.104     <none>        443/TCP    29s

NAME                                                          READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/oracle-database-operator-controller-manager   3/3     3            3           29s

NAME                                                                     DESIRED   CURRENT   READY   AGE
replicaset.apps/oracle-database-operator-controller-manager-665874bd57   3         3         3       29s
[root@docker-test-server oracle-database-operator]# 


[root@test-server oracle-database-operator]# kubectl get crd
NAME                                               CREATED AT
autonomouscontainerdatabases.database.oracle.com   2022-06-22T01:21:36Z
autonomousdatabasebackups.database.oracle.com      2022-06-22T01:21:36Z
autonomousdatabaserestores.database.oracle.com     2022-06-22T01:21:37Z
autonomousdatabases.database.oracle.com            2022-06-22T01:21:37Z
cdbs.database.oracle.com                           2022-06-22T01:21:37Z <<<<
certificaterequests.cert-manager.io                2022-06-21T17:03:46Z
certificates.cert-manager.io                       2022-06-21T17:03:47Z
challenges.acme.cert-manager.io                    2022-06-21T17:03:47Z
clusterissuers.cert-manager.io                     2022-06-21T17:03:48Z
dbcssystems.database.oracle.com                    2022-06-22T01:21:38Z
issuers.cert-manager.io                            2022-06-21T17:03:49Z
oraclerestdataservices.database.oracle.com         2022-06-22T01:21:38Z
orders.acme.cert-manager.io                        2022-06-21T17:03:49Z 
pdbs.database.oracle.com                           2022-06-22T01:21:39Z <<<<
shardingdatabases.database.oracle.com              2022-06-22T01:21:39Z
singleinstancedatabases.database.oracle.com        2022-06-22T01:21:40Z

The following sections explain the setup and functionality of this controller.

Prerequsites to manage PDB Life Cycle using Oracle DB Operator On-Prem Database Controller

Before you want to manage the life cycle of a PDB in a CDB using the Oracle DB Operator On-Prem Database Controller, complete the following steps.

CAUTION : You must make the changes specified in this section before you proceed to the next section.

  • Prepare CDB for PDB Lifecycle Management (PDB-LM)

Pluggable Database management operation is performed in the Container Database (CDB) and it includes create, clone, plug, unplug, delete, modify and map operations.

You cannot have an ORDS enabled schema in the container database. To perform the PDB lifecycle management operations, the default CDB administrator credentials must be defined by performing the below steps on the target CDB(s):

Create the CDB administrator user and grant the required privileges. In this example, the user is C##DBAPI_CDB_ADMIN. However, any suitable common user name can be used.

Also, create a user named SQL_ADMIN. You can use the below set of SQL commands for this purpose:

SQL> conn /as sysdba
 
-- Create the below users at the database level:

DROP USER SQL_ADMIN CASCADE;
CREATE USER SQL_ADMIN IDENTIFIED BY welcome1;
ALTER SESSION SET "_oracle_script"=true;
DROP USER  C##DBAPI_CDB_ADMIN cascade;
CREATE USER C##DBAPI_CDB_ADMIN IDENTIFIED BY <Password> CONTAINER=ALL ACCOUNT UNLOCK;
GRANT SYSOPER TO C##DBAPI_CDB_ADMIN CONTAINER = ALL;
GRANT SYSDBA TO C##DBAPI_CDB_ADMIN CONTAINER = ALL;
GRANT CREATE SESSION TO C##DBAPI_CDB_ADMIN CONTAINER = ALL;
GRANT CREATE SESSION TO SQL_ADMIN;
GRANT SYSDBA TO SQL_ADMIN;
 

-- Verify the account status of the below usernames. They should not be in locked status:

col username        for a30
col account_status  for a30
select username, account_status from dba_users where username in ('ORDS_PUBLIC_USER','SQL_ADMIN','C##DBAPI_CDB_ADMIN','APEX_PUBLIC_USER','APEX_REST_PUBLIC_USER');

Reference Setup: Example of a setup using OCI OKE(Kubernetes Cluster) and a CDB in Cloud (OCI Exadata Database Cluster)

Please refer here for steps to configure a Kubernetes Cluster and a CDB. This example uses an OCI OKE Cluster as the Kubernetes Cluster and a CDB in OCI Exadata Database service.

  • Oracle REST Data Service (ORDS) Image

    Oracle DB Operator On-Prem Database controller requires the Oracle REST Data Services (ORDS) image for PDB Lifecycle Management in the target CDB.

    You can build this image by using the ORDS Dockerfile

    NOTE: Download the required binaries to build this image i.e. Oracle Rest Data Services 'ords-< version >.zip', from http://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/index.html

    NOTE: The current version of Oracle DB Operator On-Prem Controller has been tested with ORDS 21.4.3 version.

Please refer here for the steps to build ORDS Docker Image with ORDS 21.4.3 version.

  • Kubernetes Secrets

    Oracle DB Operator On-Prem Database Controller uses Kubernetes Secrets to store usernames and passwords to manage the life cycle operations of a PDB in the target CDB.

Secrets for CDB CRD

Create a secret file as shown here: config/samples/onpremdb/cdb_secret.yaml. Modify this file with the base64 encoded values of the required passwords for CDB and use it to create the required secrets.

$ kubectl apply -f cdb_secret.yaml

Note: In order to get the base64 encoded value for a password, please use the below command like below at the command prompt. The value you get is the base64 encoded value for that password string.

echo -n "<password to be encoded using base64>" | base64

Note: On successful creation of the CDB Resource, the CDB secrets would be deleted from the Kubernetes system.

Secrets for PDB CRD

Create a secret file as shown here: config/samples/onpremdb/pdb_secret.yaml. Modify this file with the base64 encoded values of the required passwords for PDB and use it to create the required secrets.

$ kubectl apply -f pdb_secret.yaml

NOTE: Refer to command provided above to encode the password using base64.

NOTE: Don't leave plaintext files containing sensitive data on disk. After loading the Secret, remove the plaintext file or move it to secure storage.

  • Kubernetes CRD for CDB

The Oracle Database Operator On-Prem Controller creates the CDB kind as a custom resource that models a target CDB as a native Kubernetes object. This is used only to create Pods to connect to the target CDB to perform PDB-LM operations. These CDB resources can be scaled up and down based on the expected load using replicas. Each CDB resource follows the CDB CRD as defined here: config/crd/bases/database.oracle.com_cdbs.yaml

To create a CDB CRD, a sample .yaml file is available here: config/samples/onpremdb/cdb.yaml

Note: The password and username fields in this cdb.yaml yaml are Kubernetes Secrets created earlier. Please see the section Kubernetes Secrets for more information. Please see Kubernetes Private Registry Documenation for creating secrets for pulling images from docker private registry.

  1. Use Case: Create a CDB CRD Resource
  2. Use Case: Add another replica to an existing CDB CRD Resource
  • Kubernetes CRD for PDB

The Oracle Database Operator On-Prem Controller creates the PDB kind as a custom resource that models a PDB as a native Kubernetes object. There is a one-to-one mapping between the actual PDB and the Kubernetes PDB Custom Resource. You cannot have more than one Kubernetes resource for a target PDB. This PDB resource can be used to perform PDB-LM operations by specifying the action attribute in the PDB Specs. Each PDB resource follows the PDB CRD as defined here: config/crd/bases/database.oracle.com_pdbs.yaml

To create a PDB CRD Resource, a sample .yaml file is available here: config/samples/onpremdb/pdb_create.yaml

Use Cases for PDB Lifecycle Management Operations using Oracle DB Operator On-Prem Controller

Using Oracle DB Operator On-Prem Controller, you can perform the following PDB-LM operations: CREATE, CLONE, MODIFY, DELETE, UNPLUG, PLUG.

  1. Create PDB
  2. Clone PDB
  3. Modify PDB
  4. Delete PDB
  5. Unplug PDB
  6. Plug PDB

Validation and Errors

Please check here for the details to look for any validation error.

Known issues

Please refer here for the known issues related to Oracle DB Operator On-Prem Controller.