Chapter 2. Getting Started with Data Grid Operator

Data Grid Operator lets you create, configure, and manage Data Grid clusters.

Prerequisites

  • Create a Data Grid Operator subscription.
  • 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.

You configure Data Grid clusters running on OpenShift by modifying the Infinispan CR.

The minimal Infinispan CR for Data Grid clusters is as follows:

apiVersion: infinispan.org/v1
kind: Infinispan
metadata:
  name: 1
spec:
  replicas: 2
1
Names the Data Grid cluster.
2
Sets the number of nodes in the Data Grid cluster.

2.2. Creating Data Grid Clusters

Use Data Grid Operator to create clusters of two or more Data Grid nodes.

Procedure

  1. Specify the number of Data Grid nodes in the cluster with spec.replicas in your Infinispan 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-rhdatagrid
    spec:
      replicas: 2
    EOF
  2. Apply your Infinispan CR.

    $ oc apply -f cr_minimal.yaml
  3. Watch Data Grid Operator create the Data Grid nodes.

    $ oc get pods -w
    
    NAME                        READY  STATUS              RESTARTS   AGE
    example-rhdatagrid-1        0/1    ContainerCreating   0          4s
    example-rhdatagrid-2        0/1    ContainerCreating   0          4s
    example-rhdatagrid-3        0/1    ContainerCreating   0          5s
    infinispan-operator-0       1/1    Running             0          3m
    example-rhdatagrid-3        1/1    Running             0          8s
    example-rhdatagrid-2        1/1    Running             0          8s
    example-rhdatagrid-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-rhdatagrid-0 | grep ISPN000094
      
      INFO  [org.infinispan.CLUSTER] (MSC service thread 1-2) \
      ISPN000094: Received new cluster view for channel infinispan: \
      [example-rhdatagrid-0|0] (1) [example-rhdatagrid-0]
      
      INFO  [org.infinispan.CLUSTER] (jgroups-3,{example_crd_name-0) \
      ISPN000094: Received new cluster view for channel infinispan: \
      [example-rhdatagrid-0|1] (2) [example-rhdatagrid-0, example-rhdatagrid-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-rhdatagrid-0, example-rhdatagrid-1]'
            status: "True"
            type: wellFormed
Tip

Use oc wait with the wellFormed condition for automated scripts.

$ oc wait --for condition=wellFormed --timeout=240s infinispan/example-rhdatagrid