Chapter 2. Getting Started with Data Grid Operator
Data Grid Operator lets you create, configure, and manage Data Grid clusters.
Prerequisites
- Install Data Grid Operator.
-
Have an
oc
client.
2.1. Infinispan Custom Resource (CR)
Data Grid Operator adds a new Custom Resource (CR) of type Infinispan
that lets you handle Data Grid clusters as complex units on OpenShift.
Data Grid Operator watches for Infinispan
Custom Resources (CR) that you use to instantiate and configure Data Grid clusters and manage OpenShift resources, such as StatefulSets and Services. In this way, the Infinispan
CR is your primary interface to Data Grid on OpenShift.
The minimal Infinispan
CR is as follows:
apiVersion: infinispan.org/v1 1 kind: Infinispan 2 metadata: name: example-infinispan 3 spec: replicas: 2 4
2.2. Creating Data Grid Clusters
Use Data Grid Operator to create clusters of two or more Data Grid nodes.
Procedure
Specify the number of Data Grid nodes in the cluster with
spec.replicas
in yourInfinispan
CR.For example, create a
cr_minimal.yaml
file as follows:$ cat > cr_minimal.yaml<<EOF apiVersion: infinispan.org/v1 kind: Infinispan metadata: name: example-infinispan spec: replicas: 2 EOF
Apply your
Infinispan
CR.$ oc apply -f cr_minimal.yaml
Watch Data Grid Operator create the Data Grid nodes.
$ oc get pods -w NAME READY STATUS RESTARTS AGE example-infinispan-1 0/1 ContainerCreating 0 4s example-infinispan-2 0/1 ContainerCreating 0 4s example-infinispan-3 0/1 ContainerCreating 0 5s infinispan-operator-0 1/1 Running 0 3m example-infinispan-3 1/1 Running 0 8s example-infinispan-2 1/1 Running 0 8s example-infinispan-1 1/1 Running 0 8s
Next Steps
Try changing the value of replicas:
and watching Data Grid Operator scale the cluster up or down.
2.3. Verifying Data Grid Clusters
Review log messages to ensure that Data Grid nodes receive clustered views.
Procedure
Do either of the following:
Retrieve the cluster view from logs.
$ oc logs example-infinispan-0 | grep ISPN000094 INFO [org.infinispan.CLUSTER] (MSC service thread 1-2) \ ISPN000094: Received new cluster view for channel infinispan: \ [example-infinispan-0|0] (1) [example-infinispan-0] INFO [org.infinispan.CLUSTER] (jgroups-3,example-infinispan-0) \ ISPN000094: Received new cluster view for channel infinispan: \ [example-infinispan-0|1] (2) [example-infinispan-0, example-infinispan-1]
Retrieve the
Infinispan
CR for Data Grid Operator.$ oc get infinispan -o yaml
The response indicates that Data Grid pods have received clustered views:
conditions: - message: 'View: [example-infinispan-0, example-infinispan-1]' status: "True" type: wellFormed
Use oc wait
with the wellFormed
condition for automated scripts.
$ oc wait --for condition=wellFormed --timeout=240s infinispan/example-infinispan