Chapter 3. Configuring Clustering
The Data Grid for OpenShift images can use either the Kubernetes or DNS discovery mechanisms for clustering. These discovery mechanisms enable images to automatically join clusters.
By default, DNS is pre-configured in the Data Grid for OpenShift image templates. If you want to use Kubernetes as the discovery mechanism, or if you plan to build and deploy a custom image, you must configure cluster discovery.
JBoss Data Grid does not support removing images from an active cluster.
3.1. Configuring the Kubernetes Discovery Mechanism
To configure the Kubernetes discovery mechanism for clustering, do the following:
Set
openshift.KUBE_PINGas the value for theJGROUPS_PING_PROTOCOLenvironment variable.JGROUPS_PING_PROTOCOL=openshift.KUBE_PING
Specify the OpenShift project name as the value for the
OPENSHIFT_KUBE_PING_NAMESPACEenvironment variable. If you do not set this variable, the server behaves like a single-node cluster.OPENSHIFT_KUBE_PING_NAMESPACE=PROJECT_NAME
Specify the label that is set at the service level as the value for the
OPENSHIFT_KUBE_PING_LABELSenvironment variable. If you do not set this variable, pods outside the application but in the same namespace attempt to join.OPENSHIFT_KUBE_PING_LABELS=app=APP_NAME
Grant authorization to the service account the pod is running under so that it can access the Kubernetes REST API. You grant this authorization using the OpenShift CLI, as follows:
Granting authorization for 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)
Granting authorization for eap-service-account in the myproject namespace:
oc policy add-role-to-user view system:serviceaccount:$(oc project -q):eap-service-account -n $(oc project -q)
Ensure port
8888is defined as a ping port on the pod container, as follows:ports: - containerPort: 8888 name: ping protocol: TCP
3.2. Configuring the DNS Discovery Mechanism
To configure the DNS discovery mechanism for clustering, do the following:
Set
openshift.DNS_PINGas the value for theJGROUPS_PING_PROTOCOLenvironment variable.JGROUPS_PING_PROTOCOL=openshift.DNS_PING
Specify the name of the ping service for the cluster as the value for the
OPENSHIFT_DNS_PING_SERVICE_NAMEenvironment variable.OPENSHIFT_DNS_PING_SERVICE_NAME=PING_SERVICE_NAME
Specify the port number where the ping service is exposed as the value for the
OPENSHIFT_DNS_PING_SERVICE_PORTenvironment variable. The default value is8888.OPENSHIFT_DNS_PING_SERVICE_PORT=PING_PORT
Define a ping service that exposes the ping port, as in the following example:
apiVersion: v1 kind: Service spec: clusterIP: None ports: - name: ping port: 8888 protocol: TCP targetPort: 8888 selector: deploymentConfig=datagrid-app metadata: annotations: description: The JGroups ping port for clustering. service.alpha.kubernetes.io/tolerate-unready-endpoints: 'true'ImportantYou should configure
clusterIP: Noneso that the service is headless. Likewise, the ping port must be named and include theservice.alpha.kubernetes.io/tolerate-unready-endpoints: 'true'annotation.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.