Configuring a custom external database

You can customize your Operational Decision Manager instance by configuring an external database. IBM Db2® and PostgreSQL drivers are provided.

About this task

ODM for production supports database connections to custom external databases, for example Oracle.

Tip: Sample YAML files are provided in the following GitHub folder

https://github.com/icp4a/cert-kubernetes/tree/19.0.3/ODM/configuration/custom-external-database.

Procedure

  1. Create an XML file to configure the Decision Center datasource.

    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. To copy a driver to the /drivers directory, use the following command.
    kubectl cp ojdbc8-12.x.x.x.jar namespace/instance-name-odm-decisioncenter-XXXXXX:/drivers/ 
  2. Create an XML file to configure the Decision Server datasource.

    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 the secret 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
      resources:
        requests:
          storage: 1Gi

    The following command creates the PVC.

    kubectl create -f driver-pvc.yaml
  5. When you deploy Operational Decision Manager, use the custom parameters for the secret and PVC you created.
     For 19.0.2 
    externalCustomDatabase.datasourceRef=customdatasource-secret
    externalCustomDatabase.driverPvc=customdatasource-pvc

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

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

    The YAML file is applied to the operator by running the kubectl apply command. You run the command only when you are done configuring your ODM customizations and all of the other components that you want to deploy or update.

    kubectl apply -f custom_resources.yaml
  6. Push the JDBC driver in the PVC by running a kubectl cp command.
    1. Get the name of the pod for the ODM instance by using the 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 a pod with the following command.
      kubectl cp ojdbc8-12.x.x.x.jar namespace/instance-name-odm-decisioncenter-XXXXXX:/drivers/
  7. Restart all the pods by using the kubectl delete pod command.
    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