Blueprints
Overview
GigaSpaces products come packaged with a set of blueprints that can be used to create projects. These blueprints can be generated via the interactive shell.
The purpose of blueprints is to make it easy to develop new services based on templates. Once you have defined and created a set of blueprints, they can serve to be an example of several types of template projects a developer can start from, making it easier to develop new projects. Using blueprints also enforced the service developer's conventions for developing each type of service. Blueprints also offer the reuse of common structure.
Commands
Default Blueprint List
Blueprint Generate
Creating a Project
When creating a project, the cmd line leads the user through an interactive workflow where a number of options are defined as the configuration is created.
A default configuration can be used to simplify the project creation process.
Adding Custom Blueprints
Custom blueprints can be added by creating a folder under:
gs-home/config/blueprints
Then add a template and related scripts to that folder.
For example, take a look at the client folder which is under the blueprints folder:
gs-home/config/blueprints/client/
Which contains the following:
Template folder: The src should be placed here plus any deployment scripts if required.
blueprint.yaml:
contains the description to display in the menuvalues yaml:
contains the default values to set to parameters as packages, version, etc. that can be overridden interactively during template generation. Define Parameters
Placeholders for parameters that should be overridden during blueprint creation will appear as:
{{section.parameter}}
In the values.yaml put the default:
[section]: [parameter]: yourVal
Developing a Blueprint
Following are the steps used to develop a blueprint:
-
Write the application as required and test it.
-
Replace the configuration values you allow to change with a placeholder
-
Copy the folder containing the files and templates to gs-home/config/blueprints.
-
Remove the target folder, if it exists.
-
Generate a new blueprint using the cmd line, override parameters, and test.
Deploying a Generated Service in Kubernetes
After generating a project from the blueprint and building the related jar, it can be deployed to a kubernetes cluster in the similar manner any stateful/stateless client is deployed.
If the service is of type PU:
-
Copy the created jar file from the target folder to a new local folder.
-
Create a docker file named Dockerfile with the following content - example using the my-pu-stateless blueprint:
FROM GigaSpaces/xap-enterprises:16.3.0
ADD my-pu-stateless-0.1.jar /opt/gigaspaces/bin/pu.jar
ENTRYPOINT ["/opt/entrypoint.sh"]
CMD ["host","run-agent","--auto"]
-
In the directory that contains the Dockerfile and jar file, perform a Docker build operation and push the image:
docker build -t my-pu-statelss docker push <your-hub-user>/my-pu-stateless[:<tag>]
-
Deploy the custom-pu using the Docker image in the cluster:
helm install custom-pu GigaSpaces/xap-pu --set manager.name=xap, instances=1
resourcesUrl=pu, jar,
metrics.enabled=false,
image.repository=my-pu-stateless,
image.tag=latest
Run the command:
kubectl get pods
and see the result:
NAMEREADY 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-s2nkj 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