Deploying a Custom Processing Unit

This topic describes how to deploy a custom GigaSpaces processing unit (PU) in a Kubernetes 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 blueprint we are using, option 4 in the procedure, is creating a stateless Processing Unit.

  1. cd to the bin folder.

  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 exec 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

Copy the created jar file from the target folder to the local folder.

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


FROM gigaspaces/xap-enterprise:16.1.1
ADD 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 .

Deploy the Docker image in GigaSpaces.


helm install custom-pu ./xap-pu/ --set manager.name=xap,\
resourceUrl=pu.jar,\
livenessProbe.enabled=false,readinessProbe.enabled=false,metrics.enabled=false,\
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