Este conteúdo não está disponível no idioma selecionado.
Chapter 2. Getting started with Infinispan CR
After you install Data Grid Operator, learn how to create Data Grid clusters on OpenShift.
2.1. Infinispan custom resource (CR) Copiar o linkLink copiado para a área de transferência!
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:
| Field | Description |
|---|---|
|
|
Declares the version of the |
|
|
Declares the |
|
| Specifies a name for your Data Grid cluster. |
|
| Specifies the number of pods in your Data Grid cluster. |
2.2. Creating Data Grid clusters Copiar o linkLink copiado para a área de transferência!
Use Data Grid Operator to create clusters of two or more Data Grid pods.
Prerequisites
- Install Data Grid Operator.
-
Have an
occlient.
Procedure
Specify the number of Data Grid pods in the cluster with
spec.replicasin yourInfinispanCR.For example, create a
cr_minimal.yamlfile as follows:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Apply your
InfinispanCR.oc apply -f cr_minimal.yaml
$ oc apply -f cr_minimal.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Watch Data Grid Operator create the Data Grid pods.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
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 Copiar o linkLink copiado para a área de transferência!
Check that Data Grid pods have successfully formed clusters.
Procedure
Retrieve the
InfinispanCR for Data Grid Operator.oc get infinispan -o yaml
$ oc get infinispan -o yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow The response indicates that Data Grid pods have received clustered views, as in the following example:
conditions: - message: 'View: [example-infinispan-0, example-infinispan-1]' status: "True" type: wellFormedconditions: - message: 'View: [example-infinispan-0, example-infinispan-1]' status: "True" type: wellFormedCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Do the following for automated scripts:
oc wait --for condition=wellFormed --timeout=240s infinispan/example-infinispan
$ oc wait --for condition=wellFormed --timeout=240s infinispan/example-infinispan
Alternatively, you can retrieve cluster view from logs as follows:
2.4. Stopping and starting Data Grid clusters Copiar o linkLink copiado para a área de transferência!
Stop and start Data Grid pods in a graceful, ordered fashion to correctly preserve cluster state.
Clusters of Data Grid service pods must restart with the same number of pods that existed before shutdown. This allows Data Grid to restore the distribution of data across the cluster. After Data Grid Operator fully restarts the cluster you can safely add and remove pods.
Procedure
Change the
spec.replicasfield to0to stop the Data Grid cluster.spec: replicas: 0
spec: replicas: 0Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure you have the correct number of pods before you restart the cluster.
oc get infinispan example-infinispan -o=jsonpath='{.status.replicasWantedAtRestart}'$ oc get infinispan example-infinispan -o=jsonpath='{.status.replicasWantedAtRestart}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Change the
spec.replicasfield to the same number of pods to restart the Data Grid cluster.spec: replicas: 6
spec: replicas: 6Copy to Clipboard Copied! Toggle word wrap Toggle overflow