7.2. Data Grid サービス Pod の作成

クロスサイトのレプリケーションなどの Data Grid 機能とカスタムキャッシュ定義を使用するには、Data Grid サービス Pod のクラスターを作成します。

手順

  1. spec.service.type: DataGrid を設定し、他の Data Grid サービスリソースを設定する Infinispan CR を作成します。

    apiVersion: infinispan.org/v1
    kind: Infinispan
    metadata:
      name: infinispan
    spec:
      replicas: 2
      service:
        type: DataGrid
    重要

    Pod の作成後に spec.service.type フィールドを変更することはできません。サービスタイプを変更するには、既存の Pod を削除してから新規の Pod を作成する必要があります。

  2. Infinispan CR を適用して、クラスターを作成します。

7.2.1. Data Grid サービス CR

このトピックでは、Data Grid サービス Pod の Infinispan CR について説明します。

apiVersion: infinispan.org/v1
kind: Infinispan
metadata:
  name: infinispan
  annotations:
    infinispan.org/monitoring: 'true'
spec:
  replicas: 6
  upgrades:
    type: Shutdown
  service:
    type: DataGrid
    container:
      storage: 2Gi
      # The ephemeralStorage and storageClassName fields are mutually exclusive.
      ephemeralStorage: false
      storageClassName: my-storage-class
    sites:
      local:
      name: azure
      expose:
        type: LoadBalancer
      locations:
      - name: azure
        url: openshift://api.azure.host:6443
        secretName: azure-token
      - name: aws
        clusterName: infinispan
        namespace: rhdg-namespace
        url: openshift://api.aws.host:6443
        secretName: aws-token
  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: debug
      org.jgroups: debug
      org.jgroups.protocols.TCP: error
      org.jgroups.protocols.relay.RELAY2: error
  expose:
    type: LoadBalancer
  configMapName: "my-cluster-config"
  configListener:
    enabled: true
  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 の数を指定します。

spec.upgrades.type

新しいバージョンが利用可能になったときに、Data Grid Operator が Data Grid クラスターをアップグレードする方法を制御します。

spec.service.type

タイプ Data Grid サービスを設定します。DataGrid の値は、Data Grid サービス Pod でクラスターを作成します。

spec.service.container

Data Grid サービス Pod のストレージリソースを設定します。

spec.service.sites

クロスサイトのレプリケーションを設定します。

spec.security.endpointSecretName

Data Grid のユーザー認証情報が含まれる認証シークレットを指定します。

spec.security.endpointEncryption

TLS 証明書およびキーストアを指定して、クライアント接続を暗号化します。

spec.container

Data Grid Pod の JVM、CPU、およびメモリーリソースを指定します。

spec.logging

Data Grid のロギングカテゴリーを設定します。

spec.expose

ネットワーク上で Data Grid エンドポイントを公開する方法を制御します。

spec.configMapName

Data Grid の設定が含まれる ConfigMap を指定します。

spec.configListener

各 Data Grid クラスターに listener Pod を作成します。これにより、Data Grid Operator はサーバー側の変更を Cache CR などの Data Grid リソースと調整できます。

listener Pod は最小限のリソースを消費し、デフォルトで有効になっています。false の値を設定すると、listener Pod が削除され、双方向の調整が無効になります。これは、Data Grid Console、CLI、またはクライアントアプリケーションを介して作成された Data Grid リソースの宣言型 Kubernetes 表現が必要ない場合にのみ行う必要があります。

spec.affinity

Data Grid の可用性を保証する anti-affinity ストラテジーを設定します。