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. environment.

The topics in this section assume basic knowledge of the GigaSpaces platform. If you aren't familiar with GigaSpaces, review the contents of the general Getting Started section before performing the tasks described here.

Prerequisites

Building a Java Application

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 4 in the procedure, is creating a stateless Processing Unit.

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

  2. Type blueprint generate. This begins the configuration work flow.

  3. A list of available blueprints is displayed. Press 4 to select the blueprint for a stateless PU.

  4. Choose the default target path (my-pu-state;ess) and "n" to take all of the other defaults..

  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-stateless directory, and enter the maven command to build the project:

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

Create a Docker Image

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


FROM gigaspaces/smart-cache-enterprise:16.4.0
ADD target/my-pu-stateless-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-stateless .

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-stateless)

Deploy the Docker image in GigaSpaces.

helm install custom-pu gigaspaces/xap-pu --version 16.4.0 --set instances=1,partitions=0,resourceUrl=pu.jar,image.repository=my-pu-stateless,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