Configuring a custom external database

You can configure your Operational Decision Manager instance to connect to a custom external database. The database drivers must be added to the ODM instance after the deployment is created.

About this task

Operational Decision Manager supports database connections to custom external databases, for example Oracle.

Note: If you use a custom external database, you are responsible for the backup and recovery process.

To use a custom external database, you need to create a data source secret and a PVC for the driver. You must then set the externalCustomDatabase parameters in the odm_configuration section of your custom resource file.

Tip: Sample YAML files are provided in the cert-kubernetes/ODM/configuration/custom-external-database folder.

For more information about downloading cert-kubernetes, see Preparing for a production deployment.

Procedure

  1. Create an XML file to configure the Decision Center data source.

    Name the file datasource-dc.xml.

    The following example shows a configuration file for Oracle.

    <server>
        <!-- Declare the jar files for Oracle access through JDBC. -->
        <library id="OracleLib">
                <fileset dir="/drivers" includes="ojdbc*.jar"/>
        </library>
    
        <!-- Declare the database -->
        <dataSource jndiName="jdbc/ilogDataSource"
                    isolationLevel="TRANSACTION_READ_COMMITTED"
                    statementCacheSize="150">
                <connectionManager maxPoolSize="25"
                                   minPoolSize="10"
                                   connectionTimout="10s"
                                   agedTimeout="30m"/>
                <jdbcDriver libraryRef="OracleLib"/>
                <properties.oracle driverType="thin" 
                                   databaseName="xe" 
                                   serverName="oracleServerName" 
                                   portNumber="1521" 
                                   user="system" 
                                   password="oracle"/>
        </dataSource>
    </server>
    Note: The /drivers path must not be modified. The path locates a directory in the container. See What to do next to push the database driver after the deployment is created.
  2. Create an XML file to configure the Decision Server data source.

    Name the file datasource-ds.xml.

    The following example shows a configuration file for Oracle.

    <server>
        <!-- Declare the jar files for Oracle access through JDBC. -->
        <library id="OracleLib">
                <fileset dir="/drivers" includes="ojdbc*.jar"/>
        </library>
    
        <!-- Declare the database -->
        <dataSource jndiName="jdbc/resdatasource">
                <jdbcDriver libraryRef="OracleLib"/>
                <properties.oracle driverType="thin" 
                                   databaseName="xe" 
                                   serverName="oracleServerName" 
                                   portNumber="1521" 
                                   user="system" 
                                   password="oracle"/>
        </dataSource>
    </server>
  3. Create a secret from the two XML files.
    Use the kubectl create secret command to create a secret. The following example creates customdatasource-secret.
    kubectl create secret generic customdatasource-secret --from-file datasource-ds.xml --from-file datasource-dc.xml
  4. Create a Persistent Volume Claim (PVC) to host the JDBC Oracle driver.
    The following YAML file (driver-pvc.yaml) defines the PVC customdatasource-pvc.
    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: customdatasource-pvc
    spec:
      accessModes:
        - ReadWriteOnce
      storageClassName: <storage_class_name>
      resources:
        requests:
          storage: 1Gi

    The following kubectl command creates the PVC.

    kubectl create -f driver-pvc.yaml
  5. When you configure Operational Decision Manager, use the custom parameters for the secret and PVC you created.

    In a custom resource descriptor with the Cloud Pak operator, use the following YAML:

    spec:
      odm_configuration:
        externalCustomDatabase:
          datasourceRef: customdatasource-secret
          driverPvc: customdatasource-pvc

What to do next

To be able to use a custom database, you must push the JDBC driver to the Decision Center pod by running a kubectl cp command after you deployed the custom resource.

For example, to configure an Oracle database as your external database use the following steps.

  1. Get the name of the pod for the ODM instance by using the following command.
    kubectl get pods | grep instance-name

    The command returns a list of pods.

  2. Check that the Oracle database is up and running.
  3. Add the Oracle JDBC driver to one of the pods that are listed from step 1 by running the following command.
    kubectl cp ojdbc8-12.x.x.x.jar namespace/instance-name-odm-decisioncenter-XXXXXX:/drivers/
  4. If you want to change the access mode from ReadWriteOnce to ReadOnlyMany, you need to edit the PersistenceVolume that is associated with the PersistenceVolumeClaim.
    Note: Make sure that ReadOnlyMany is supported by your persistence volume.

    In ReadWriteOnce mode, the persistence volume can be mounted as read-write by a single node. All the pods attached to this persistence volume are instantiated on the same node.

    In ReadOnlyMany mode, the persistence volume can be mounted as read-only by many nodes. All the pods attached to the persistence volume are instantiated on multiple nodes.

    To change the access mode to ReadOnlyMany, follow these steps:

    1. Display the associated PersistenceVolume.
      kubectl get pvc customdatasource-pvc
    2. Run the following command to change the access mode of the persistence volume to ReadOnlyMany.
      kubectl patch pv <PV-NAME> -p '{"spec":{"accessModes":["ReadOnlyMany"]}}'
After you added the driver, restart all the pods by using the kubectl delete pod command to pick up the changes.
kubectl delete pod instance-name-odm-decisioncenter-XXXXXX \
kubectl delete pod instance-name-odm-decisionserverconsole-XXXXXX \
kubectl delete pod instance-name-odm-decisionserverruntime-XXXXXX \
kubectl delete pod instance-name-odm-decisionrunner-XXXXXX