Skip to content

Commit 96c0697

Browse files
committed
3.0.0 - JKUBE over fabric8, kie-maven-plugin over offliner plugin
1 parent c37f7f2 commit 96c0697

15 files changed

+1356
-301
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/local-m2-repository
33
/ARCHIVE
44
local-m2-repository-offliner/
5+
.idea

Dockerfile

Lines changed: 0 additions & 17 deletions
This file was deleted.

Jenkinsfile-mine-WORKING

Lines changed: 0 additions & 110 deletions
This file was deleted.

README.adoc

Lines changed: 55 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= Business Automation - Springboot Runtime App
1+
= Business Automation - Spring Boot Runtime App
22
:toc:
33

44

@@ -29,27 +29,63 @@ image::images/aim.jpg[800,800]
2929
IMPORTANT: Important: Before using note that by default this App provides the minimum configurations for SpringBoot KJAR Service. See xref:anchor-7[How To Further Configure the App]
3030

3131
1. _Fork_ this repository for every new service (ie. this is just a baseline) and update *pom.xml* with new *GAV*.
32-
2. Build and install in your local/central MAVEN repository the xref:anchor-5[Plugin for building KJAR Dependencies]
3332

34-
=== How To Use as locally Springboot App
33+
=== How To Use as local Springboot App
3534
[[anchor-2]]
3635

3736
first start at xref:anchor-1[How To Use this Repo]
3837

