How to deploy a Camel Spring Boot application to OpenShift?

Solution Verified - Updated

Environment

Camel Spring Boot (CSB)
- 3.14
- 3.18
- 3.20
OpenShift
- 4.10

Issue

How to deploy a Camel Spring Boot application to OpenShift?

Resolution

The certified OpenShift is listed on this article.
https://access.redhat.com/articles/6970899

As noted on the article, Red Hat OpenJDK 11 (ubi8/openjdk-11) container image will be used for CSB.

Step 1: install IS
Please check this page and follow the instruction.
This content is not included.This content is not included.https://catalog.redhat.com/software/containers/ubi8/openjdk-11/5dd6a4b45a13461646f677f4?container-tabs=gti

oc import-image ubi8/openjdk-11:1.14-5 --from=registry.access.redhat.com/ubi8/openjdk-11:1.14-5 --confirm

The version might not be the same. For this article, 1.14-5 will be used.

From CSB 3.18, OpenJDK 17 is also certified. If you want to use OpenJDK17, please use this ImageStream.
This content is not included.This content is not included.https://catalog.redhat.com/software/containers/ubi8/openjdk-17/618bdbf34ae3739687568813?container-tabs=gti

Step 2: generate a sample maven program
Please follow the instruction on the official document.
2022 Q3 Release
https://access.redhat.com/documentation/en-us/red_hat_integration/2022.q3/html/getting_started_with_camel_spring_boot/getting-started-with-camel-spring-boot_csb#generting-a-csb-application-using-maven
2022 Q4 Release
https://access.redhat.com/documentation/en-us/red_hat_integration/2022.q4/html/getting_started_with_camel_spring_boot/getting-started-with-camel-spring-boot_csb#generting-a-csb-application-using-maven

Step 3: modify pom.xml
Add property, <jkube.generator.from>, and specify the IS name at Step 1.

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <spring.boot-version>2.7.1</spring.boot-version>  // This version might be changed in the future release.
    <surefire.plugin.version>3.0.0-M4</surefire.plugin.version>
    <jkube.generator.from>registry.access.redhat.com/ubi8/openjdk-11:1.14-5</jkube.generator.from>
  </properties>

Add openshift-maven-plugin.
Because of This content is not included.CSB-646, The version for Fuse 7.11 is used for now.
Once CSB 3.14.5.redhat-00012 released, please use "org.eclipse.jkube:openshift-maven-plugin:1.9.1.redhat-00004".

          <plugin>
            <groupId>org.jboss.redhat-fuse</groupId>
            <artifactId>openshift-maven-plugin</artifactId>
            <version>7.11.0.fuse-sb2-7_11_0-00028-redhat-00001</version>
            <executions>
              <execution>
                <goals>
                  <goal>resource</goal>
                  <goal>build</goal>
                  <goal>apply</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

Step 4: build and deploy
Under the directory which the modified pom.xml exists, execute the following command.

mvn clean -DskipTests oc:deploy

Step 5: confirm
You could observe that the CSB is running on the pod.

Root Cause

This content is not included.CSB-568
This content is not included.CSB-646

Components
Category
Tags

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.