What are the options to use a custom runtime JBoss EAP 7 configurations in OCP
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):
| Option | Pro | Con | Runtime |
|---|---|---|---|
Change JVM property via DC's via JAVA_OPTS_APPEND | easy to set | can only change JVM properties | Can be done in runtime (restart of the pod will be done) |
| changes via config map: actions.cli and postconfigure.sh | very simple: just need the cli command | Red Hat is maintaining the standalone-configuration and the user has to updates/adds only what they want to add to the default configuration | Can be done in runtime |
| overwrite standalone-openshift in /standalone/config | one 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.xml | One and done (apply on the custom image) | Need to do a S2I process and deployment | no, another image must be provisioned |
| Using LOGGER_CATEGORIES - described on EAP 7 logging mechanism and customization in OCP 4 | Can be used at runtime, no need for postconfig.sh/actions.cli | Need to be set at deployment (dc or deployment) level | Can 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
- To confirm the config is created:
$ oc get cm- example:
$ oc get cm | grep jboss-cli
NAME DATA AGE
jboss-cli 2 23m
- 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
- 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 theReplicationControllers(orReplicaSetfor deployment yaml deployment).
| Method of deployment | Method of control |
|---|---|
| Deployment Config | ReplicationControllers |
| Deployment | Replica Set |
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.