What are the options to use a custom runtime JBoss EAP 7 configurations in OCP

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7.x
  • Red hat OpenShift Container Platform (OCP)
    • 4.x

Issue

How to customize a standalone-openshift.xml
How to add the UFC protocol on the jgroups stack on EAP image?

Resolution

Options to customize standalone-openshift.xml (and its behavior):

OptionProConRuntime
Change JVM property via DC's via JAVA_OPTS_APPENDeasy to setcan only change JVM propertiesCan be done in runtime (restart of the pod will be done)
changes via config map: actions.cli and postconfigure.shvery simple: just need the cli commandRed Hat is maintaining the standalone-configuration and the user has to updates/adds only what they want to add to the default configurationCan be done in runtime
overwrite standalone-openshift in /standalone/configone and done (apply on the custom image)In that case, the default standalone-openshift.xml is not used and it is up to the user to keep its custom configuration in sync with default configuration (in addition to their own changes)no, another image must be provisioned
S2I build were EAP_HOME/standalone/configuration - create a file standalone-openshift.xmlOne and done (apply on the custom image)Need to do a S2I process and deploymentno, another image must be provisioned
Using LOGGER_CATEGORIES - described on EAP 7 logging mechanism and customization in OCP 4Can be used at runtime, no need for postconfig.sh/actions.cliNeed to be set at deployment (dc or deployment) levelCan be used at runtime:yes, e.g. oc set env dc/eap-app LOGGER_CATEGORIES=org.jgroups.protocols.DNS_PING:TRACE - requires pod restart

Example 1: Adding a property via JAVA_OPTS_APPEND

For example, adding a certain JVM property that can be done via JAVA_OPTS_APPEND:

### set the environment variable JAVA_OPTS_APPEND
$ oc set env dc/eap-app JAVA_OPTS_APPEND=-Dflag=example
### get the environment variable:
$ oc get dc/eap-app -o yaml | grep -A2 JAVA_OPTS_APPEND
        - name: JAVA_OPTS_APPEND
          value: -Dflag=example

Example 2: Adding UFC protocol on the default EAP image

Via config-map (actions.cli + postconfigure.sh):

$ cat actions.cli

embed-server --std-out=echo --admin-only --server-config=standalone-openshift.xml 
/subsystem=jgroups/stack=tcp/protocol=UFC:add(add-index=10)
stop-embedded-server

$ cat postconfigure.sh

$JBOSS_HOME/bin/jboss-cli.sh --file=$JBOSS_HOME/extensions/actions.cli

Do the following to create the config-map:

oc create configmap jboss-cli --from-file=postconfigure.sh=postconfigure.sh --from-file=actions.cli=actions.cli
oc set volume dc/eap-app --add --name=jboss-cli -m /opt/eap/extensions -t configmap --configmap-name=jboss-cli --default-mode='0777' --overwrite

There are two commands above:
The first creates the configmap called jboss-cli; And the second one just sets the volume in the deployment. The second command does not complain about a cm that is not there.

Given the files: actions.cli and postconfigure.sh above, this can be set in a Dockerfile and an image provisioned from it, this is described on Running JBoss CLI commands on extended JBoss EAP 7 OpenShift Image.

Root Cause

This article describes runtime alternatives, for build time see the solution What are the options to execute CLI commands at build time in JBoss EAP 7 in OCP images that provides alternatives for executing CLI commands at build time, such as replace the default standalone-openshift.xml file inside /opt/eap/standalone/configuration also can be used to declare environment variables via docker set ENV EXAMPLE=/opt/eap/.

Note: as described on the solution Customizing standalone-openshift.xml, currently EAP images are not supported on podman/docker.

Diagnostic Steps

  1. To confirm the config is created: $ oc get cm - example:
$ oc get cm | grep jboss-cli
NAME                                   DATA   AGE
jboss-cli                              2      23m
  1. To confirm the volume is properly created - oc exec $podname on the pod and verify:
$ oc exec $podname -- ls /opt/eap/
LICENSE.txt
bin
docs
extensions <------------------------------------------------------
jboss-modules.jar
modules
standalone
  1. In case the configMap is properly created, and the volume is applied but the pods didn't get update yet (meaning the user cannot access /eap/opt/extensions) verify the ReplicationControllers (or ReplicaSet for deployment yaml deployment).
Method of deploymentMethod of control
Deployment ConfigReplicationControllers
DeploymentReplica Set
Components

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.