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

  • Java SDK version 8 or 11

  • Maven 3.2.5 or higher

  • Docker

  • Docker image repository

  • kubectl installed and connected to the DIH Kubernetes cluster

  • Helm

  • GigaSpaces unzipped and installed

  • Perform the steps in Deploying and Managing GigaSpaces in Kubernetes

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 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/xap-enterprise:15.2.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 ./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					
helm install custom-pu gigaspaces/xap-pu --version 15.2.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