Red Hat xPaaS EAP Image
Guide to developing with the Red Hat Enterprise Application Platform Image
Legal Notice
Abstract
Chapter 1. Introduction to the xPaaS EAP Image
1.1. What is JBoss Enterprise Application Platform (EAP)?
Red Hat JBoss Enterprise Application Platform 7.0 (JBoss EAP 7) is an application server that works as a middleware platform, is built on open standards, and is compliant with the Java EE 7 specification.
It is based on Wildfly 10, and provides preconfigured options for features such as high-availability clustering, messaging, and distributed caching.
With JBoss EAP you can develop, deploy, and run applications using the various APIs and services that JBoss EAP provides. JBoss EAP includes a modular structure that allows you to enable services only when required, which results in improved startup speed. The web-based management console and management command line interface (CLI) make editing XML configuration files unnecessary and add the ability to script and automate tasks. In addition, JBoss EAP includes APIs and development frameworks for quickly developing secure and scalable Java EE applications. JBoss EAP 7 is a certified implementation of the Java EE 7 full and web profile specifications.
1.2. How Does JBoss EAP Work on OpenShift?
Red Hat offers a containerized xPaaS image for the Red Hat JBoss Enterprise Application Platform (JBoss EAP) that is designed for use with OpenShift. Using this image, developers can quickly and easily build, scale, and test applications that are deployed across hybrid environments.
1.3. Comparison: EAP and xPaaS EAP Image
There are some notable differences when comparing the JBoss EAP product with the available JBoss EAP xPaaS image. The following table describes these differences and notes which features are included or supported in the current version of the EAP xPaaS image.
Table 1.1. Differences between EAP and EAP xPaaS Image
| Feature | Status | Description |
|---|---|---|
| EAP Management Console | Not included | The EAP Management Console is not included in this release of EAP xPaaS image. |
| Domain mode | Not supported | Although domain mode is not supported, creation and distribution of applications are managed in the containers on OpenShift. |
| Default root page | Disabled | The default root page is disabled, but you can deploy your own application to the root context as ROOT.war. |
| Remote messaging | Supported | A-MQ for inter-pod and remote messaging is supported. HornetQ is only supported for intra-pod messaging and only enabled when A-MQ is absent. The EAP 7 xPaaS image includes Artemis as a replacement for HornetQ. |
1.4. Comparison: EAP 6.4 and xPaaS EAP 7.0 Image
Red Hat offers two xPaaS EAP images for use with OpenShift. The first is based on JBoss EAP 6.4 and the second is based on JBoss EAP 7. There are several differences between the two images:
JBoss Web is replaced by Undertow
- The xPaaS JBoss EAP 6.4 image uses JBoss Web.
- The xPaas JBoss EAP 7 image uses Undertow instead of JBoss Web. This change only affects users implementing custom JBoss Web Valves in their applications. Affected users must refer to the Red Hat JBoss EAP 7 documentation for details about migrating JBoss EAP Web Valve handlers.
HornetQ is replaced by Artemis
- The EAP 6.4 image only uses HornetQ for intra-pod messaging when A-MQ is absent.
-
The EAP 7 image uses Artemis instead of HornetQ. This change resulted in renaming the
HORNETQ_QUEUESandHORNETQ_TOPICSenvironment variables toMQ_QUEUESandMQ_TOPICSrespectively. For complete instructions to deal with migrating applications from JBoss EAP 6.4 to 7, see the JBoss EAP 7 Migration Guide.
1.5. Version Compatibility and Support
The xPaaS images for OpenShift are updated frequently. Therefore, it is important to understand which versions of the xPaaS images are compatible with which versions of OpenShift. Not all images are compatible with all OpenShift 3.x versions. Visit the Red Hat Customer Portal and see the OpenShift and Atomic Platform Tested Integrations page for more information on version compatibility and support.
Chapter 2. Installation and Configuration
2.1. Overview
Before installing the JBoss EAP xPaaS image on your OpenShift instance, you must first determine whether you are installing the EAP xPaaS image in a production or a non-production environment. Production environments require Secure Sockets Layer (SSL) encryption for network communication for general public access, which is also known as a HTTPS connection. In this case you must use a signed certificate from a Certificate Authority (CA).
However, if you are installing the EAP xPaaS image for demonstration purposes, proof-of-concept (POC) designs, or environments with internal access only, unencrypted and insecure communication may be sufficient. The instructions referenced here describe how to create the required keystore for the xPaaS EAP image with a self-signed or a purchased SSL certificate.
Using a self-signed SSL certificate to create a keystore is not intended for production environments. For production environments or where SSL encrypted communication is required, you must use a SSL certificate that is purchased from a verified CA.
2.2. Key Terms
The following table describes the various terms that are used within the context of this topic.
Table 2.1. Terminology used in this topic
| Key term | Description |
|---|---|
| SSL | Secure Sockets Layer encrypts network traffic between the client and the EAP web server, providing a HTTPS connection between them. |
| HTTPS | HTTPS is a protocol that provides an SSL-encrypted connection between a client and a server. |
| Keystore | A Java keystore is a repository to store SSL/TLS certificates and distribute them to applications for encrypted communication. |
| Secrets | A secret contains the Java keystore that gets passed to the EAP xPaaS image along with a password to access it. This then gets used in scripts to configure HTTPS access. |
2.3. Initial Setup
The instructions in this guide follow on from and assume an OpenShift instance similar to that created in the OpenShift Primer.
2.4. Getting Started
After you have completed the Section 2.3, “Initial Setup” instructions, this topic helps you get started with the JBoss xPaaS EAP image by performing the required preliminary steps before you can install the image on OpenShift. This process consists of the following steps:
- Step 1: Create project
- Step 2: Create service account
- Step 3: Create keystore from SSL certificate
- Step 4: Create secret from keystore
- Step 5: Add secret to service account
- Step 6: Create and deploy EAP application
The following instructions describe how to perform each step.
Step 1: Create a new project in OpenShift
A project allows a group of users to organize and manage content separately from other groups. Create a project in OpenShift with the following command.
$ oc create project <project-name>You can then make this new project to be the current project with the following command:
$ oc project <project-name>Step 2: Create an EAP service account in your project
Service accounts are API objects that exist within each project. Create a service account named eap-service-account in the OpenShift project that you created in step 1. For the EAP 7 image specify the service account name to be eap7-service-account.
$ oc create serviceaccount eap-service-account -n <project-name>After creating the service account, configure the access permissions for it with the following command, specifying the correct name depending on the EAP image version.
$ oc policy add-role-to-user view system:serviceaccount:$(oc project -q):eap-service-account -n $(oc project -q)
The service account that you create must be configured with the correct permissions with the ability to view pods in Kubernetes. This is required in order for clustering with the xPaaS EAP image to work. You can view the top of the log files to see whether the correct service account permissions have been configured.
Step 3: Create a keystore from SSL certificate
The xPaaS EAP image requires a keystore to be imported to properly install and configure the image on your OpenShift instance. Note that self-signed certificates do not provide secure communication and are intended for internal testing purposes.
For production environments Red Hat recommends that you use your own SSL certificate purchased from a verified Certificate Authority (CA) for SSL-encrypted connections (HTTPS).
See Generate a SSL Encryption Key and Certificate for more information on how to create a keystore with self-signed or purchased SSL certificates.
Step 4: Create a secret from the keystore
Next, create a secret from the keystore that you created in step 1 with the following command.
$ oc secret new <secret-name> <keystore-filename>.jks
Step 5: Add the secret to your service account
Now add the secret created in step 3 to the eap-service-account that was created in step 2. You can do this with the following command.
$ oc secrets add serviceaccount/eap-service-account secret/<secret-name>Step 6: Create and deploy the EAP application
You can now create an EAP application using the defined image, or you can use the basic S2I template.
To create an EAP application using the defined image, run the following command.
$ oc new-app <jboss-eap-7/eap70-openshift>Alternatively, you can create an EAP application using the basic S2I template with the following command.
$ oc new-app <eap7-basic-s2i>2.5. Configuring the xPaaS EAP Image
The recommended method to run and configure the xPaaS JBoss EAP image is to use the OpenShift S2I process together with the application template parameters and environment variables.
The variable EAP_HOME is used to denote the path to the JBoss EAP installation. Replace this variable with the actual path to your JBoss EAP installation.
The S2I process for the xPaaS JBoss EAP image works as follows:
-
If a pom.xml file is present in the source repository, a Maven build process is triggered that uses the contents of the
$MAVEN_ARGSenvironment variable. Although you can specify arguments or options with the$MAVEN_ARGSenvironment variable, Red Hat recommends that you use the$MAVEN_ARGS_APPENDenvironment variable to do this. The$MAVEN_ARGS_APPENDvariable takes the default arguments from$MAVEN_ARGSand appends the options from$MAVEN_ARGS_APPENDto it. By default, the OpenShift profile uses the Maven package goal which includes system properties for skipping tests (-DskipTests) and enabling the Red Hat GA repository (-Dcom.redhat.xpaas.repo). The results of a successful Maven build are copied toEAP_HOME/standalone/deployments. This includes all JAR, WAR, and EAR files from the source repository specified by the$ARTIFACT_DIRenvironment variable. The default value of$ARTIFACT_DIRis the target directory. -
EAP_HOME/standalone/deployments is the artifacts directory, which is specified with the
$ARTIFACT_DIRenvironment variable. - All files in the configuration source repository directory are copied to EAP_HOME/standalone/configuration. If you want to use a custom JBoss EAP configuration file, it should be named standalone-openshift.xml.
- All files in the modules source repository directory are copied to EAP_HOME/modules.
Chapter 3. Reference Information
The content in this section is derived from the engineering documentation for this image. It is provided for reference as it can be useful for development purposes, and for testing beyond the scope of the product documentation
3.1. Datasources
Datasources are automatically created based on the value of some environment variables.
The most important is the DB_SERVICE_PREFIX_MAPPING environment variable that defines JNDI mappings for data sources. This variable must be set to a comma-separated list of <name>-<database_type>=<PREFIX> triplets, where name is used as the pool-name in the data source, database_type determines what database driver to use, and PREFIX is the prefix used in the names of environment variables, which are used to configure the data source.
3.1.1. JNDI mappings for datasources
For each <name>-<database_type>=PREFIX triplet in the DB_SERVICE_PREFIX_MAPPING environment variable, a separate datasource will be created by the launch script, which is executed when running the image.
The first part (before the equal sign) of the DB_SERVICE_PREFIX_MAPPING should be lowercase.
The <database_type> will determine the driver for the datasource. Currently, only postgresql and mysql are supported.
When chosing a name for the <name> parameter, do not use any special characters.
3.1.1.1. Database drivers
Every image contains Java drivers for MySQL, PostgreSQL and MongoDB databases deployed. Datasources are generated only for MySQL and PostgreSQL databases.
For MongoDB database there are no JNDI mappings created because this is not a SQL database.
3.1.1.2. Datasource configuration environment variables
Other datasource properties will be configured from the following environment variables:
| Variable name | Description | Example value |
|---|---|---|
|
|
Defines the database server’s hostname or IP to be used in the datasource’s |
|
|
| Defines the database server’s port for the datasource. |
|
|
|
Defines the JNDI name for the datasource. Defaults to |
|
|
| Defines the username for the datasource. |
|
|
| Defines the password for the datasource. |
|
|
| Defines the database name for the datasource. |
|
|
| Defines the java.sql.Connection transaction isolation level for the datasource. |
|
|
| Defines the minimum pool size option for the datasource. |
|
|
| Defines the maximum pool size option for the datasource. |
|
When running this image in OpenShift, the <NAME>_<DATABASE_TYPE>_SERVICE_HOST and <NAME>_<DATABASE_TYPE>_SERVICE_PORT environment variables are set up automatically from the database service definition in the OpenShift application template, while the others are configured in the template directly (as env entries in container definitions under each pod template).
3.1.1.3. Examples
These examples show how value of the DB_SERVICE_PREFIX_MAPPING environment variable influences datasource creation.
3.1.1.3.1. Single mapping
Consider value test-postgresql=TEST.
This will create a datasource with java:jboss/datasources/test_postgresql name. Additionally all the required settings like password and username will be expected to be provided as env variables with the TEST_ prefix, for example TEST_USERNAME and TEST_PASSWORD.
3.1.1.3.2. Multiple mappings
You can also specify multiple database mappings. Consider following value for the DB_SERVICE_PREFIX_MAPPING environment variable: cloud-postgresql=CLOUD,test-mysql=TEST_MYSQL.
Multiple datasource mappings should be separated with comma.
This will create two datasources:
-
java:jboss/datasources/test_mysql, and -
java:jboss/datasources/cloud_postgresql.
MySQL datasource configuration (username, etc) will be expected with the TEST_MYSQL prefix, for example TEST_MYSQL_USERNAME, whereas for the PostgreSQL datasource it’ll expect beexpected with the CLOUD_ prefix, for example CLOUD_USERNAME.
3.2. Clustering
Clustering is achieved through one of two discovery mechanisms: Kubernetes or DNS. This is done by configuring the JGroups protocol stack in standalone-openshift.xml with either the <openshift.KUBE_PING/> or <openshift.DNS_PING/> elements. Out of the box, KUBE_PING is the pre-configured and supported protocol.
For KUBE_PING to work, however, the following steps must be taken:
The
OPENSHIFT_KUBE_PING_NAMESPACEenvironment variable must be set. If not set, the server will behave as a single-node cluster (a "cluster of one").
For example:OPENSHIFT_KUBE_PING_NAMESPACE=<project_name>The
OPENSHIFT_KUBE_PING_LABELSenvironment variables should be set. If not set, pods outside of your application (albeit in your namespace) will try to join.
For example:OPENSHIFT_KUBE_PING_LABELS=application=<app_name>Authorization must be granted to the service account the pod is running under to be allowed to access Kubernetes' REST api. This is done on the command line.
For example:
Using the default service account in the myproject namespace:oc policy add-role-to-user view system:serviceaccount:$(oc project -q):default -n $(oc project -q)
Using the eap-service-account in the project namespace:
oc policy add-role-to-user view system:serviceaccount:$(oc project -q):eap-service-account -n $(oc project -q)
NoteSee Section 2.4, “Getting Started” for more information on adding policies to service accounts.
3.3. Security Domains
To configure a new Security Domain, the user must define the SECDOMAIN_NAME environment variable.
This will result in the creation of a security domain named after the environment variable. The user may also define the following environment variables to customize the domain:
| Variable name | Description | Example value |
|---|---|---|
|
| Define in order to enable the definition of an additional security domain. |
|
|
| If defined, the password-stacking module option is enabled and set to the value useFirstPass. |
|
|
|
The login module to be used. |
|
|
|
The name of the properties file containing user definitions. |
|
|
|
The name of the properties file containing role definitions. |
|
3.4. HTTPS
3.4.1. Environment variables
| Variable name | Description | Example value |
|---|---|---|
|
|
If defined along with |
|
|
|
If defined along with |
|
|
|
If defined along with |
|
3.5. Administration
3.5.1. Environment Variables
| Variable name | Description | Example value |
|---|---|---|
|
|
If both this and |
|
|
| If defined, an admin user is defined for accessing the management port, with this value as password. |
|
3.6. S2I
The image includes S2I scripts and maven.
Maven is currently only supported as a build tool for applications that are supposed to be deployed on JBoss EAP-based containers (or related/descendant images) on OpenShift.
Currently WAR, EAR, and JAR deployments are supported.
3.6.1. Custom configuration
It is possible to add custom configuration files for the image. All files put into configuration/ directory will be copied into $JBOSS_HOME/standalone/configuration/. For example to override the default configuration used in the image, just add a custom standalone-openshift.xml into the configuration/ directory.
3.6.1.1. Custom modules
It is possible to add custom modules. All files from the modules/ directory will be copied into $JBOSS_HOME/modules/.
3.6.2. Deployment Artifacts
By default, artifacts from the source target directory will be deployed. To deploy from different directories set the ARTIFACT_DIR environment variable in the BuildConfig definition. ARTIFACT_DIR is a comma-delimited list. For example: ARTIFACT_DIR=app1/target,app2/target,app3/target
3.6.3. Scripts
run- this script uses the launch.sh script that configures and starts EAP with the standalone-openshift.xml configuration.
assemble-
uses Maven to build the source, create a package (war) and move it to the
$JBOSS_HOME/standalone/deploymentsdirectory.
3.6.4. Environment variables
You can influence the way the build is executed by supplying environment variables to the s2i build command. The environment variables that can be supplied are:
| Variable name | Description | Example value |
|---|---|---|
|
|
|
|
|
| Hostname or IP address of a HTTP proxy for Maven to use. |
|
|
| TCP Port of a HTTP proxy for Maven to use. |
|
|
|
If supplied with | myusername |
|
|
If supplied with | mypassword |
|
| If supplied, a configured HTTP proxy will ignore these hosts. |
|
|
| Overrides the arguments supplied to maven during build. |
|
|
| Appends user arguments supplied to maven during build. |
|
|
| URL of a Maven Mirror/repository manager to configure. |
|
|
| Optionally clear the local maven repository after the build. |
|
|
| If defined, directory in the source from where data files are copied. |
|
|
|
Directory in the image where data from |
|
3.7. SSO
This image contains support for Red Hat SSO-enabled applications.
See Red Hat xPaaS SSO Image documentation for more information on how to deploy the xPaaS SSO image with the EAP image.
3.7.1. Environment variables
| Variable name | Description | Example value | Default value |
|---|---|---|---|
|
| URI of the SSO server | - | - |
|
| SSO realm for the deployed application(s) | - | - |
|
| Public key of the SSO Realm. This field is optional but if omitted can leave the applications vulnerable to man-in-middle attacks | - | - |
|
| SSO User required to access the SSO REST API |
| - |
|
|
Password for |
| - |
|
| Keystore location for SAML | - |
|
|
| Keystore password for SAML | - |
|
|
| Alias for keys/certificate to use for SAML | - |
|
|
| Optional. SSO Client Access Type | true | - |
|
| Path for SSO redirects back to the application | Defaults to match module-name | - |
|
| Optionally enable CORS for SSO applications | true | - |
|
| The SSO Client Secret for Confidential Access | KZ1QyIq4 | - |
|
| If true SSL communication between EAP and the SSO Server will be secure (i.e. certificate validation is enabled with curl) | false | - |
