Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 3. Get Started
The Red Hat JBoss Data Grid images were automatically created during the installation of OpenShift along with the other default image streams and templates.
You can make changes to the JBoss Data Grid configuration in the image using either the S2I templates, or by using a modified JDG for OpenShift image.
3.1. Using the JDG for OpenShift image Source-to-Image (S2I) Process
The recommended method to run and configure the OpenShift JDG for OpenShift image is to use the OpenShift S2I process together with the application template parameters and environment variables.
The S2I process for the JDG for OpenShift image works as follows:
- 
						If there is a pom.xml file in the source repository, a Maven build is triggered with the contents of $MAVEN_ARGSenvironment variable.
- 
						By default the packagegoal is used with theopenshiftprofile, including the system properties for skipping tests (-DskipTests) and enabling the Red Hat GA repository (-Dcom.redhat.xpaas.repo.redhatga).
- The results of a successful Maven build are copied to JDG_HOME/standalone/deployments. This includes all JAR, WAR, and EAR files from the directory within the source repository specified by - $ARTIFACT_DIRenvironment variable. The default value of- $ARTIFACT_DIRis the target directory.- Any JAR, WAR, and EAR in the deployments source repository directory are copied to the JDG_HOME/standalone/deployments directory.
- All files in the configuration source repository directory are copied to JDG_HOME/standalone/configuration. Note- If you want to use a custom JBoss Data Grid configuration file, it should be named clustered-openshift.xml. 
 
- All files in the modules source repository directory are copied to JDG_HOME/modules.
Refer to the Artifact Repository Mirrors section for additional guidance on how to instruct the S2I process to utilize the custom Maven artifacts repository mirror.
3.1.1. Using a Different JDK Version in the JDG for OpenShift image
The JDG for OpenShift image may come with multiple versions of OpenJDK installed, but only one is the default. For example, the JDG for OpenShift image comes with OpenJDK 1.7 and 1.8 installed, but OpenJDK 1.8 is the default.
If you want the JDG for OpenShift image to use a different JDK version than the default, you must:
- Ensure that your pom.xml specifies to build your code using the intended JDK version.
- In the S2I application template, configure the image’s - JAVA_HOMEenvironment variable to point to the intended JDK version. For example:- { "name": "JAVA_HOME", "value": "/usr/lib/jvm/java-1.7.0" }- { "name": "JAVA_HOME", "value": "/usr/lib/jvm/java-1.7.0" }- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
3.2. Using a Modified JDG for OpenShift image
An alternative method is to make changes to the image, and then use that modified image in OpenShift.
The JBoss Data Grid configuration file that OpenShift uses inside the JDG for OpenShift image is JDG_HOME/standalone/configuration/clustered-openshift.xml, and the JBoss Data Grid startup script is JDG_HOME/bin/openshift-launch.sh.
You can run the JDG for OpenShift image in Docker, make the required configuration changes using the JBoss Data Grid Management CLI (JDG_HOME/bin/jboss-cli.sh), and then commit the changed container as a new image. You can then use that modified image in OpenShift.
It is recommended that you do not replace the OpenShift placeholders in the JDG for OpenShift image configuration file, as they are used to automatically configure services (such as messaging, datastores, HTTPS) during a container’s deployment. These configuration values are intended to be set using environment variables.
Ensure that you follow the guidelines for creating images.
3.3. Binary Builds
To deploy existing applications on OpenShift, you can use the binary source capability.
3.3.1. Deploy binary build of EAP 6.4 / EAP 7.0 Infinispan application together with JDG for OpenShift image
The following example uses CarMart quickstart to deploy EAP 6.4 / EAP 7.0 Infinispan application, accessing a remote JBoss Data Grid server running in the same OpenShift project.
Prerequisite:
- Create a new project. - oc new-project jdg-bin-demo - $ oc new-project jdg-bin-demo- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow Note- For brevity this example will not configure clustering. See dedicated section if data replication across the cluster is desired. 
Deploy JBoss Data Grid 6.5 server:
- Identify the image stream for the JBoss Data Grid 6.5 image. - oc get is -n openshift | grep grid | cut -d ' ' -f 1 - $ oc get is -n openshift | grep grid | cut -d ' ' -f 1 jboss-datagrid65-openshift- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Deploy the server. Also specify the following: - 
									carcacheas the name of application,
- A Hot Rod based connector, and
- carcacheas the name of the Infinispan cache to configure.- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 
- 
									
Deploy binary build of EAP 6.4 / EAP 7.0 CarMart application:
- Clone the source code. - git clone https://github.com/jboss-openshift/openshift-quickstarts.git - $ git clone https://github.com/jboss-openshift/openshift-quickstarts.git- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Configure the Red Hat JBoss Middleware Maven repository.
- Build the - datagrid/carmartapplication.- cd openshift-quickstarts/datagrid/carmart/ - $ cd openshift-quickstarts/datagrid/carmart/- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Prepare the directory structure on the local file system. - Application archives in the deployments/ subdirectory of the main binary build directory are copied directly to the standard deployments folder of the image being built on OpenShift. For the application to deploy, the directory hierarchy containing the web application data must be correctly structured. - Create main directory for the binary build on the local file system and deployments/ subdirectory within it. Copy the previously built WAR archive for the carmart quickstart to the deployments/ subdirectory: - ls - $ ls pom.xml README.md README-openshift.md README-tomcat.md src target- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - mkdir -p jdg-binary-demo/deployments - $ mkdir -p jdg-binary-demo/deployments- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - cp target/jboss-carmart.war jdg-binary-demo/deployments/ - $ cp target/jboss-carmart.war jdg-binary-demo/deployments/- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow Note- Location of the standard deployments directory depends on the underlying base image, that was used to deploy the application. See the following table: - Expand - Table 3.1. Standard Location of the Deployments Directory - Name of the Underlying Base Image(s) - Standard Location of the Deployments Directory - EAP for OpenShift 6.4 and 7.0 - $JBOSS_HOME/standalone/deployments - Java S2I for OpenShift - /deployments - JWS for OpenShift - $JWS_HOME/webapps 
- Identify the image stream for EAP 6.4 / EAP 7.0 image. - oc get is -n openshift | grep eap | cut -d ' ' -f 1 - $ oc get is -n openshift | grep eap | cut -d ' ' -f 1 jboss-eap64-openshift jboss-eap70-openshift- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Create new binary build, specifying image stream and application name. - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow Note- Specify - jboss-eap70-openshiftas the image stream name in the aforementioned command to use EAP 7.0 image for the application.
- Start the binary build. Instruct - ocexecutable to use main directory of the binary build we created in previous step as the directory containing binary input for the OpenShift build.- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Create a new OpenShift application based on the build. - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Expose the service as route. - oc get svc -o name - $ oc get svc -o name service/carcache service/eap-app- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - oc get route - $ oc get route No resources found.- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - oc expose svc/eap-app - $ oc expose svc/eap-app route "eap-app" exposed- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - oc get route - $ oc get route NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD eap-app eap-app-jdg-bin-demo.openshift.example.com eap-app 8080-tcp None- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Access the application. - Access the CarMart application in your browser using the URL http://eap-app-jdg-bin-demo.openshift.example.com/jboss-carmart. You can view / remove existing cars (Home tab), or add a new car (New car tab).