이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 20. Deploying custom code to Data Grid


Add custom code, such as scripts and event listeners, to your Data Grid clusters.

Before you can deploy custom code to Data Grid clusters, you need to make it available. To do this you can copy artifacts from a persistent volume (PV), download artifacts from an HTTP or FTP server, or use both methods.

20.1. Copying code artifacts to Data Grid clusters

Adding your artifacts to a persistent volume (PV) and then copy them to Data Grid pods.

This procedure explains how to use a temporary pod that mounts a persistent volume claim (PVC) that:

  • Lets you add code artifacts to the PV (perform a write operation).
  • Allows Data Grid pods to load code artifacts from the PV (perform a read operation).

To perform these read and write operations, you need certain PV access modes. However, support for different PVC access modes is platform dependent.

It is beyond the scope of this document to provide instructions for creating PVCs with different platforms. For simplicity, the following procedure shows a PVC with the ReadWriteMany access mode.

In some cases only the ReadOnlyMany or ReadWriteOnce access modes are available. You can use a combination of those access modes by reclaiming and reusing PVCs with the same spec.volumeName.

Note

Using ReadWriteOnce access mode results in all Data Grid pods in a cluster being scheduled on the same OpenShift node.

Procedure

  1. Change to the namespace for your Data Grid cluster.

    oc project rhdg-namespace
  2. Create a PVC for your custom code artifacts, for example:

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: datagrid-libs
    spec:
      accessModes:
        - ReadWriteMany
      resources:
        requests:
          storage: 100Mi
  3. Apply your PVC.

    oc apply -f datagrid-libs.yaml
  4. Create a pod that mounts the PVC, for example:

    apiVersion: v1
    kind: Pod
    metadata:
      name: datagrid-libs-pod
    spec:
      securityContext:
        fsGroup: 2000
      volumes:
        - name: lib-pv-storage
          persistentVolumeClaim:
            claimName: datagrid-libs
      containers:
        - name: lib-pv-container
          image: registry.redhat.io/datagrid/datagrid-8-rhel8:8.5
          volumeMounts:
            - mountPath: /tmp/libs
              name: lib-pv-storage
  5. Add the pod to the Data Grid namespace and wait for it to be ready.

    oc apply -f datagrid-libs-pod.yaml
    oc wait --for=condition=ready --timeout=2m pod/datagrid-libs-pod
  6. Copy your code artifacts to the pod so that they are loaded into the PVC.

    For example to copy code artifacts from a local libs directory, do the following:

    oc cp --no-preserve=true libs datagrid-libs-pod:/tmp/
  7. Delete the pod.

    oc delete pod datagrid-libs-pod

    Specify the persistent volume with spec.dependencies.volumeClaimName in your Infinispan CR and then apply the changes.

    apiVersion: infinispan.org/v1
    kind: Infinispan
    metadata:
      name: infinispan
    spec:
      replicas: 2
      dependencies:
        volumeClaimName: datagrid-libs
      service:
        type: DataGrid
Note

If you update your custom code on the persistent volume, you must restart the Data Grid cluster so it can load the changes.

20.2. Downloading code artifacts

Add your artifacts to an HTTP or FTP server so that Data Grid Operator downloads them to the {lib_path} directory on each Data Grid node.

When downloading files, Data Grid Operator can automatically detect the file type. Data Grid Operator also extracts archived files, such as zip or tgz, to the filesystem after the download completes.

You can also download Maven artifacts using the groupId:artifactId:version format, for example org.postgresql:postgresql:42.3.1.

Note

Each time Data Grid Operator creates a Data Grid node it downloads the artifacts to the node.

Prerequisites

  • Host your code artifacts on an HTTP or FTP server or publish them to a maven repository.

Procedure

  1. Add the spec.dependencies.artifacts field to your Infinispan CR.
  2. Do one of the following:

    • Specify the location of the file to download via HTTP or FTP as the value of the spec.dependencies.artifacts.url field.
    • Provide the Maven artifact to download with the groupId:artifactId:version format as the value of the spec.dependencies.artifacts.maven field.
  3. Optionally specify a checksum to verify the integrity of the download with the spec.dependencies.artifacts.hash field.

    The hash field requires a value is in the format of <algorithm>:<checksum> where <algorithm> is sha1|sha224|sha256|sha384|sha512|md5.

    apiVersion: infinispan.org/v1
    kind: Infinispan
    metadata:
      name: infinispan
    spec:
      replicas: 2
      dependencies:
        artifacts:
          - url: http://example.com:8080/path
            hash: sha256:596408848b56b5a23096baa110cd8b633c9a9aef2edd6b38943ade5b4edcd686
      service:
        type: DataGrid
  4. Apply the changes.
Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.