Este conteúdo não está disponível no idioma selecionado.
Chapter 4. Creating Data Grid clusters
Create Data Grid clusters running on OpenShift with the Infinispan CR or with the native Data Grid CLI plugin for oc clients.
4.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 listens for Infinispan Custom Resources (CR) that you use to instantiate and configure Data Grid clusters and manage OpenShift resources, such as StatefulSets and Services.
Infinispan CR
| 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. |
|
| Specifies the type of Data Grid service to create. |
|
| Specifies the Data Grid Server version of your cluster. |
4.2. Creating Data Grid clusters Copiar o linkLink copiado para a área de transferência!
Create Data Grid clusters with the native CLI plugin, kubectl-infinispan.
Prerequisites
- Install Data Grid Operator.
-
Have
kubectl-infinispanon yourPATH.
Procedure
Run the
infinispan create clustercommand.For example, create a Data Grid cluster with two pods as follows:
oc infinispan create cluster --replicas=3 -Pservice.type=DataGrid infinispan
oc infinispan create cluster --replicas=3 -Pservice.type=DataGrid infinispanCopy to Clipboard Copied! Toggle word wrap Toggle overflow TipAdd the
--versionargument to control the Data Grid version of your cluster. For example,--version=8.4.6-1. If you don’t specify the version, Data Grid Operator creates cluster with the latest supported Data Grid version.Watch Data Grid Operator create the Data Grid pods.
oc get pods -w
oc get pods -wCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Next steps
After you create a Data Grid cluster, use the oc to apply changes to Infinispan CR and configure your Data Grid service.
You can also delete Data Grid clusters with kubectl-infinispan and re-create them as required.
oc infinispan delete cluster infinispan
oc infinispan delete cluster infinispan
Additional resources
4.3. Verifying Data Grid cluster views Copiar o linkLink copiado para a área de transferência!
Confirm that Data Grid pods have successfully formed clusters.
Prerequisites
- Create at least one Data Grid cluster.
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: [infinispan-0, infinispan-1]' status: "True" type: wellFormedconditions: - message: 'View: [infinispan-0, 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/infinispan
oc wait --for condition=wellFormed --timeout=240s infinispan/infinispan
Retrieving cluster view from logs
You can also get the cluster view from Data Grid logs as follows:
oc logs infinispan-0 | grep ISPN000094
oc logs infinispan-0 | grep ISPN000094
4.4. Modifying Data Grid clusters Copiar o linkLink copiado para a área de transferência!
Configure Data Grid clusters by providing Data Grid Operator with a custom Infinispan CR.
Prerequisites
- Install Data Grid Operator.
- Create at least one Data Grid cluster.
-
Have an
occlient.
Procedure
Create a YAML file that defines your
InfinispanCR.For example, create a
my_infinispan.yamlfile that changes the number of Data Grid pods to two:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Apply your
InfinispanCR.oc apply -f my_infinispan.yaml
oc apply -f my_infinispan.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Watch Data Grid Operator scale the Data Grid pods.
oc get pods -w
oc get pods -wCopy to Clipboard Copied! Toggle word wrap Toggle overflow
4.5. 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 infinispan -o=jsonpath='{.status.replicasWantedAtRestart}'oc get infinispan 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