Deploying JBoss EAP applications on OpenShift

Red Hat provides a container image for JBoss Enterprise Application Platform (JBoss EAP) that is specifically designed for use with OpenShift. In this tutorial we will learn how to pull the image from the registry and use it to deploy an application on OpenShift using S2I.

There are several strategies you can use to create an EAP application: in this example we will show how to use OpenShift Templates. First off, let’s create an openshift project for our example:

oc new-project eap-demo

Next, in order to use Red Hat images on OpenShift you need to access one of its Registries. The recommended registry to use is “registry.redhat.io” which requires authentication using your Red Hat Portal login. To verify that you are capable of authentication, you can log-in to the Registry using either docker or podman (Check this tutorial for an overview of Podman: Getting started with Podman)

docker login registry.redhat.io
Username: username
Password: password

Login Succeeded!

Then, for environments where credentials will be shared, such as deployment systems, it is recommended to create a secret with a Service Account Tokens. A Service Account can be created at the following link: https://access.redhat.com/terms-based-registry/

Click on “New Service Account” and fill the Service account name:

 

Next, download it and execute it:

oc create -f 6340056_eapdemo_account.yaml

The secret will be added to your project. Now, you should be able to import the eap73-openjdk11-openshift-rhel8 image:

oc import-image jboss-eap-7/eap73-openjdk11-openshift-rhel8 --from=registry.redhat.io/jboss-eap-7/eap73-openjdk11-openshift-rhel8 --confirm

The above command should complete with the following output:

imagestream.image.openshift.io/eap73-openjdk11-openshift-rhel8 imported

Let’s now import the EAP 7.3 basic Template and the eap73-openjdk11 ImageStream in our project, so that we can use it to instantiate our application:

oc replace --force   -f https://raw.githubusercontent.com/jboss-container-images/jboss-eap-openshift-templates/eap73/templates/eap73-basic-s2i.json

oc replace --force   -f https://raw.githubusercontent.com/jboss-container-images/jboss-eap-7-openshift-image/7.3.x/templates/eap73-openjdk11-image-stream.json

Great, now we will add an example application to our project. The application is the well-known kitchensink app, available in the EAP Quickstarts. You can create it as follows:

oc new-app --template=eap73-basic-s2i \
 -p IMAGE_STREAM_NAMESPACE=eap-demo \
 -p SOURCE_REPOSITORY_URL=https://github.com/jboss-developer/jboss-eap-quickstarts \
 -p SOURCE_REPOSITORY_REF=7.3.x-openshift \
 -p CONTEXT_DIR=kitchensink

Verify that the Pod comes up:

oc get pods
NAME                              READY   STATUS      RESTARTS   AGE
eap-app-1-deploy                  0/1     Completed   0          107m
eap-app-1-zjj2k                   1/1     Running     0          106m
eap-app-2-build                   0/1     Completed   0          110m
eap-app-build-artifacts-1-build   0/1     Completed   0          116m

The Route to access the application shuld be available as well:

oc get routes
NAME      HOST/PORT                           PATH   SERVICES   PORT    TERMINATION     WILDCARD
eap-app   eap-app-eap-demo.apps-crc.testing          eap-app    <all>   edge/Redirect   None

You can reach the application at: eap-app-eap-demo.apps-crc.testing

Great. We just managed to create an EAP 7.3 application on OpenShift, authenticating on registry.redhat.io through Service Account Tokens.