Este conteúdo não está disponível no idioma selecionado.
Chapter 7. Setting up Data Grid services
Use Data Grid Operator to create clusters of either Cache service or Data Grid service pods.
7.1. Service types Copiar o linkLink copiado para a área de transferência!
Services are stateful applications, based on the Data Grid Server image, that provide flexible and robust in-memory data storage. When you create Data Grid clusters you specify either DataGrid or Cache as the service type with the spec.service.type field.
DataGridservice type- Deploy Data Grid clusters with full configuration and capabilities.
Cacheservice type- Deploy Data Grid clusters with minimal configuration.
Red Hat recommends the DataGrid service type for clusters because it lets you:
- Back up data across global clusters with cross-site replication.
- Create caches with any valid configuration.
- Add file-based cache stores to save data in a persistent volume.
- Query values across caches using the Data Grid Query API.
- Use advanced Data Grid features and capabilities.
The Cache service type was designed to provide a convenient way to create a low-latency data store with minimal configuration. Additional development on the Infinispan CRD has shown that the DataGrid CR offers a better approach to achieving this goal, ultimately giving users more choice and less deployment overhead. For this reason, the Cache service type is planned for removal in the next version of the Infinispan CRD and is no longer under active development.
The DataGrid service type continues to benefit from new features and improved tooling to automate complex operations such as cluster upgrades and data migration.
7.2. Creating Data Grid service pods Copiar o linkLink copiado para a área de transferência!
To use custom cache definitions along with Data Grid capabilities such as cross-site replication, create clusters of Data Grid service pods.
Procedure
Create an
InfinispanCR that setsspec.service.type: DataGridand configures any other Data Grid service resources.Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantYou cannot change the
spec.service.typefield after you create pods. To change the service type, you must delete the existing pods and create new ones.-
Apply your
InfinispanCR to create the cluster.
7.2.1. Data Grid service CR Copiar o linkLink copiado para a área de transferência!
This topic describes the Infinispan CR for Data Grid service pods.
| Field | Description |
|---|---|
|
| Names your Data Grid cluster. |
|
|
Automatically creates a |
|
| Specifies the number of pods in your cluster. |
|
| Specifies the Data Grid Server version of your cluster. |
|
| Controls how Data Grid Operator upgrades your Data Grid cluster when new versions become available. |
|
|
Configures the type Data Grid service. A value of |
|
| Configures the storage resources for Data Grid service pods. |
|
| Configures cross-site replication. |
|
| Specifies an authentication secret that contains Data Grid user credentials. |
|
| Specifies TLS certificates and keystores to encrypt client connections. |
|
| Specifies JVM, CPU, and memory resources for Data Grid pods. |
|
| Configures Data Grid logging categories. |
|
| Controls how Data Grid endpoints are exposed on the network. |
|
|
Specifies a |
|
|
Creates a
The |
|
|
Configures the logging level for the |
|
| Configures anti-affinity strategies that guarantee Data Grid availability. |
7.3. Allocating storage resources Copiar o linkLink copiado para a área de transferência!
You can allocate storage for Data Grid service pods but not Cache service pods.
By default, Data Grid Operator allocates 1Gi for the persistent volume claim. However you should adjust the amount of storage available to Data Grid service pods so that Data Grid can preserve cluster state during shutdown.
If available container storage is less than the amount of available memory, data loss can occur.
Procedure
-
Allocate storage resources with the
spec.service.container.storagefield. Configure either the
ephemeralStoragefield or thestorageClassNamefield as required.NoteThese fields are mutually exclusive. Add only one of them to your
InfinispanCR.- Apply the changes.
Ephemeral storage
Name of a StorageClass object
| Field | Description |
|---|---|
|
| Specifies the amount of storage for Data Grid service pods. |
|
|
Defines whether storage is ephemeral or permanent. Set the value to |
|
|
Specifies the name of a |
7.3.1. Persistent volume claims Copiar o linkLink copiado para a área de transferência!
Data Grid Operator creates a persistent volume claim (PVC) and mounts container storage at:/opt/infinispan/server/data
Caches
When you create caches, Data Grid permanently stores their configuration so your caches are available after cluster restarts. This applies to both Cache service and Data Grid service pods.
Data
Data is always volatile in clusters of Cache service pods. When you shutdown the cluster, you permanently lose the data.
Use a file-based cache store, by adding the <file-store/> element to your Data Grid cache configuration, if you want Data Grid service pods to persist data during cluster shutdown.
7.4. Allocating CPU and memory Copiar o linkLink copiado para a área de transferência!
Allocate CPU and memory resources to Data Grid pods with the Infinispan CR.
Data Grid Operator requests 1Gi of memory from the OpenShift scheduler when creating Data Grid pods. CPU requests are unbounded by default.
Procedure
-
Allocate the number of CPU units with the
spec.container.cpufield. Allocate the amount of memory, in bytes, with the
spec.container.memoryfield.The
cpuandmemoryfields have values in the format of<limit>:<requests>. For example,cpu: "2000m:1000m"limits pods to a maximum of2000mof CPU and requests1000mof CPU for each pod at startup. Specifying a single value sets both the limit and request.Apply your
InfinispanCR.If your cluster is running, Data Grid Operator restarts the Data Grid pods so changes take effect.
spec:
container:
cpu: "2000m:1000m"
memory: "2Gi:1Gi"
spec:
container:
cpu: "2000m:1000m"
memory: "2Gi:1Gi"
7.5. Setting JVM options Copiar o linkLink copiado para a área de transferência!
Pass additional JVM options to Data Grid pods at startup.
Procedure
-
Configure JVM options with the
spec.containerfiled in yourInfinispanCR. Apply your
InfinispanCR.If your cluster is running, Data Grid Operator restarts the Data Grid pods so changes take effect.
JVM options
spec:
container:
extraJvmOpts: "-<option>=<value>"
routerExtraJvmOpts: "-<option>=<value>"
cliExtraJvmOpts: "-<option>=<value>"
spec:
container:
extraJvmOpts: "-<option>=<value>"
routerExtraJvmOpts: "-<option>=<value>"
cliExtraJvmOpts: "-<option>=<value>"
| Field | Description |
|---|---|
|
| Specifies additional JVM options for the Data Grid Server. |
|
| Specifies additional JVM options for the Gossip router. |
|
| Specifies additional JVM options for the Data Grid CLI. |
7.6. Configuring pod probes Copiar o linkLink copiado para a área de transferência!
Optionally configure the values of the Liveness, Readiness and Startup probes used by Data Grid pods.
The Data Grid Operator automatically configures the probe values to sensible defaults. We only recommend providing your own values once you have determined that the default values do not match your requirements.
Procedure
Configure probe values using the
spec.service.container.*Probefields:Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantIf no value is specified for a given probe value, then the Data Grid Operator default is used.
Apply your
InfinispanCR.If your cluster is running, Data Grid Operator restarts the Data Grid pods in order for the changes to take effect.
7.7. Configuring pod priority Copiar o linkLink copiado para a área de transferência!
Create one or more priority classes to indicate the importance of a pod relative to other pods. Pods with higher priority are scheduled ahead of pods with lower priority, ensuring prioritization of pods running critical workloads, especially when resources become constrained.
Prerequisites
-
Have
cluster-adminaccess to OpenShift.
Procedure
Define a
PriorityClassobject by specifying its name and value.high-priority.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the priority class.
oc create -f high-priority.yaml
oc create -f high-priority.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reference the priority class name in the pod configuration.
Infinispan CR
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You must reference an existing priority class name, otherwise the pod is rejected.
- Apply the changes.
7.8. FIPS mode for your Infinispan CR Copiar o linkLink copiado para a área de transferência!
The Red Hat OpenShift Container Platform can use certain Federal Information Processing Standards (FIPS) components that ensure OpenShift clusters meet the requirements of a FIPS compliance audit.
If you enabled FIPS mode on your OpenShift cluster then the Data Grid Operator automatically enables FIPS mode for your Infinispan custom resource (CR).
Client certificate authentication is not currently supported with FIPS mode. Attempts to create Infinispan CR with spec.security.endpointEncryption.clientCert set to a value other than None will fail.
7.9. Adjusting log levels Copiar o linkLink copiado para a área de transferência!
Change levels for different Data Grid logging categories when you need to debug issues. You can also adjust log levels to reduce the number of messages for certain categories to minimize the use of container resources.
Procedure
Configure Data Grid logging with the
spec.logging.categoriesfield in yourInfinispanCR.spec: logging: categories: org.infinispan: debug org.jgroups: debugspec: logging: categories: org.infinispan: debug org.jgroups: debugCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Apply the changes.
Retrieve logs from Data Grid pods as required.
oc logs -f $POD_NAME
oc logs -f $POD_NAMECopy to Clipboard Copied! Toggle word wrap Toggle overflow
7.9.1. Logging reference Copiar o linkLink copiado para a área de transferência!
Find information about log categories and levels.
| Root category | Description | Default level |
|---|---|---|
|
| Data Grid messages |
|
|
| Cluster transport messages |
|
| Log level | Description |
|---|---|
|
| Provides detailed information about running state of applications. This is the most verbose log level. |
|
| Indicates the progress of individual requests or activities. |
|
| Indicates overall progress of applications, including lifecycle events. |
|
| Indicates circumstances that can lead to error or degrade performance. |
|
| Indicates error conditions that might prevent operations or activities from being successful but do not prevent applications from running. |
Garbage collection (GC) messages
Data Grid Operator does not log GC messages by default. You can direct GC messages to stdout with the following JVM options:
extraJvmOpts: "-Xlog:gc*:stdout:time,level,tags"
extraJvmOpts: "-Xlog:gc*:stdout:time,level,tags"
7.10. Creating Cache service pods Copiar o linkLink copiado para a área de transferência!
Create Data Grid clusters with Cache service pods for a volatile, low-latency data store with minimal configuration.
Cache service pods provide volatile storage only, which means you lose all data when you modify your Infinispan CR or update the version of your Data Grid cluster.
Procedure
Create an
InfinispanCR that setsspec.service.type: Cacheand configures any other Cache service resources.Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Apply your
InfinispanCR to create the cluster.
7.10.1. Cache service CR Copiar o linkLink copiado para a área de transferência!
This topic describes the Infinispan CR for Cache service pods.
| Field | Description |
|---|---|
|
| Names your Data Grid cluster. |
|
|
Automatically creates a |
|
| Specifies the number of pods in your cluster. If you enable autoscaling capabilities, this field specifies the initial number of pods. |
|
| Specifies the Data Grid Server version of your cluster. |
|
| Controls how Data Grid Operator upgrades your Data Grid cluster when new versions become available. |
|
|
Configures the type Data Grid service. A value of |
|
| Sets the number of copies for each entry across the cluster. The default for Cache service pods is two, which replicates each cache entry to avoid data loss. |
|
| Enables and configures automatic scaling. |
|
| Specifies an authentication secret that contains Data Grid user credentials. |
|
| Specifies TLS certificates and keystores to encrypt client connections. |
|
| Specifies JVM, CPU, and memory resources for Data Grid pods. |
|
| Configures Data Grid logging categories. |
|
| Controls how Data Grid endpoints are exposed on the network. |
|
| Configures anti-affinity strategies that guarantee Data Grid availability. |
7.11. Automatic scaling Copiar o linkLink copiado para a área de transferência!
Data Grid Operator can monitor the default cache on Cache service pods to automatically scale clusters up or down, by creating or deleting pods based on memory usage.
Automatic scaling is available for clusters of Cache service pods only. Data Grid Operator does not perform automatic scaling for clusters of Data Grid service pods.
When you enable automatic scaling, you define memory usage thresholds that let Data Grid Operator determine when it needs to create or delete pods. Data Grid Operator monitors statistics for the default cache and, when memory usage reaches the configured thresholds, scales your clusters up or down.
Maximum threshold
This threshold sets an upper boundary for the amount of memory that pods in your cluster can use before scaling up or performing eviction. When Data Grid Operator detects that any node reaches the maximum amount of memory that you configure, it creates a new node if possible. If Data Grid Operator cannot create a new node then it performs eviction when memory usage reaches 100 percent.
Minimum threshold
This threshold sets a lower boundary for memory usage across your Data Grid cluster. When Data Grid Operator detects that memory usage falls below the minimum, it shuts down pods.
Default cache only
Autoscaling capabilities work with the default cache only. If you plan to add other caches to your cluster, you should not include the autoscale field in your Infinispan CR. In this case you should use eviction to control the size of the data container on each node.
7.11.1. Configuring automatic scaling Copiar o linkLink copiado para a área de transferência!
If you create clusters with Cache service pods, you can configure Data Grid Operator to automatically scale clusters.
Procedure
Add the
spec.autoscaleresource to yourInfinispanCR to enable automatic scaling.NoteSet a value of
truefor theautoscale.disabledfield to disable automatic scaling.Configure thresholds for automatic scaling with the following fields:
Expand Field Description spec.autoscale.maxMemUsagePercentSpecifies a maximum threshold, as a percentage, for memory usage on each node.
spec.autoscale.maxReplicasSpecifies the maximum number of Cache service pods for the cluster.
spec.autoscale.minMemUsagePercentSpecifies a minimum threshold, as a percentage, for cluster memory usage.
spec.autoscale.minReplicasSpecifies the minimum number of Cache service pods for the cluster.
For example, add the following to your
InfinispanCR:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Apply the changes.
7.12. Adding labels and annotations to Data Grid resources Copiar o linkLink copiado para a área de transferência!
Attach key/value labels and annotations to pods and services that Data Grid Operator creates and manages. Labels help you identify relationships between objects to better organize and monitor Data Grid resources. Annotations are arbitrary non-identifying metadata for client applications or deployment and management tooling.
Red Hat subscription labels are automatically applied to Data Grid resources.
Procedure
-
Open your
InfinispanCR for editing. Attach labels and annotations to Data Grid resources in the
metadata.annotationssection.-
Define values for annotations directly in the
metadata.annotationssection. -
Define values for labels with the
metadata.labelsfield.
-
Define values for annotations directly in the
-
Apply your
InfinispanCR.
Custom annotations
Custom labels
7.13. Adding labels and annotations with environment variables Copiar o linkLink copiado para a área de transferência!
Set environment variables for Data Grid Operator to add labels and annotations that automatically propagate to all Data Grid pods and services.
Procedure
Add labels and annotations to your Data Grid Operator subscription with the spec.config.env field in one of the following ways:
Use the
oc edit subscriptioncommand.oc edit subscription datagrid -n openshift-operators
oc edit subscription datagrid -n openshift-operatorsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the Red Hat OpenShift Console.
- Navigate to Operators > Installed Operators > Data Grid Operator.
- From the Actions menu, select Edit Subscription.
Labels and annotations with environment variables
7.14. Defining environment variables in the Data Grid Operator subscription Copiar o linkLink copiado para a área de transferência!
You can define environment variables in your Data Grid Operator subscription either when you create or edit the subscription.
If you are using the Red Hat OpenShift Console, you must first install the Data Grid Operator and then edit the existing subscription.
spec.config.envfield-
Includes the
nameandvaluefields to define environment variables. ADDITIONAL_VARSvariable-
Includes the names of environment variables in a format of JSON array. Environment variables within the
valueof theADDITIONAL_VARSvariable automatically propagate to each Data Grid Server pod managed by the associated Operator.
Prerequisites
- Ensure the Operator Lifecycle Manager (OLM) is installed.
-
Have an
occlient.
Procedure
Create a subscription definition YAML for your Data Grid Operator:
-
Use the
spec.config.envfield to define environment variables. Within the
ADDITIONAL_VARSvariable, include environment variable names in a JSON array.subscription-datagrid.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example, use the environment variables to set the local time zone:
subscription-datagrid.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Use the
Create a subscription for Data Grid Operator:
oc apply -f subscription-datagrid.yaml
oc apply -f subscription-datagrid.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Retrieve the environment variables from the
subscription-datagrid.yaml:oc get subscription datagrid -n openshift-operators -o jsonpath='{.spec.config.env[*].name}'oc get subscription datagrid -n openshift-operators -o jsonpath='{.spec.config.env[*].name}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Next steps
Use the
oc edit subscriptioncommand to modify the environment variable:oc edit subscription datagrid -n openshift-operators
oc edit subscription datagrid -n openshift-operatorsCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
To ensure the changes take effect on your Data Grid clusters, you must recreate the existing clusters. Terminate the pods by deleting the
StatefulSetassociated with the existingInfinispanCRs.
- In the Red Hat OpenShift Console, navigate to Operators > Installed Operators > Data Grid Operator. From the Actions menu, select Edit Subscription.