39-
1. _Run_ *JenkinspipelineBatch.sh* script to create KJARs binaries, a repository of their dependencies (along with the KJARs installed in it), configurations for the Springboot Runtime App (`your-service-name.xml` kie-server-state, `application-XXX.properties`) based on what is to run
40-
* *[Parameter 1]* a list of KJARs to be loaded into Springboot App. The list must have the following format `containerAlias-1#RuntimeStrategy#GIT_REPO-1,containerAlias-2#RuntimeStrategy#GIT_REPO-2,containerAlias-N#RuntimeStrategy#GIT_REPO-N`
41-
* *[Parameter 2]* Name of Business Service (will be used for `kie-server-state` config file name, `application-xxx.properties` configurations `kieserver.serverId`, `kieserver.Name`)
42-
* example:
43-
44-
./JenkinspipelineBatch.sh basic#PER_PROCESS_INSTANCE#https://github.com/skoussou/basic-kjar,retail#PER_CASE#https://github.com/skoussou/example-retail-credit-kjar business-application-service
45-
38+
1. Configure the KJAR the Spring Boot RHPAM Runtime App will use
39+
* Get the KJAR code locally if not available via public repo (NEXUS/Artifactory) and build the artifact in your local maven repo see xref:anchor-8[How To Deploy a KJAR into Central Maven Repo]). (some https://github.com/skoussou/JBossAutomationPlayground/tree/master/example-kjars[example KJARs here])
40+
* Update the list of KJARs to be added (immutable service) to the Spring Boot App by modifying one of the following
41+
[[anchor-2b]]
42+
** *Option-1*: Add in `application-XXX.properties` the following 2 properties
43+
*** `kieserver.classPathContainer=true`
44+
*** `kieserver.autoScanDeployments=true`
45+
** and *kie-maven-plugin* in `pom.xml` (see example https://github.com/elguardian/springboot-kjar-multiversion/blob/767dfada69a0777aae8d5870f22dd50aab21de3c/business-application-service/pom.xml#L53) *with the list of KJARs*
46+
** *Option-2*: Add in `application-XXX.properties` only the following property
47+
*** `kieserver.classPathContainer=true`
48+
*** add a *Bean* in the code with the following content:
49+
+
50+
@Configuration
51+
public class KieContainerDeployer {
52+
@Bean
53+
public KieContainerResource evaluation_v1() {
54+
KieContainerResource container = new KieContainerResource("evaluation_v1", new ReleaseId("com.myspace", "Evaluation", "1.0.0-SNAPSHOT"), STARTED);
55+
container.setConfigItems(Arrays.asList(new KieServerConfigItem(KieServerConstants.PCFG_RUNTIME_STRATEGY, "PER_PROCESS_INSTANCE", "String")));
56+
return container;
57+
}
58+
@Bean
59+
public KieContainerResource evaluation_v2() {
60+
KieContainerResource container = new KieContainerResource("evaluation_v2", new ReleaseId("com.myspace", "Evaluation", "2.0.0-SNAPSHOT"), STARTED);
61+
container.setConfigItems(Arrays.asList(new KieServerConfigItem(KieServerConstants.PCFG_RUNTIME_STRATEGY, "PER_PROCESS_INSTANCE", "String")));
62+
return container;
63+
}
64+
}
65+
+
66+
*** add *kie-maven-plugin* in `pom.xml` (see example https://github.com/elguardian/springboot-kjar-multiversion/blob/767dfada69a0777aae8d5870f22dd50aab21de3c/business-application-service/pom.xml#L53) (no need to explicitly list the KJARs in the plugin)
67+
** *Option-3*: Add the plugin as in *Option 2* and in `application-XXX.properties` all KJARs as follows per KJAR
68+
+
69+
kieserver.deployments[0].alias=basic
70+
kieserver.deployments[0].containerId=basic_100
71+
kieserver.deployments[0].artifactId=basic-kjar
72+
kieserver.deployments[0].groupId==com.redhat
73+
kieserver.deployments[0].version=1.0.0
74+
+
75+
[[anchor-2c]]
76+
* update the `kie-server-state` file (there are 2 examples in this repo business-application-service.xml, business-rules-application-service.xml)
77+
** ensure the file name `your-service-name.xml` will match in all the `application-XXX.properties` the value of configurations `kieserver.serverId`, `kieserver.Name`). This is the name of the Business Service
78+
** ensure there are in the `your-service-name.xml` a `<container>` section for each KieContainter/KJAR to be loaded at runtime
79+
+
4680
2. Run the Service as local SpringBoot App and xref:anchor-6[Use the KJAR Springboot Service APIs]
4781
* No external DB dependencies
4882

49-
mvn spring-boot:run -Dspring-boot.run.profiles=h2 -Dspring-boot.run.jvmArguments="-Dkie.maven.settings.custom=settings-local-only.xml -Dorg.kie.server.startup.strategy=LocalContainersStartupStrategy"
83+
mvn spring-boot:run -Dspring-boot.run.profiles=h2 -P h2 -Dspring-boot.run.jvmArguments="-Dkie.maven.settings.custom~/.m2/settings.xml -Dorg.kie.server.startup.strategy=LocalContainersStartupStrategy"
5084

5185
* use *-Dspring-boot.run.profiles=mysql* and *-P mysql* to use with an external Mysql database and update *_src/main/resources/application-mysql.properties_* with DB connection details
5286
* use *-Dspring-boot.run.profiles=postgres* and *-P postgres* to use with an external PostgresSQL database and update *_src/main/resources/application-postgres.properties_* with DB connection details
87+
* Access API at http://127.0.0.1:8090/rest/api-docs?url=http://localhost:8090/rest/server/swagger.json[http://127.0.0.1:8090/rest/api-docs?url=http://localhost:8090/rest/server/swagger.json]
88+
5389

5490

5591
=== How To Use as local Docker container
@@ -62,19 +98,9 @@ first start at xref:anchor-1[How To Use this Repo]
6298

6399
first start at xref:anchor-1[How To Use this Repo]
64100

65-
1. Configure in `pom.xml` under https://github.com/skoussou/springboot-business-app/blob/master/pom.xml#L87[artifacts section] the KJARs you plan to deploy in your service (*Important:* KJARs need to be deployed in NEXUS if using a central maven repo. See xref:anchor-8[How To Deploy a KJAR into Central Maven Repo])
66-
67-
<artifacts>
68-
<gav>com.redhat:basic-kjar:1.0.0</gav>
69-
<gav>com.redhat:basic-kjar:2.0.0</gav>
70-
<gav>com.redhat:example-retail-credit-kjar:1.0.0</gav>
71-
</artifacts>
72-
73-
2. Configure `your-service-name.xml` (see `business-application-service.xml` as an example and must match `application-openshift.properties` properties `kieserver.serverId`, `kieserver.Name`)
74-
* one *<container>* sectio for each KJAR above
75-
76-
3. Configure the `artifactId` and `version` based on your `pom.xml` in the https://github.com/skoussou/springboot-business-app/blob/master/Dockerfile#L6[`Dockerfile`]
77-
101+
1. Configure in your RHPAM Spring Boot Service the KJARs (see xref:anchor-2b[How to Configure KJARs in immutbale RHPAM Service]) you plan to deploy in your service (*Important:* KJARs need to be deployed in NEXUS if using a central maven repo. See xref:anchor-8[How To Deploy a KJAR into Central Maven Repo])
102+
2. Configure the `kie-server-state` file (see xref:anchor-2c[Configure KIE Server state file]) so that the resulting Openshift Spring Boot Image will contain the configured KIEContainers in
103+
3. Configure the `artifactId` and `version` based on your `pom.xml` in the link:./src/main/docker/Dockerfile#L6[`Dockerfile`]
78104
4. Configure database connection details in `application-openshift.properties` to connect to either an _external database_ or create a MySQL database service in openshift
79105

80106
* Create necessary *mysql* database service dependency (see `application-openshift.properties`)
@@ -88,20 +114,20 @@ first start at xref:anchor-1[How To Use this Repo]
88114

89115
5. Change the service name according to the `artifact-id` in your `pom.xml` for https://github.com/skoussou/springboot-business-app/blob/master/src/main/fabric8/service.yml[`service.yml`] and https://github.com/skoussou/springboot-business-app/blob/master/src/main/fabric8/route.yml[`route.yml`]
90116

91-
==== Run the service in K8s/Openshift cluster (fabric8) - NON-CICD
117+
==== Run the service in K8s/Openshift cluster (JKube) - NON-CICD
92118

93-
first start at xref:anchor-4[How To Use in Openshift]
119+
First start at xref:anchor-4[How To Use in Openshift]
94120

95121
1. Use the *openshift* profile to *Build App*, *Build KJAR Maven Dependencies Repo*, *Build Image with Repo*, *Create resoures bc/dc*
96122
* Build and deploy in OCP
97123

98-
mvn clean package -DskipTests=true -P openshift -Dmaven.artifact.threads=50 -s settings-nexus.xml
99-
mvn fabric8:deploy -Dfabric8.namespace=dev-pam -DskipTests=true -P openshift -Dmaven.artifact.threads=50 -s settings-nexus.xml
124+
mvn clean package -DskipTests=true -P openshift -Dmaven.artifact.threads=50 -s ~/.m2/settings.xml
125+
mvn oc:deploy -Djkube.namespace=dev-demo -DskipTests=true -P openshift -Dmaven.artifact.threads=50 -s ~/.m2/settings.xml
100126

101127
* Check the created OCP resources
102128

103129
oc get all -l app=business-application-service
104-
oc get all -l version=2.2.14
130+
oc get all -l version=3.0.0
105131

106132
2. Get to Swagger API and xref:anchor-6[Use the KJAR Springboot Service APIs]
107133

0 commit comments

Comments
 (0)