Chapter 6. Running and Configuring Realtime Decision Server for OpenShift

You can make changes to Realtime Decision Server for OpenShift configuration in the image using either the S2I templates, or by using a modified Realtime Decision Server for OpenShift.

6.1. Using Realtime Decision Server for OpenShift Source-to-Image (S2I) Process

The recommended method to run and configure Realtime Decision Server for OpenShift is to use the OpenShift S2I process together with the application template parameters and environment variables.

The S2I process for Realtime Decision Server for OpenShift works as follows:

  1. If there is a pom.xml file in the source repository, a Maven build is triggered with the contents of $MAVEN_ARGS environment variable.

    • By default, the package goal is used with the openshift profile, including the system properties for skipping tests (-DskipTests) and enabling the Red Hat GA repository (-Dcom.redhat.xpaas.repo.redhatga).
  2. The results of a successful Maven build are installed into the local Maven repository, /home/jboss/.m2/repository/, along with all dependencies for offline usage. Realtime Decision Server for OpenShift will load the created kjars from this local repository.

    • In addition to kjars resulting from the Maven build, any kjars found in the deployments source directory will also be installed into the local Maven repository. Kjars do not end up in the EAP_HOME/standalone/deployments/ directory.
  3. Any JAR (that is not a kjar), WAR, and EAR in the deployments source repository directory will be copied to the EAP_HOME/standalone/deployments directory and subsequently deployed using the JBoss EAP deployment scanner.
  4. All files in the configuration source repository directory are copied to EAP_HOME/standalone/configuration.

    Note

    If you want to use a custom JBoss EAP configuration file, it should be named standalone-openshift.xml.

  5. All files in the modules source repository directory are copied to EAP_HOME/modules.

Refer to the Artifact Repository Mirrors section for additional guidance on how to instruct the S2I process to utilize the custom Maven artifacts repository mirror.

6.2. Binary Builds

To deploy existing applications on OpenShift, you can use the binary source capability.

Prerequisite:

  1. Get the application archive or build the application locally.

    The following example uses both the hellorules and hellorules-client quickstarts.

    • Clone the source code.

      $ git clone https://github.com/jboss-openshift/openshift-quickstarts.git
    • Configure the Red Hat JBoss Middleware Maven repository.
    • Build the application — both the hellorules and hellorules-client quickstarts.

      Note

      The output of mvn clean package command below has been shortened to contain just selected information.

      $ cd openshift-quickstarts/decisionserver/
      $ mvn clean package
      [INFO] Scanning for projects...
      ...
      [INFO] ------------------------------------------------------------------------
      [INFO] Reactor Build Order:
      [INFO]
      [INFO] OpenShift Quickstarts: Decision Server: Hello Rules
      [INFO] OpenShift Quickstarts: Decision Server: Hello Rules - Client
      [INFO] OpenShift Quickstarts: Decision Server: Parent
      [INFO]
      [INFO] ------------------------------------------------------------------------
      [INFO] Building OpenShift Quickstarts: Decision Server: Hello Rules 1.4.0.Final
      [INFO] ------------------------------------------------------------------------
      ...
      [INFO] ------------------------------------------------------------------------
      [INFO] Building OpenShift Quickstarts: Decision Server: Hello Rules - Client 1.4.0.Final
      [INFO] ------------------------------------------------------------------------
      ...
      [INFO] ------------------------------------------------------------------------
      [INFO] Reactor Summary:
      [INFO]
      [INFO] OpenShift Quickstarts: Decision Server: Hello Rules  SUCCESS [  0.844 s]
      [INFO] OpenShift Quickstarts: Decision Server: Hello Rules - Client SUCCESS [  7.446 s]
      [INFO] OpenShift Quickstarts: Decision Server: Parent ..... SUCCESS [  0.002 s]
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESS
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 9.286 s
      [INFO] Finished at: 2017-06-27T16:49:25+02:00
      [INFO] Final Memory: 49M/502M
      [INFO] ------------------------------------------------------------------------
  1. Prepare the directory structure on the local file system.

    Application archives in the deployments/ subdirectory of the main binary build directory are copied directly to the standard deployments folder of the image being built on OpenShift. For the application to deploy, the directory hierarchy containing the web application data must be correctly structured.

    Create main directory for the binary build on the local file system and deployments/ subdirectory within it. Copy both the previously built JAR archive for the hellorules quickstart, and WAR archive for the hellorules-client quickstart to the deployments/ subdirectory:

    decisionserver]$ ls
    hellorules  hellorules-client  pom.xml
    $ mkdir -p ocp/deployments
    $ cp hellorules/target/decisionserver-hellorules-1.4.0.Final.jar ocp/deployments/
    $ cp hellorules-client/target/decisionserver-hellorules-client-1.4.0.Final.war ocp/deployments/
    Note

    Location of the standard deployments directory depends on the underlying base image, that was used to deploy the application. See the following table:

    Table 6.1. Standard Location of the Deployments Directory

    Name of the Underlying Base Image(s)Standard Location of the Deployments Directory

    EAP for OpenShift 6.4 and 7.0

    $JBOSS_HOME/standalone/deployments

    Java S2I for OpenShift

    /deployments

    JWS for OpenShift

    $JWS_HOME/webapps

