Chapter 9. Deploying JBoss Data Grid for OpenShift with Custom Configuration Files
You can use the OpenShift ConfigMap
API to create a deployment that uses custom configuration instead of using the source-to-image (S2I) build process.
-
Changes to the configuration via
ConfigMap
do not cause pods to redeploy automatically. You must manually redeploy pods if you updatestandalone.xml
. -
JBoss Data Grid for OpenShift deployments that you create with custom configuration files do not support shared persistent volumes that you configure with the
DATAGRID_SPLIT
environment variable.
9.1. Setting Up the Configuration Files and Custom Template
Create a ConfigMap that contains your configuration files and mount it to a specific directory as follows:
Mount your configuration files, the ConfigMap content, in the following directory:
/opt/datagrid/standalone/configuration/user
At a minimum, this directory must contain
standalone.xml
to configure JBoss Data Grid. This directory can also containlogging.properties
,application-role.properties
, and other properties files that are available with the JBoss Data Grid distribution.Note the following requirements for your custom configuration:
-
You must explicitly define all cache and endpoint configuration in
standalone.xml
. You cannot use environment variables to configure caches or endpoints after you create a deployment. Your cache container must be named
clustered
so that the default ReadinessProbe works.<cache-container name="clustered"> ... </cache-container>
-
To encrypt client to server traffic, you must configure the server identity in
standalone.xml
. You cannot use environment variables to configure HTTPS after you create a deployment.
-
You must explicitly define all cache and endpoint configuration in
Create a custom template for your JBoss Data Grid for OpenShift deployment.
- Ensure that the template exposes the required ports and services.
-
Set the
USER_CONFIG_MAP
environment variable to a value oftrue
.
Add placeholders to your custom standalone.xml
if you want to make environment variables available in your deployment.
For example, the following is a placeholder for the JGROUPS_PING_PROTOCOL
:
<!-- ##JGROUPS_PING_PROTOCOL## -->
Refer to clustered-openshift.xml to review the default XML file for JBoss Data Grid for OpenShift. This file contains all the available placeholders.
You can find examples for deployments with custom configuration in the following files:
9.2. Creating Deployments with Custom Configuration
To deploy JBoss Data Grid for OpenShift with a custom configuration, do the following:
On your master host(s), log in as a cluster administrator or a user with project administrator access to the
openshift
namespace.$ oc login -u system:admin
Import your custom template into the
openshift
namespace.$ oc create -n openshift -f path/to/template.yaml
Create a ConfigMap from the directory where your custom configuration resides.
To create a ConfigMap with
standalone.xml
only, do the following:$ oc create configmap datagrid-config --from-file=./standalone.xml
To create a ConfigMap with
standalone.xml
and other configuration files, do the following:$ oc create configmap datagrid-config \ --from-file=path/to/configuration
Where
path/to/configuration
is the local directory that contains the configuration files.The ConfigMap name should match the name that you specify in your custom template. The example template uses the name
datagrid-config
.
Deploy JBoss Data Grid for OpenShift with your custom configuration.
$ oc new-app user-config
The application name should match the name that you specify in your custom template. The example template uses the name
user-config
.When you deploy JBoss Data Grid for OpenShift, the configuration files are copied to the
/opt/datagrid/standalone/configuration
directory for the application.