Chapter 3. Deploying an application to the server You can deploy your application on a JBoss EAP server running on bare metal or on OpenShift Container Platform. To deploy your application on a JBoss EAP server running on bare metal, follow this procedure: Deploying an application to a bare metal installation To deploy your application on a JBoss EAP server running on OpenShift Container Platform, follow these procedures: Preparing an application for deployment on OpenShift Container Platform Deploying an application to JBoss EAP on OpenShift with Helm 3.1. Deploying an application to a bare metal installation You can deploy an application to JBoss EAP by using the JBoss EAP deploy plug-in. Prerequisites You have created an application. For more information, see Creating a hello world servlet . JBoss EAP is running. Procedure Navigate to the application root directory. The application root directory contains the pom.xml configuration file. Add the following build configuration to the pom.xml configuration file in the <project> section to define the application archive filename. <build> ... <finalName>USD{project.artifactId}</finalName> 1 </build> 1 Set the name of the deployment to the project's artifact ID. Build and deploy the application by using the JBoss EAP deploy plug-in. Verification Navigate to the address http://localhost:8080/helloworld/ in a browser. You are redirected to http://localhost:8080/helloworld/HelloWorld and you get the following message: steps Testing an application deployed on JBoss EAP 3.2. Deploying an application to OpenShift Container Platform You can use the source-to-image (S2I) workflow to deploy your applications to JBoss EAP on OpenShift Container Platform. 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 server. 3.2.1. Preparing an application for deployment on OpenShift Container Platform OpenShift Container Platform uses application hosted on a Git repository. To deploy your application on OpenShift, you must first push your application to a Git repository. After that, you can use JBoss EAP helm chart to configure your application deployment. Prerequisites You have created an application. For more information, see Creating a Hello World servlet . You have created a Git repository. Procedure Move the application to your local Git repository, if it already is not in it. Define the following property in the pom.xml configuration file: <properties> ... <version.plugin.eap>1.0.0.Final-redhat-00013</version.plugin.eap> 1 </properties> 1 <version.plugin.eap> defines the version for JBoss EAP Maven plug-in. Add the JBoss EAP maven plugin to <pluginManagement> , in <build> section inside the <project> section. <project> ... <build> <pluginManagement> <plugins> ... <plugin> <groupId>org.jboss.eap.plugins</groupId> <artifactId>eap-maven-plugin</artifactId> <version>USD{version.plugin.eap}</version> </plugin> </plugins> </pluginManagement> </build> </project> Create a profile "openshift" in the pom.xml configuration file. This profile defines the plug-ins, feature packs, and layers required for deployment on OpenShift Container Platform. <profiles> <profile> <id>openshift</id> <build> <plugins> <plugin> <groupId>org.jboss.eap.plugins</groupId> <artifactId>eap-maven-plugin</artifactId> 1 <configuration> <channels> <channel> <manifest> <groupId>org.jboss.eap.channels</groupId> <artifactId>eap-8.0</artifactId> </manifest> </channel> </channels> <feature-packs> <feature-pack> 2 <location>org.jboss.eap:wildfly-ee-galleon-pack</location> </feature-pack> <feature-pack> <location>org.jboss.eap.cloud:eap-cloud-galleon-pack</location> </feature-pack> </feature-packs> <layers> 3 <layer>cloud-server</layer> </layers> <name>ROOT.war</name> 4 </configuration> <executions> <execution> <goals> <goal>package</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles> 1 wildfly-maven-plugin is a JBoss EAP plug-in for provisioning a JBoss EAP instance, with the application deployed, on OpenShift Container Platform. 2 feature-packs defines the feature-packs (zipped files that contains features to dynamically provision a server). In this case we need the feature-packs org.wildfly:wildfly-galleon-pack and org.wildfly.cloud:wildfly-cloud-galleon-pack . 3 layers defines the layers (from the configured feature-packs) to include in the provisioned server. Each layer identifies one or more server capabilities that can be installed on its own, or in combination with other layers. In our case we opt for the cloud-server layer, which provisions just the basic features of JBoss EAP, well suited for a cloud server. 4 <name>ROOT.war</name> : Defines the resulting name of the application's web archive (WAR). If ROOT.war is specified then the application is deployed at the root path of the server, otherwise it is deployed at <name/> relative path. Verify that the applications compiles. Push the changes to your repository. steps Deploying an application to JBoss EAP on OpenShift with Helm 3.2.2. Deploying an application to JBoss EAP on OpenShift with Helm Use the JBoss EAP Helm chart to configure and deploy application to JBoss EAP on OpenShift with Helm. Prerequisites You have prepared your application for deployment on OpenShift Container Platform. For more information, see Preparing an application for deployment on OpenShift Container Platform . You have created a project in OpenShift Container Platform. For more information see Working with projects . You have installed OpenShift CLI ( oc ) For more information, see Installing the OpenShift CLI . You are logged in to OpenShift Container Platform from your machine. For more information, see Logging in to the OpenShift CLI . You have installed helm. For more information, see Installing Helm . Procedure Create a directory called charts in the application root directoy and navigate to it. Application root directory is the one that contains pom.xml configuration file. Create a file helm.yaml with the following content: build: uri: https://github.com/ <user> / <repository> .git 1 ref: <branch_name> 2 contextDir: helloworld 3 deploy: replicas: 1 4 1 Specify the URL for your Git repository that contains the application to deploy on OpenShift Container Platform. 2 Specify the Git branch that contains your application. 3 Specify the directory containing the application. 4 Specify the number of pods to create. Configure the JBoss EAP repository in Helm. If you haven't added the JBoss EAP repository to Helm before, add it. If you already have added the JBoss EAP repository to Helm, update it. Deploy the application using helm. The deployment can take a few minutes to complete. Verification Get the URL of the route to the deployment. Navigate to the "Application URL" in a browser. You are redirected to the servlet at path "/HelloWorld" and you get the following message: steps Testing an application deployed on JBoss EAP

