Spring Eco samples for multiple Spring modules (Spring Boot 2.0.x).
-
Spring samples
Topic | Projects | Description | Modules |
---|---|---|---|
Test and presentation project |
simple-data-provider |
A general project for providing multiple interfaces for testing or presenting |
Spring Boot |
Service Registry & Discovery |
eureka-client, eureka-server, eureka-service |
Handles Service registration and discovery in Microservices landscape using Spring Cloud and Eureka. With Docker. |
Spring Cloud, Spring Cloud Config, Netflix Eureka, Hystrix, FeignClient, Security |
Apache Kafka |
simple-kafka |
Kafka examples with Producer and Consumer |
Spring Boot, Apache Kafka, Confluent Kafka |
To use the whole functionality start the apps using the docker compose file or start them manually in the following order
# | Action | Description |
---|---|---|
1 |
java -jar -Dspring.profiles.active=stock-fmp simple-data-provider-0.0.1-SNAPSHOT.jar |
Start SimpleDataProvide with FMP as stock backend system. Listening on port 9042 |
2 |
java -jar -Dspring.profiles.active=stock-iex simple-data-provider-0.0.1-SNAPSHOT.jar |
Start SimpleDataProvide with IEX as stock backend system. Listening on port 9043 |
3 |
java -jar eureka-server-0.0.2-SNAPSHOT.jar |
Start the service registry with Eureka. Listening on port 9876 |
4 |
java -jar -Dspring.profiles.active=stock-fmp eureka-service-0.0.2-SNAPSHOT.jar |
Start the service with a releation to SimpleDataProvider FMP instance. Listening on port 9022 |
5 |
java -jar -Dspring.profiles.active=stock-iex eureka-service-0.0.2-SNAPSHOT.jar |
Start the service with a releation to SimpleDataProvider IEX instance. Listening on port 9023 |
6 |
java -jar eureka-client-0.0.2-SNAPSHOT.jar |
Start the client and retrieve the service instances from Service Registry. Listening on port 9011 |
For the docker compose way:
$ cd docker
$ VER=0.0.3-SNAPSHOT docker-compose -f docker-compose-eureka.ml up
The docker compose file has a variable VER referencing the version number. For simplicity will be the same version number used, for fetching the docker image from docker hub.
Some of the modules contains meta data for a Openshift integration. This integration enables the operation of the sub-module in a Openshift instance.
Enabled modules are: * simple-data-provider
To install the application in Openshift
oc new-app --template=master-spring-template -p PROJECT_NAME=code-4 -p APP_NAME=simple-data-provider -p SOURCE_REPOSITORY_URL=https://github.com/haf-tech/spring-samples -p SOURCE_REF=master -p SOURCE_SUB_MODULE_DIR=simple-data-provider -p APP_HTTP_PORT=9021 -p WEBHOOK_GITHUB_SECRET=abcd...efgh -p WEBHOOK_GENERIC_SECRET=zyx...wvu
The output is
--> Deploying template "code-4/spring-samples" to project code-4
* With parameters:
* PROJECT_NAME=code-4
* APP_NAME=simple-data-provider
* SOURCE_REPOSITORY_URL=https://github.com/haf-tech/spring-samples
* SOURCE_REF=master
* SOURCE_SUB_MODULE_DIR=simple-data-provider
* APP_HTTP_PORT=9021
* WEBHOOK_GITHUB_SECRET=3...
* WEBHOOK_GENERIC_SECRET=9...
--> Creating resources ...
buildconfig "simple-data-provider" created
deploymentconfig "simple-data-provider" created
imagestream "simple-data-provider" created
service "simple-data-provider" created
route "simple-data-provider" created
--> Success
Use 'oc start-build simple-data-provider' to start a build.
Access your application via route 'simple-data-provider-code-4.8a09.starter-us-east-2.openshiftapps.com'
Run 'oc status' to view your app.
TargetPort The current version of the kubernet-client can not handle a (string) parameter for an integer field. See kubernetes-client/java#242. This is reason for the hard-coded target port.
Openshift labels all created components with an app-label. This can be used to reference right components.
oc delete all -l app=simple-data-provider
Excurse to upload template
oc create -f .openshiftio/application-template.yaml
Delete template
oc delete template master-spring-template
Verify the existing templates
oc get template master-spring-template
Generate a template for (all) existing objects. Consider to remove afterwards the unnecessary objects, like Pods, Builds etc.
oc export all --as-template=master-spring-template masterSpringTemplate.yaml
Trigger a build using the generic or GitHub WebHook. To retrieve the URL
oc describe bc simple-data-provider
And trigger manually a new build
curl -kv -X POST https://<domain>:<port>/apis/build.openshift.io/v1/namespaces/<namespace>/buildconfigs/<app-name>/webhooks/<secret>/generic