7.8. 创建缓存服务 pod

使用缓存服务 pod 创建 Data Grid 集群,用于具有最小配置的易变的低延迟数据存储。

重要

缓存服务 pod 仅提供易失性存储,这意味着当您修改 Infinispan CR 或更新您的 Data Grid 集群版本时,您会丢失所有数据。

流程

  1. 创建一个 Infinispan CR,它将设置 spec.service.type: Cache,并配置任何其他缓存服务资源。

    apiVersion: infinispan.org/v1
    kind: Infinispan
    metadata:
      name: infinispan
    spec:
      replicas: 2
      service:
        type: Cache
  2. 应用您的 Infinispan CR 来创建集群。

7.8.1. 缓存服务 CR

本主题论述了用于缓存服务 pod 的 Infinispan CR。

apiVersion: infinispan.org/v1
kind: Infinispan
metadata:
  name: infinispan
  annotations:
    infinispan.org/monitoring: 'true'
spec:
  replicas: 2
  upgrades:
    type: Shutdown
  service:
    type: Cache
    replicationFactor: 2
  autoscale:
    maxMemUsagePercent: 70
    maxReplicas: 5
    minMemUsagePercent: 30
    minReplicas: 2
  security:
    endpointSecretName: endpoint-identities
    endpointEncryption:
        type: Secret
        certSecretName: tls-secret
  container:
    extraJvmOpts: "-XX:NativeMemoryTracking=summary"
    cpu: "2000m:1000m"
    memory: "2Gi:1Gi"
  logging:
    categories:
      org.infinispan: trace
      org.jgroups: trace
  expose:
    type: LoadBalancer
  affinity:
    podAntiAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
      - weight: 100
        podAffinityTerm:
          labelSelector:
            matchLabels:
              app: infinispan-pod
              clusterName: infinispan
              infinispan_cr: infinispan
          topologyKey: "kubernetes.io/hostname"
字段描述

metadata.name

为您的 Data Grid 集群命名。

metadata.annotations.infinispan.org/monitoring

为集群自动创建 ServiceMonitor

spec.replicas

指定集群中的 pod 数量。如果启用自动扩展功能,此字段指定初始 pod 数量。

spec.upgrades.type

控制当有新版本可用时,Data Grid Operator 如何升级您的 Data Grid 集群。

spec.service.type

配置类型 Data Grid 服务。值为 Cache 会创建一个使用缓存服务 pod 的集群。

spec.service.replicationFactor

设置集群中每个条目的副本数。缓存服务 pod 的默认是两个,复制每个缓存条目以避免数据丢失。

spec.autoscale

启用并配置自动扩展。

spec.security.endpointSecretName

指定包含 Data Grid 用户凭证的身份验证 secret。

spec.security.endpointEncryption

指定 TLS 证书和密钥存储来加密客户端连接。

spec.container

为 Data Grid pod 指定 JVM、CPU 和内存资源。

spec.logging

配置数据网格日志类别。

spec.expose

控制如何在网络上公开 Data Grid 端点。

spec.affinity

配置用于保证 Data Grid 可用性的反关联性策略。