Chapter 8. Build and run microservices applications on the OpenShift image for JBoss EAP XP You can build and run your microservices applications on the OpenShift image for JBoss EAP XP. Note JBoss EAP XP is supported only on OpenShift 4 and later versions. Use the following workflow to build and run a microservices application on the OpenShift image for JBoss EAP XP by using the source-to-image (S2I) process. Note Default cloud-default-mp-config layer provide a standalone configuration file, which is based on the standalone-microprofile-ha.xml file. For more information about the server configuration files included in JBoss EAP XP, see the Standalone server configuration files section. This workflow uses the microprofile-config quickstart as an example. The quickstart provides a small, specific working example that can be used as a reference for your own project. See the microprofile-config quickstart that ships with JBoss EAP XP 5.0.0 for more information. Additional resources For more information about the server configuration files included in JBoss EAP XP, see Standalone server configuration files . 8.1. Preparing OpenShift for application deployment Prepare OpenShift for application deployment. Prerequisites You have installed an operational OpenShift instance. For more information, see the Installing and Configuring OpenShift Container Platform Clusters book on Red Hat Customer Portal . Procedure Log in to your OpenShift instance using the oc login command. Create a new project in OpenShift. A project allows a group of users to organize and manage content separately from other groups. You can create a project in OpenShift using the following command. For example, for the microprofile-config quickstart, create a new project named eap-demo using the following command. 8.2. Building and Deploying JBoss EAP XP Application Images using S2I Follow the source-to-image (S2I) workflow to build reproducible container images for a JBoss EAP XP application. These generated container images include the application deployment and ready-to-run JBoss EAP XP servers. The S2I workflow takes source code from a Git repository and injects it into a container that's based on the language and framework you want to use. After the S2I workflow is completed, the src code is compiled, the application is packaged and is deployed to the JBoss EAP XP server. Prerequisites You have an active Red Hat customer account. You have a Registry Service Account. Follow the instructions on the Red Hat Customer Portal to create an authentication token using a registry service account . You have downloaded the OpenShift secret YAML file, which you can use to pull images from Red Hat Ecosystem Catalog. For more information, see OpenShift Secret . You used the oc login command to log in to OpenShift. You have installed Helm. For more information, see Installing Helm . You have installed the repository for the JBoss EAP Helm charts by entering this command in the management CLI: Procedure Create a file named helm.yaml using the following YAML content: build: uri: https://github.com/jboss-developer/jboss-eap-quickstarts.git ref: XP_5.0.0.GA contextDir: microprofile-config mode: s2i deploy: replicas: 1 Use the following command to deploy your JBoss EAP XP application on Openshift. Note This procedure is very similar to Building application images using source-to-image in OpenShift . For more information about that procedure see Using JBoss EAP on OpenShift Container Platform . Verification Access the application using curl . You get the output MyPropertyFileConfigValue confirming that the application is deployed. 8.3. Completing post-deployment tasks for JBoss EAP XP source-to-image (S2I) application Depending on your application, you might need to complete some tasks after your OpenShift application has been built and deployed. Examples of post-deployment tasks include the following: Exposing a service so that the application is viewable from outside of OpenShift. Scaling your application to a specific number of replicas. Procedure Get the service name of your application using the following command. Optional : Expose the main service as a route so you can access your application from outside of OpenShift. For example, for the microprofile-config quickstart, use the following command to expose the required service and port. Get the URL of the route. Access the application in your web browser using the URL. The URL is the value of the HOST/PORT field from command's output. Note For JBoss EAP XP 5.0.0 GA distribution, the Microprofile Config quickstart does not reply to HTTPS GET requests to the application's root context. This enhancement is only available in the {JBossXPShortName101} GA distribution. For example, to interact with the Microprofile Config application, the URL might be http:// HOST_PORT_Value /config/value in your browser. If your application does not use the JBoss EAP root context, append the context of the application to the URL. For example, for the microprofile-config quickstart, the URL might be http:// HOST_PORT_VALUE /microprofile-config/ . Optionally, you can scale up the application instance by running the following command. This command increases the number of replicas to 3. For example, for the microprofile-config quickstart, use the following command to scale up the application. Additional Resources For more information about JBoss EAP XP Quickstarts, see the Use the Quickstarts section in the Using MicroProfile in JBoss EAP guide.

Commands:
oc new-project PROJECT_NAME
oc new-project eap-demo
helm repo add jboss-eap https://jbossas.github.io/eap-charts/
build: uri: https://github.com/jboss-developer/jboss-eap-quickstarts.git ref: XP_5.0.0.GA contextDir: microprofile-config mode: s2i deploy: replicas: 1
helm install microprofile-config -f helm.yaml jboss-eap/eap-xp5
curl https://USD(oc get route microprofile-config --template='{{ .spec.host }}')/config/value
oc get service
oc expose service/microprofile-config --port=8080
oc get route
oc scale deploymentconfig DEPLOYMENTCONFIG_NAME --replicas=3
oc scale deployment/microprofile-config --replicas=3