Skip to content

Commit ab33fdc

Browse files
authored
OCP SpringBoot first draft (#142) (#3613)
* OCP SpringBoot first draft * UBI image change * OCP procedure now uses single JAR file * QE/SME review changes * Fixed BC monitoring connection from single Jar * make exposing route optional * SPringBoot SSL fix * Fix location port * XML tagging error * Set log location * Peer review * Temporarily exclude OCP SB
1 parent f8647c7 commit ab33fdc

File tree

4 files changed

+167
-15
lines changed

4 files changed

+167
-15
lines changed

_artifacts/document-attributes.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ endif::OP[]
103103
:FUSE_LONG: Red Hat Fuse
104104
:FUSE_VERSION: 7.9
105105
:FUSE_EAP_VERSION: 7.4
106+
:SPRING_BOOT_VERSION: 2.3.4
106107
:JWS: Red Hat JBoss Web Server
107108
:JWS_VERSION: 5.4
108109
:JWS_VERSION_LONG: 5.4.0

assemblies/assembly-springboot-business-apps.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ include::{enterprise-dir}/springboot/creating-self-contained-image-proc.adoc[lev
4949
include::{enterprise-dir}/springboot/bus-app-run_con.adoc[leveloffset=+1]
5050
include::{enterprise-dir}/springboot/bus-app-run-standard_con.adoc[leveloffset=+2]
5151
include::{enterprise-dir}/springboot/bus-app-run-managed_con.adoc[leveloffset=+2]
52+
53+
// include::{enterprise-dir}/springboot/openshift-springboot-proc.adoc[leveloffset=+1]
54+
5255
include::{enterprise-dir}/springboot/bus-app-import_proc.adoc[leveloffset=+1]
5356
include::{enterprise-dir}/springboot/spring-boot-jms-audit-proc.adoc[leveloffset=+1]
5457
include::{enterprise-dir}/springboot/audit-replication-parameters-ref.adoc[leveloffset=+2]

doc-content/enterprise-only/springboot/creating-self-contained-image-proc.adoc

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,20 @@ kieserver.autoScanDeployments=true
4646
|`kieserver.autoScanDeployments`
4747
|`true, false`
4848
|When set to `true`, {KIE_SERVER} scans and deploys all KJAR files available in the Spring Boot application, whether they are declared programmatically or through the Maven plug-in.
49-
5049
|===
51-
5250
+
5351
When both of these properties are set to `true`, the Spring Boot {KIE_SERVER} automatically scans for deployable artifacts that are packaged within the Spring Boot application using the `package-dependencies-kjar` Maven goal of the `kie-maven-plugin` plug-in.
5452
+
55-
. In the `<BUSINESS-APPLICATION>/<BUSINESS-APPLICATION>-service` directory, add the following Maven plug-in in the Spring Boot `service/pom.xml` file where `<GROUP_ID>`, `<ARTIFACT_ID>`, and `<VERSION>` are the group, artifact, and version (GAV) of a KJAR artifact that your project uses. You can find these values in the `pom.xml` file that is located in the KJAR source directory.
53+
If your business application will run in an {OPENSHIFT} pod or in any other environment where the current directory is not writable, add the `spring.jta.log-dir` parameter that points to a writable location. For example:
54+
+
55+
[source]
56+
----
57+
spring.jta.log-dir=/tmp
58+
----
59+
+
60+
This parameter sets the location for the transaction log.
61+
+
62+
. In the `<BUSINESS-APPLICATION>/<BUSINESS-APPLICATION>-service` directory, add the following Maven plug-in in the Spring Boot `pom.xml` file where `<GROUP_ID>`, `<ARTIFACT_ID>`, and `<VERSION>` are the group, artifact, and version (GAV) of a KJAR artifact that your project uses. You can find these values in the `pom.xml` file that is located in the KJAR source directory.
5663
+
5764
NOTE: You can add more than one version of an artifact.
5865
+
@@ -77,7 +84,7 @@ NOTE: You can add more than one version of an artifact.
7784
<artifactItems>
7885
<artifactItem>
7986
<groupId><GROUP_ID></groupId>
80-
<artifactId><ARTIFACT_ID>/artifactId>
87+
<artifactId><ARTIFACT_ID></artifactId>
8188
<version><VERSION></version>
8289
</artifactItem>
8390
</artifactItems>
@@ -122,12 +129,13 @@ The following example adds two version of the `Evaluation` artifact:
122129
</artifactItems>
123130
</configuration>
124131
</plugin>
125-
<plugins>
126-
<build>
132+
</plugins>
133+
</build>
127134
----
128135
ifdef::PAM[]
129136
+
130-
. Optional: if you want to be able to configure the {KIE_SERVER} to communicate with a {CENTRAL} Monitoring instance using WebSockets, add the following lines to the `pom.xml` file under the `<dependencies>` tag:
137+
. Optional: if you want to be able to configure the {KIE_SERVER} to communicate with a {CENTRAL} monitoring instance using WebSockets, make the following changes:
138+
.. Add the following lines to the `pom.xml` file under the `<dependencies>` tag:
131139
+
132140
[source, xml]
133141
----
@@ -138,7 +146,14 @@ ifdef::PAM[]
138146
</dependency>
139147
----
140148
+
141-
WebSockets communication with a {CENTRAL} Monitoring instance is supported in all cases, including running the instance on {OPENSHIFT}.
149+
WebSockets communication with a {CENTRAL} monitoring instance is supported in all cases, including running the instance on {OPENSHIFT}.
150+
.. In the `<BUSINESS-APPLICATION>/<BUSINESS-APPLICATION>-service/src/main/resources/application.properties` file, add or change the following properties:
151+
+
152+
[source]
153+
----
154+
kieserver.location=${org.kie.server.location}
155+
kieserver.controllers=${org.kie.server.controller}
156+
----
142157
endif::PAM[]
143158
+
144159
. To build the self-contained Spring Boot image, enter the following command in the `<BUSINESS-APPLICATION>/<BUSINESS-APPLICATION>-service` directory:
@@ -162,16 +177,26 @@ To configure the {KIE_SERVER} to connect to a {CENTRAL} monitoring instance usin
162177
+
163178
[source]
164179
----
165-
java -jar <FILENAME>.jar -Dorg.kie.server.startup.strategy=LocalContainersStartupStrategy
166-
-Dorg.kie.server.controller=ws://<BC-HOSTNAME>:<BC-PORT>/websocket/controller
167-
-Dorg.kie.server.controller.user=<USER> -Dorg.kie.server.controller.pwd=<PASSWORD>
180+
java -Dorg.kie.server.location=http://<LOCATION>:<PORT>/rest/server -Dorg.kie.server.controller=ws://<BC-HOSTNAME>:<BC-PORT>/websocket/controller -Dorg.kie.server.controller.user=<USER> -Dorg.kie.server.controller.pwd=<PASSWORD> -jar <FILENAME>.jar
168181
----
169182
+
170183
In this command, replace the following values:
171184
+
172-
** `<FILENAME>` with the name of the JAR file
173-
** `<BC-HOSTNAME>` with the fully qualified name of the {CENTRAL} Monitoring instance
185+
** `<LOCATION>` with the fully qualified host name for accessing your service. {CENTRAL} monitoring accesses the service to retrieve process information and displays a URL for the service with this host name
186+
** `<PORT>` with the port for accessing your service, for example, `8090`
187+
** `<BC-HOSTNAME>` with the fully qualified name of the {CENTRAL} monitoring instance
174188
** `<BC-PORT>` with the port of the {CENTRAL} Monitoring instance, for example, `8080`
175-
** `<USER>` with the username of a user configured on the {CENTRAL} Monitoring instance
176-
** `<PASSWORD>` with the password of the user configured on the {CENTRAL} Monitoring instance
189+
** `<USER>` with the username of a user configured on the {CENTRAL} monitoring instance
190+
** `<PASSWORD>` with the password of the user configured on the {CENTRAL} monitoring instance
191+
** `<FILENAME>` with the name of the JAR file
192+
+
193+
[NOTE]
194+
====
195+
This configuration uses unsecured HTTP communication for your service. If you configure your Spring Boot business application with a valid SSL certificate, you can replace `http:` with `https:` to use secure HTTPS communication. For more information about configuring SSL on Spring Boot, see https://docs.spring.io/spring-boot/docs/{SPRING_BOOT_VERSION}.RELEASE/reference/html/howto.html#howto-configure-ssl[Spring Boot documentation].
196+
====
197+
+
198+
[NOTE]
199+
====
200+
If you want to view process information from {CENTRAL} monitoring, you must ensure that the user that is logged into {CENTRAL} can also be authenticated with your service using the same password.
201+
====
177202
endif::PAM[]
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
[id='openshift-springboot-proc_{context}']
2+
= Running a SpringBoot business application on {OPENSHIFT}
3+
4+
To run your {PRODUCT} SpringBoot business application on {OPENSHIFT}, create an immutable image and push this image to your {OPENSHIFT} environment.
5+
6+
ifdef::PAM[]
7+
Optionally, you can also use {CENTRAL} Monitoring to monitor the execution of business processes in your application.
8+
endif::PAM[]
9+
10+
.Prerequisites
11+
12+
* You have developed a {PRODUCT} SpringBoot business application. For instructions about creating the application, see xref:bus-app-create_{context}[].
13+
* If necessary, you have configured Spring security for the application. For instructions about configuring Spring security, see xref:bus-app-security-con_{context}[].
14+
* You have completed any necessary additional Spring configuration for the business application. For instructions about Spring configuration for your business application, see xref:bus-app-configure-con_{context}[].
15+
* You created a single JAR file for the business application. For instructions about creating a single JAR file for your SpringBoot business application, see xref:creating-self-contained-image-proc_{context}[].
16+
* You are logged on to your {OPENSHIFT} environment using the `oc` command and the required project is active.
17+
ifdef::PAM[]
18+
* If you want to use {CENTRAL} Monitoring, you have installed {CENTRAL} Monitoring using the operator. Use the same namespace to deploy {CENTRAL} Monitoring and your business application.
19+
+
20+
[IMPORTANT]
21+
====
22+
You must configure {CENTRAL} Monitoring to use the controller startup strategy. To enable the controller strategy on {CENTRAL} Monitoring, in the *Console* tab of the operator configuration, add a `KIE_SERVER_CONTROLLER_OPENSHIFT_ENABLED` environment variable and set it to `false`.
23+
====
24+
endif::PAM[]
25+
26+
.Procedure
27+
28+
. Outside the business application project directories, create an `ocp-image` directory with the following subdirectories:
29+
+
30+
----
31+
ocp-image
32+
|--/root
33+
|--/opt
34+
|-- /spring-service
35+
----
36+
+
37+
. Copy the single JAR file for your business application into the `root/opt/spring-service` subdirectory. For example:
38+
+
39+
----
40+
cd ../business-application-service
41+
cp target/business-application-service-1.0-SNAPSHOT.jar ../ocp-image/root/opt/spring-service/
42+
----
43+
+
44+
. In the `ocp-image` directory, create a `Dockerfile` file with the following content:
45+
+
46+
----
47+
FROM registry.access.redhat.com/ubi8/openjdk-11:latest
48+
COPY root /
49+
EXPOSE 8090
50+
WORKDIR /opt/spring-service/
51+
CMD ["sh","-c", "java ${JAVA_OPTIONS} -Dorg.kie.server.mode=PRODUCTION -jar /opt/spring-service/<FILENAME>.jar"]
52+
----
53+
+
54+
Replace `<FILENAME>.jar` with the name of the single JAR file for your business application.
55+
+
56+
ifdef::PAM[]
57+
Alternatively, if you want to configure communication with {CENTRAL} Monitoring, use the following content for `Dockerfile`:
58+
+
59+
----
60+
FROM registry.access.redhat.com/ubi8/openjdk-11:latest
61+
COPY root /
62+
EXPOSE 8090
63+
WORKDIR /opt/spring-service/
64+
CMD ["sh","-c", "java ${JAVA_OPTIONS} -Dorg.kie.server.location=${KIESERVER_LOCATION} -Dorg.kie.server.controller=${KIESERVER_CONTROLLERS} -Dorg.kie.server.controller.user=${KIE_SERVER_CONTROLLER_USER} -Dorg.kie.server.controller.pwd=${KIE_SERVER_CONTROLLER_PWD} -Dorg.kie.server.mode=PRODUCTION -jar /opt/spring-service/<FILENAME>.jar"]
65+
----
66+
+
67+
Replace `<FILENAME>.jar` with the name of the single JAR file for your business application.
68+
+
69+
endif::PAM[]
70+
. To build the initial image and deploy it in your {OPENSHIFT} environment, complete the following steps:
71+
.. To build the image, run the following commands in the `ocp-image` directory:
72+
+
73+
----
74+
oc new-build --binary --strategy=docker --name openshift-kie-springboot
75+
oc start-build openshift-kie-springboot --from-dir=. --follow
76+
----
77+
+
78+
Optional: replace `openshift-kie-springboot` with a custom application name in these commands and all subsequent commands.
79+
+
80+
.. To deploy the image in the {OPENSHIFT} environment, run the following command:
81+
+
82+
----
83+
oc new-app openshift-kie-springboot
84+
----
85+
+
86+
ifdef::PAM[]
87+
Alternatively, to deploy the image and configure it to communicate with {CENTRAL} Monitoring, run the following command:
88+
+
89+
----
90+
oc new-app openshift-kie-springboot -e KIESERVER_LOCATION=http://<LOCATION>:<PORT>/rest/server -e KIESERVER_CONTROLLERS=ws://<BC-HOSTNAME>:<BC-PORT>/websocket/controller -e KIE_SERVER_CONTROLLER_USER=USER -e KIE_SERVER_CONTROLLER_PWD=PASSWORD
91+
----
92+
+
93+
In this command, replace the following values:
94+
+
95+
** `<LOCATION>` with the fully qualified host name for accessing your service. {CENTRAL} Monitoring accesses the service to retrieve process information and displays a URL for the service with this host name
96+
** `<PORT>` with the port for accessing your service, for example, `8090`
97+
** `<BC-HOSTNAME>` with the host name for accessing the {CENTRAL} Monitoring instance. If your application is deployed in the same project/namespace as the {CENTRAL} Monitoring instance, use the service name for {CENTRAL} Monitoring, for example, `myapp-rhpamcentrmon`. Otherwise, you can use use the fully qualified host name of a route for the {CENTRAL} Monitoring instance.
98+
** `<BC-PORT>` with the port of the {CENTRAL} Monitoring instance, for example, `8080`
99+
** `<USER>` with the username of a user configured on the {CENTRAL} Monitoring instance
100+
** `<PASSWORD>` with the password of the user configured on the {CENTRAL} Monitoring instance
101+
+
102+
[NOTE]
103+
====
104+
This configuration uses unsecured HTTP communication for your service. If you configure your Spring Boot business application with a valid SSL certificate, you can replace `http:` with `https:` to use secure HTTPS communication. For more information about configuring SSL on Spring Boot, see https://docs.spring.io/spring-boot/docs/{SPRING_BOOT_VERSION}.RELEASE/reference/html/howto.html#howto-configure-ssl[Spring Boot documentation].
105+
====
106+
+
107+
[NOTE]
108+
====
109+
If you want to view process information from {CENTRAL} Monitoring, you must ensure that the user that is logged into {CENTRAL} Monitoring can also be authenticated with your service using the same password.
110+
====
111+
+
112+
endif::PAM[]
113+
.. Optional: To expose the route for the image, run the following command:
114+
+
115+
----
116+
oc expose service/openshift-kie-springboot --port=8090
117+
----
118+
+
119+
. If you already built and deployed the image and need to update it, run the following command in the `ocp-image` directory:
120+
+
121+
----
122+
oc start-build openshift-kie-springboot --from-dir=. --follow
123+
----

0 commit comments

Comments
 (0)