Deploying a Custom Processing Unit
This topic describes how to deploy a custom GigaSpaces processing unit 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. (PU 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 Kubernetes 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
-
Java SDK version 11
-
Maven 3.2.5 or higher
-
Docker
-
Docker image repository
-
kubectl installed and connected to the DIH Digital Integration Hub. An application architecture that decouples digital applications from the systems of record, and aggregates operational data into a low-latency data fabric. 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 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.
-
cd
to thebin
folder and then rungs.sh
(orgs.bat
). -
Type
blueprint generate
. This begins the configuration work flow. - A list of available blueprints is displayed. Press 4 to select the blueprint for a stateless PU.
- Choose the default target path (my-pu-state;ess) and "n" to take all of the other defaults..
-
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.
-
Build the jar file – switch to the bin/my-pu-stateless directory, and enter the maven command to build the project:
Type quit to exit the gs procedure.
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