Decision Management (ODM,ADS)

Decision Management (ODM, ADS)

Connect with experts and peers to elevate technical expertise, solve problems and share insights

Β View Only

ODM Kubernetes libertyHookRef Explained

  • 1.  ODM Kubernetes libertyHookRef Explained

    Posted 27 days ago
    Edited by Aaron Chen 26 days ago

    Customizing ODM Liberty Configuration Using libertyHookRef

    In IBM ODM, the libertyHookRef parameter appears in production configurations. This parameter is found here: ODM for production configuration parameters  This parameter allows you to inject custom configurations into the Liberty server.xml, which is especially valuable in advanced use cases.


    πŸ“Œ Use Case: Adding a Third Datasource

    By default, ODM Helm charts support configuration of two datasources: ilogDatasource and resDatasource. But what if your JAVA SE or POJO session requires an additional (third) datasource?

    This is where libertyHookRef comes into play. It allows you to extend Liberty's configuration - including additional datasources - via custom XML injected at runtime.


    πŸ› οΈ How It Works

    1. Create a libertyHookEnd.xml File

    This XML file works similarly to datasource-dc.xml. To base your custom config on existing templates, you can inspect the contents inside a running ODM pod:

    kubectl exec -it mycompany-odm-decisionserverruntime-6b77d7b696-g5mdt -- /bin/sh

    cd /config/customdatasource

    ls
    # Output:
    # datasource-dc.xml  datasource-ds.xml

    cat datasource-ds.xml

    1. Sample libertyHookEnd.xml

    Here's an example you can adapt. Make sure to change id and jndiName to suit your requirements:

    <server>

      <!-- Additional Decision Center datasource -->
      <dataSource id="dcdatasource2"
                  jndiName="jdbc/ilogDataSource2"
                  isolationLevel="TRANSACTION_READ_COMMITTED"
                  statementCacheSize="150"
                  jdbcDriverRef="postgresql-driver"
                  type="javax.sql.ConnectionPoolDataSource"
                  validationTimeout="0">

        <connectionManager maxPoolSize="25"
                           minPoolSize="10"
                           connectionTimeout="10s"
                           agedTimeout="30m" />

        <properties
          databaseName="mydatabase"
          user="odmAdmin"
          password="odmAdmin"
          portNumber="5432"
          tcpKeepAlive="true"
          sslMode="prefer"
          serverName="my-postgres-instance.c0cxct6erry9.us-east-2.rds.amazonaws.com" />

      </dataSource>

      <jdbcDriver id="postgresql-driver"
                  javax.sql.ConnectionPoolDataSource="org.postgresql.ds.PGConnectionPoolDataSource"
                  javax.sql.XADataSource="org.postgresql.xa.PGXADataSource"
                  libraryRef="postgresql-library" />

      <library id="postgresql-library">
        <fileset dir="${server.config.dir}/resources" />
      </library>

    </server>

    1. Create a Secret

    Bundle your libertyHookEnd.xml into a Kubernetes secret named customdatasource-secret:

    *Create a libertyHookStart.xml file to modify the start of the server.xml and/or a libertyHookEnd.xml file to modify the end of the server.xml file.*

    kubectl create secret generic customdatasource-secret \
      --from-file=libertyHookEnd.xml=./libertyHookEnd.xml

    kubectl create secret generic my-liberty-config --from-file=libertyHookStart.xml --from-file=libertyHookEnd.xml

    Update value.yaml

    To apply the customization to Decision Center and Decision Server Runtime, add the following:

    decisionCenter:
      libertyHookRef: customdatasource-secret

    decisionServerRuntime:
      libertyHookRef: customdatasource-secret

    Or if you're using a global customization:

    customization:
      libertyHookRef: customdatasource-secret

    ⚠️ Important: Avoid setting libertyHookRef in multiple places. If using the customization section, remove it from individual components to prevent conflicts.

    Once everything is set, apply the updated values with:

    kubectl apply -f value.yaml



    ------------------------------
    Aaron Chen
    ------------------------------