How to deploy an application in JBoss EAP 7 in OCP 4
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 7.x
- Red hat OpenShift Container Platform (OCP)
- 4.x
Issue
How to deploy an application in JBoss EAP 7 in OCP 4
Resolution
Assuming one has a valid OCP 4 cluster, the following possibilities can be done to deploy an application.
There are four possibilities: deploy together (inside the image), import to inside the pod (ephemeral), source-to-image (S2-image), and SOURCE_REPOSITORY (directly set on the OCP).
1. deploy together (inside the image):
Create a dockerfile with the deployment - this can be done via BuildConfig in OCP 4 directly:
FROM registry.redhat.io/jboss-eap-7/eap74-openjdk8-openshift-rhel7:7.4.4-2.1652304391
COPY version.txt /opt/eap/version.txt
COPY test_app/ServletExamples.war /deployments <---- ServletExample.war application
One can create a source to image makefile with podman, and export the image (via Quay).
2. Import to inside the pod (ephemeral - unless persisted via CM):
Send to the pod, which will be ephemeral (meaning it will vanish on restart of the pod):
oc cp ServletExamples.war eap-pod-example-0:/deployments
Confirm the deployment:
$ oc exec -it eap-pod-example-0 -- ls -lrt /deployments
total 15640
-rw-rw-r--. 1 185 root 11932865 May 11 19:34 activemq-rar.rar
-rw-r--r--. 1 jboss root 19 May 19 17:59 ServletExamples.war.deployed
-rw-r--r--. 1 jboss root 2115841 May 19 17:59 ServletExamples.war
In this case, the default/original EAP image can be installed via the EAP Operator.
3. source-to-image (S2I image)
Using the EAP 7 templates can be used for S2I build via the BuildConfig passing Gitsource or jar directly.
The main solution for EAP 7 thin images is: JBoss EAP 7 thin image, see related solutions:
- JBoss EAP S2I build template options
- Troubleshooting EAP 7 local BuildConfig in OCP 4
- Customizing EAP 7 Template buildconfig deployment in OCP 4
4. BuildConfig via SOURCE_REPOSITORY (directly set on the OCP)
Inside the OCP 4 there is a feature to build an application from the git source, which is set via Custom builder image's environment variable SOURCE_REPOSITORY. That's a creation/deployment of an application directly as Image/ImageStream as described on OCP 4.13 - Creating New Applications.
It would be possible to create an application and then inject on the EAP image directly via Buildconfig
Final Configuration CONFIG_IS_FINAL [note]
As explained on EAP 7/8 CONFIG_IS_FINAL on Galleon Build for image building, when deploying in OCP the EAP 7 images will be modified according to the initial scripts for clustering for example where the default EAP image is clustered. So specifically for disable clustering, the discovery protocol LOCAL_PING can be used instead of KUBE_PING; to do so without incurring overwriting by the scripts - set the environment variable CONFIG_IS_FINAL. See below:
spec:
replicas: 2
env:
- name: CONFIG_IS_FINAL
value: true
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.