Deploying a Custom Processing Unit

This topic describes how to deploy a custom GigaSpaces processing unitClosed This is the unit of packaging and deployment in the GigaSpaces Data Grid, and is essentially the main GigaSpaces service. The Processing Unit (PU) itself is typically deployed onto the Service Grid. When a Processing Unit is deployed, a Processing Unit instance is the actual runtime entity. (PUClosed This is the unit of packaging and deployment in the GigaSpaces Data Grid, and is essentially the main GigaSpaces service. The Processing Unit (PU) itself is typically deployed onto the Service Grid. When a Processing Unit is deployed, a Processing Unit instance is the actual runtime entity.) in a KubernetesClosed An open-source container orchestration system for automating software deployment, scaling, and management of containerized applications. environment.

Refer to the Your First Data Grid page

To build your first data grid, refer to Your First Data but note that for Kubernetes, Docker images first need to be created - see here.

Prerequisites

  • Java SDK version 11

  • Maven 3.2.5 or higher

  • Docker

  • Docker image repository

  • kubectl installed and connected to the Kubernetes cluster

  • Helm

  • GigaSpaces unzipped and installed

Building a Java Application Using Blueprints

We will build a Java application from one of the built-in blueprints available in the gs.bat/sh procedure.

The blueprintClosed Java project templating framework provided by DIH for developers, a bueprint, or class, contains a set of attributes and behaviors that define an object. we are using, option 2 in the procedure, is creating a stateful Processing Unit.

  1. cd to the bin folder and then run gs.sh (or gs.bat).

  2. Type blueprint generate. This will let you select a blueprint and will create a project for you that you can continue to develop, build and deploy. It begins the configuration workflow.

  3. A list of available blueprints is displayed. Select 2 which is the blueprint for a stateful PU.

  4. The blueprints whose names contain "-xml" use the pu.xml to configure the processing unit. The blueprints not containing "-xml" in their names use annotation-base configuration, and a minimal pu.xml

  5. The project is created, and the target path is displayed. You are prompted to open the project in your default file explorer. Choose "y" to see the project tree.

  6. Type quit to exit the gs procedure.

  7. Build the jar file – switch to the bin/my-pu-stateful directory, and enter the maven command to build the project:

cd <installation directory>/bin/my-pu-stateful
mvn clean install -DskipTests

Create a Docker Image

Create a docker file named Dockerfile, with the following content:


FROM gigaspaces/xap-skyline-enterprise:17.0.0
ADD target/my-pu-stateful-0.1.jar /opt/gigaspaces/bin/pu.jar

ENTRYPOINT ["/opt/entrypoint.sh"]
CMD ["host", "run-agent", "--auto"]

Perform a Docker build operation, in the directory that has Dockerfile and the jar file. This will create a Docker image.

 docker build -t my-pu-stateful .

You might need to push the image to a remote docker registry if your cluster cannot access the local one. If you do create a remote docker registry you will need to add the name to the command to deploy the Docker image (e.g., update what is in bold: pu-jar-image.repository=my-pu-statelful)

Deploy the Docker image in GigaSpaces.

helm install custom-pu gigaspaces/xap-pu --version 17.0.0 --set instances=1,partitions=0,resourceUrl=pu.jar,image.repository=my-pu-stateful,image.tag=latest					

Enter the command kubectl get pods to see the result:

NAME                            READY   STATUS    RESTARTS   AGE
custom-pu-xap-pu-0              1/1     Running   0          3s
demo-xap-pu-0                   1/1     Running   0          26s
xap-grafana-67d9b898b5-s2njk    1/1     Running   0          114s
xap-influxdb-0                  1/1     Running   0          114s
xap-operator-8478949559-hb4pp   1/1     Running   0          114s
xap-xap-manager-0               1/1     Running   0          114s