Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/snowdrop/cache-example
Spring Boot Cache Booster
https://github.com/snowdrop/cache-example
booster cache data-grid example infinispan kubernetes openshift spring-boot
Last synced: 5 days ago
JSON representation
Spring Boot Cache Booster
- Host: GitHub
- URL: https://github.com/snowdrop/cache-example
- Owner: snowdrop
- License: apache-2.0
- Created: 2018-01-09T16:18:44.000Z (almost 7 years ago)
- Default Branch: sb-2.7.x
- Last Pushed: 2022-10-26T11:39:23.000Z (about 2 years ago)
- Last Synced: 2024-04-16T07:12:04.092Z (7 months ago)
- Topics: booster, cache, data-grid, example, infinispan, kubernetes, openshift, spring-boot
- Language: Java
- Homepage:
- Size: 1.21 MB
- Stars: 3
- Watchers: 5
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
= Cache Spring Boot Example
:toc: left== Purpose
The purpose of this use case is to demonstrate how to use Red Hat JBoss Data Grid for
Openshift as a cache, to increase the response time of applications.
This mission covers:* The deployment of the Red Hat JBoss Data Grid on OpenShift
* How applications leverage this cache service== Technical details
The boosters demonstrates how Spring's Caching support can interact with the JBoss Datagrid caching server.
What that means practically, is that the business code simply uses Spring's `@Cacheable` to cache return values== Deploying and interacting with the example
- Create a new OpenShift project `cache-example` (or whatever you want to call it):
[source,bash,options="nowrap",subs="attributes+"]
----
$ oc new-project cache-example
----- Deploy JBoss Datagrid to Openshift
[source,bash,options="nowrap",subs="attributes+"]
----
$ oc apply -f .openshiftio/cache.yml
----- Build and deploy the Spring Boot applications using Dekorate
[source,bash,options="nowrap",subs="attributes+"]
----
$ mvn clean verify -pl greeting-service -Popenshift -Ddekorate.deploy=true
$ mvn clean verify -pl cute-name-service -Popenshift -Ddekorate.deploy=true
----- Open the UI of the `greeting-service`. The URL can be determined by executing
[source,bash,options="nowrap",subs="attributes+"]
----
$ oc get route/spring-boot-cache-greeting --template={{.spec.host}}
----From the UI the user can invoke the `greeting-service` which in turn invokes the JBoss Datagrid and perhaps the `name-service`
depending on the state of the cache- Execute the integration test using Dekorate to verify the behavior of the system
[source,bash,options="nowrap",subs="attributes+"]
----
$ oc delete project cache-example --ignore-not-found=true
$ oc new-project cache-example
$ ./run_tests_with_dekorate_in_ocp.sh
----Alternativelly, tests can be executed against a specific Spring Boot or Dekorate version by passing the
version as a `-D=value` parameter. For instance overriding both the Spring Boot and the Dekorate versions using their corresponding version properties is done the following way:[source,bash,options="nowrap",subs="attributes+"]
----
./run_tests_with_dekorate_in_ocp.sh -Dspring-boot.version=2.7.3 -Ddekorate.version=2.11.1
----- Execute the integration test using S2i to verify the behavior of the system
[source,bash,options="nowrap",subs="attributes+"]
----
$ oc delete project cache-example --ignore-not-found=true
$ oc new-project cache-example
$ ./run_tests_with_s2i.sh "https://github.com/snowdrop/cache-example" sb-2.4.x
----== Deploying application on OpenShift using Helm
First, make sure you have installed the Helm command line and connected/logged to a kubernetes cluster.
Then, you need to install the example by doing:
[source,shell script]
----
helm install cache ./helm --set cute-name-service.route.expose=true --set cute-name-service.s2i.source.repo=https://github.com/snowdrop/cache-example --set cute-name-service.s2i.source.ref= --set greeting-service.route.expose=true --set greeting-service.s2i.source.repo=https://github.com/snowdrop/cache-example --set greeting-service.s2i.source.ref=
----**note**: Replace `` with one branch from `https://github.com/snowdrop/cache-example/branches/all`.
And to uninstall the chart, execute:
[source,shell script]
----
helm uninstall cache
----== Deploying application on Kubernetes using Helm
Requirements:
- Have installed [the Helm command line](https://helm.sh/docs/intro/install/)
- Have connected/logged to a kubernetes clusterYou need to install the example by doing:
[source,shell script]
----
helm install cache ./helm -n --set cute-name-service.ingress.host= --set greeting-service.ingress.host=
----And to uninstall the chart, execute:
[source,shell script]
----
helm uninstall cache
----== Running Tests on OpenShift using Dekorate:
[source,shell script]
----
sh run_tests_with_dekorate_in_ocp.sh
----== Running Tests on OpenShift using S2i from Source:
[source,shell script]
----
./run_tests_with_s2i.sh
----This script can take 2 parameters referring to the repository and the branch to use to source the images from.
[source,shell script]
----
./run_tests_with_s2i.sh "https://github.com/snowdrop/cache-example" branch-to-test
----== Running Tests on Kubernetes with External Registry:
[source,shell script]
----
mvn clean verify -Pkubernetes,kubernetes-it -Ddekorate.docker.registry= -Ddekorate.push=true
----== Running Tests on OpenShift using Helm
[source,shell script]
----
./run_tests_with_helm_in_ocp.sh
----This script can take 2 parameters referring to the repository and the branch to use to source the images from.
[source,shell script]
----
./run_tests_with_helm_in_ocp.sh "https://github.com/snowdrop/cache-example" branch-to-test
----== Running Tests on Kubernetes using Helm
First, you need to create the k8s namespace:
[source,shell script]
----
kubectl create namespace
----Then, run the tests by specifying the container registry and the kubernetes namespace:
[source,shell script]
----
./run_tests_with_helm_in_k8s.sh
----For example:
[source,shell script]
----
./run_tests_with_helm_in_k8s.sh "quay.io/user" "myNamespace"
----