Perform the following steps to run application consisting of binary input on OpenShift:

  1. Login into OpenShift instance.

    $ oc login
  2. Create a new project.

    $ oc new-project ds-bin-demo
  3. (Optional) Identify the image stream for the particular image.

    $ oc get is -n openshift | grep ^jboss-decisionserver | cut -f1 -d ' '
    jboss-decisionserver62-openshift
    jboss-decisionserver63-openshift
    Note

    Since the images from jboss-decisionserver62-openshift image stream are obsolete, we will use jboss-decisionserver63-openshift below.

  4. Create new binary build, specifying image stream and application name.

    Note

    You can change the default user name and password to access the REST interface of the KIE server by providing custom values for KIE_SERVER_USER and KIE_SERVER_PASSWORD environment variables.

    $ oc new-build --binary=true \
    --name=ds-hr-app \
    --image-stream=jboss-decisionserver63-openshift \
    -e KIE_SERVER_USER=kieserveruser \
    -e KIE_SERVER_PASSWORD=kieserverPwd1!
    --> Found image 4a6c0ce (5 weeks old) in image stream "jboss-decisionserver63-openshift" in project "openshift" under tag "latest" for "jboss-decisionserver63-openshift"
    
        JBoss BRMS Realtime Decision Server 6.3
        ---------------------------------------
        Platform for executing business rules on JBoss BRMS Realtime Decision Server 6.3.
    
        Tags: builder, decisionserver, decisionserver6
    
        * A source build using binary input will be created
          * The resulting image will be pushed to image stream "ds-hr-app:latest"
          * Use 'start-build --from-dir=DIR|--from-repo=DIR|--from-file=FILE' to trigger a new build
          * WARNING: a binary build was created, you must specify one of --from-dir|--from-file|--from-repo when starting builds
    
    --> Creating resources with label build=ds-hr-app ...
        imagestream "ds-hr-app" created
        buildconfig "ds-hr-app" created
    --> Success
  5. Start the binary build. Instruct oc executable to use main directory of the binary build we created in previous step as the directory containing binary input for the OpenShift build.

    Note

    The output of the next command has been shortened for brevity.

    $ oc start-build ds-hr-app --from-dir=./ocp/ --follow
    Uploading directory "ocp" as binary input for the build ...
    build "ds-hr-app-1" started
    Receiving source from STDIN as archive ...
    
    Copying all war artifacts from /home/jboss/source/. directory into /opt/eap/standalone/deployments for later deployment...
    Copying all ear artifacts from /home/jboss/source/. directory into /opt/eap/standalone/deployments for later deployment...
    Copying all rar artifacts from /home/jboss/source/. directory into /opt/eap/standalone/deployments for later deployment...
    Copying all jar artifacts from /home/jboss/source/. directory into /opt/eap/standalone/deployments for later deployment...
    Copying all war artifacts from /home/jboss/source/deployments directory into /opt/eap/standalone/deployments for later deployment...
    '/home/jboss/source/deployments/decisionserver-hellorules-client-1.4.0.Final.war' -> '/opt/eap/standalone/deployments/decisionserver-hellorules-client-1.4.0.Final.war'
    Copying all ear artifacts from /home/jboss/source/deployments directory into /opt/eap/standalone/deployments for later deployment...
    Copying all rar artifacts from /home/jboss/source/deployments directory into /opt/eap/standalone/deployments for later deployment...
    Copying all jar artifacts from /home/jboss/source/deployments directory into /opt/eap/standalone/deployments for later deployment...
    '/home/jboss/source/deployments/decisionserver-hellorules-1.4.0.Final.jar' -> '/opt/eap/standalone/deployments/decisionserver-hellorules-1.4.0.Final.jar'
    /opt/eap/standalone/deployments/decisionserver-hellorules-1.4.0.Final.jar is a kjar
    ...
    INFO: org.openshift.quickstarts:decisionserver-hellorules:1.4.0.Final verified.
    
    
    Pushing image 172.30.202.111:5000/ds-bin-demo/ds-hr-app:latest ...
    Pushed 6/9 layers, 67% complete
    Pushed 7/9 layers, 78% complete
    Pushed 8/9 layers, 89% complete
    Pushed 9/9 layers, 100% complete
    Push successful
  6. Create a new OpenShift application based on the build.

    $ oc new-app ds-hr-app
    --> Found image c2c182e (48 seconds old) in image stream ds-hr-app under tag "latest" for "ds-hr-app"
    
        ds-bin-demo/ds-hr-app-2:ea504dd7
        --------------------------------
        Platform for executing business rules on JBoss BRMS Realtime Decision Server 6.3.
    
        Tags: builder, decisionserver, decisionserver6
    
        * This image will be deployed in deployment config "ds-hr-app"
        * Ports 8080/tcp, 8443/tcp, 8778/tcp will be load balanced by service "ds-hr-app"
          * Other containers can access this service through the hostname "ds-hr-app"
    
    --> Creating resources with label app=ds-hr-app ...
        deploymentconfig "ds-hr-app" created
        service "ds-hr-app" created
    --> Success
        Run 'oc status' to view your app.
  7. Expose the service as route.

    $ oc get svc -o name
    service/ds-hr-app
    $ oc expose svc/ds-hr-app
    route "ds-hr-app" exposed
  8. Access the application.

    You can get the list of available query string arguments of the hellorules application by accessing the URL http://ds-hr-app-ds-bin-demo.openshift.example.com/hellorules/.

    Run the hellorules-client servlet using the URL http://ds-hr-app-ds-bin-demo.openshift.example.com/hellorules?command=runLocal.

    Note

    You may verify the current KIE server state by accessing dedicated server/ page of the REST API: http://ds-hr-app-ds-bin-demo.openshift.example.com/kie-server/services/rest/server/. Use aforementioned user name and password to access this page (or any REST API method of the server in general).

6.3. Using a Modified Decision Server xPaaS Image

An alternative method is to make changes to the image, and then use that modified image in OpenShift. The templates currently provided, along with the interfaces they support, are listed below:

Table 6.2. Provided Templates

Template NameSupported Interfaces

decisionserver63-basic-s2i.json

http-rest, jms-hornetq

decisionserver63-https-s2i.json

http-rest, https-rest, jms-hornetq

decisionserver63-amq-s2i.json

http-rest, https-rest, jms-activemq

You can run Realtime Decision Server for OpenShift in Docker, make the required configuration changes using the JBoss EAP Management CLI (EAP_HOME/bin/jboss-cli.sh) included in Realtime Decision Server for OpenShift, and then commit the changed container as a new image. You can then use that modified image in OpenShift.

Important

It is recommended that you do not replace the OpenShift placeholders in the JBoss EAP xPaaS configuration file, as they are used to automatically configure services (such as messaging, datastores, HTTPS) during a container’s deployment. These configuration values are intended to be set using environment variables.

Note

Ensure that you follow the guidelines for creating images.