Commands:
<build> <finalName>USD{project.artifactId}</finalName> 1 </build>
mvn package wildfly:deploy
Hello World!
mv -r helloworld/ <your_git_repo>
<properties> <version.plugin.eap>1.0.0.Final-redhat-00013</version.plugin.eap> 1 </properties>
<project> <build> <pluginManagement> <plugins> <plugin> <groupId>org.jboss.eap.plugins</groupId> <artifactId>eap-maven-plugin</artifactId> <version>USD{version.plugin.eap}</version> </plugin> </plugins> </pluginManagement> </build> </project>
<profiles> <profile> <id>openshift</id> <build> <plugins> <plugin> <groupId>org.jboss.eap.plugins</groupId> <artifactId>eap-maven-plugin</artifactId> 1 <configuration> <channels> <channel> <manifest> <groupId>org.jboss.eap.channels</groupId> <artifactId>eap-8.0</artifactId> </manifest> </channel> </channels> <feature-packs> <feature-pack> 2 <location>org.jboss.eap:wildfly-ee-galleon-pack</location> </feature-pack> <feature-pack> <location>org.jboss.eap.cloud:eap-cloud-galleon-pack</location> </feature-pack> </feature-packs> <layers> 3 <layer>cloud-server</layer> </layers> <name>ROOT.war</name> 4 </configuration> <executions> <execution> <goals> <goal>package</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles>
mvn package -Popenshift
mkdir charts; cd charts
build: uri: https://github.com/ <user> / <repository> .git 1 ref: <branch_name> 2 contextDir: helloworld 3 deploy: replicas: 1 4
helm repo add jboss-eap https://jbossas.github.io/eap-charts/
helm repo update jboss-eap
helm install helloworld -f helm.yaml jboss-eap/eap8
APPLICATION_URL=https://USD(oc get route helloworld --template='{{ .spec.host }}') && echo "" && echo "Application URL: USDAPPLICATION_URL"
Hello World!