3.3. 创建 Data Grid 服务节点
要使用自定义缓存定义以及 Data Grid 功能(如跨站点复制),请创建 Data Grid 服务节点集群。
流程
在
InfinispanCR 中指定DataGrid作为spec.service.type的值。apiVersion: infinispan.org/v1 kind: Infinispan metadata: name: example-infinispan spec: replicas: 2 service: type: DataGridapiVersion: infinispan.org/v1 kind: Infinispan metadata: name: example-infinispan spec: replicas: 2 service: type: DataGridCopy to Clipboard Copied! Toggle word wrap Toggle overflow 注意您无法在创建节点后更改
spec.service.type字段。要更改服务类型,您必须删除现有节点并创建新节点。- 使用任何其他 Data Grid 服务资源配置节点。
-
应用
InfinispanCR 以创建集群。
3.3.1. Data Grid 服务资源 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
apiVersion: infinispan.org/v1
kind: Infinispan
metadata:
# Names the cluster.
name: example-infinispan
spec:
# Specifies the number of nodes in the cluster.
replicas: 6
service:
# Configures the service type as Data Grid.
type: DataGrid
# Configures storage resources.
container:
storage: 2Gi
storageClassName: my-storage-class
# Configures cross-site replication.
sites:
local:
name: azure
expose:
type: LoadBalancer
locations:
- name: azure
url: openshift://api.azure.host:6443
secretName: azure-token
- name: aws
url: openshift://api.aws.host:6443
secretName: aws-token
# Configures authentication and encryption.
security:
# Defines a secret with custom credentials.
endpointSecretName: endpoint-identities
# Adds a custom TLS certificate to encrypt client connections.
endpointEncryption:
type: Secret
certSecretName: tls-secret
# Sets container resources.
container:
extraJvmOpts: "-XX:NativeMemoryTracking=summary"
cpu: "1000m"
memory: 1Gi
# Configures logging levels.
logging:
categories:
org.infinispan: debug
org.jgroups: debug
org.jgroups.protocols.TCP: error
org.jgroups.protocols.relay.RELAY2: fatal
# Configures how the cluster is exposed on the network.
expose:
type: LoadBalancer
# Configures affinity and anti-affinity strategies.
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
app: infinispan-pod
clusterName: example-infinispan
infinispan_cr: example-infinispan
topologyKey: "kubernetes.io/hostname"
apiVersion: infinispan.org/v1
kind: Infinispan
metadata:
# Names the cluster.
name: example-infinispan
spec:
# Specifies the number of nodes in the cluster.
replicas: 6
service:
# Configures the service type as Data Grid.
type: DataGrid
# Configures storage resources.
container:
storage: 2Gi
storageClassName: my-storage-class
# Configures cross-site replication.
sites:
local:
name: azure
expose:
type: LoadBalancer
locations:
- name: azure
url: openshift://api.azure.host:6443
secretName: azure-token
- name: aws
url: openshift://api.aws.host:6443
secretName: aws-token
# Configures authentication and encryption.
security:
# Defines a secret with custom credentials.
endpointSecretName: endpoint-identities
# Adds a custom TLS certificate to encrypt client connections.
endpointEncryption:
type: Secret
certSecretName: tls-secret
# Sets container resources.
container:
extraJvmOpts: "-XX:NativeMemoryTracking=summary"
cpu: "1000m"
memory: 1Gi
# Configures logging levels.
logging:
categories:
org.infinispan: debug
org.jgroups: debug
org.jgroups.protocols.TCP: error
org.jgroups.protocols.relay.RELAY2: fatal
# Configures how the cluster is exposed on the network.
expose:
type: LoadBalancer
# Configures affinity and anti-affinity strategies.
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
app: infinispan-pod
clusterName: example-infinispan
infinispan_cr: example-infinispan
topologyKey: "kubernetes.io/hostname"