Running MicroProfile applications on Openshift

In this tutorial we will learn how to deploy a Thorntail application on Openshift. This is the quickest path to leverage Microprofile applications in a PaaS.

Thorntail is the new name for WildFly Swarm, and contains everything you need to develop and run Microprofile applications by packaging server runtime libraries with your application code and running it as Uber Jar application.

In order to deploy Thorntail application we need a Java Runtime that can be used to run the JAR file produced by Thorntail Maven plugin. For this purpose we will use Red Hat Java S2I builder image

Red Hat Java S2I for OpenShift is a Source-to-Image (S2I) builder image designed for use with OpenShift. It allows users to build and run plain Java applications (fat-jar and flat classpath) within a containerized image on OpenShift.

Let’s start by creating a new Openshift project named “microprofile-demo”:

oc new-project "microprofile-demo"

Now let’s import the Java version 8 image from Red Hat’s Repository:

oc import-image java:8 --confirm

Now let’s use any Thorntail example available on Github. For example this is my fork of Thorntail’s examples:

oc new-app --name rest-demo 'java:8~' --context-dir='jaxrs/jaxrs-cdi'

As you can see from the output, the following resources will be created:

--> Found image b4b953c (2 weeks old) in image stream "microprofile-demo/java" under tag "8" for "java:8"

    Java Applications 
    Platform for building and running plain Java applications (fat-jar and flat classpath)

    Tags: builder, java

    * A source build using source code from will be created
      * The resulting image will be pushed to image stream tag "rest-demo:latest"
      * Use 'start-build' to trigger a new build
    * This image will be deployed in deployment config "rest-demo"
    * Ports 8080/tcp, 8443/tcp, 8778/tcp will be load balanced by service "rest-demo"
      * Other containers can access this service through the hostname "rest-demo"

--> Creating resources ... "rest-demo" created "rest-demo" created "rest-demo" created
    service "rest-demo" created
--> Success
    Build scheduled, use 'oc logs -f bc/rest-demo' to track its progress.
    Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
     'oc expose svc/rest-demo' 
    Run 'oc status' to view your app.

Great! now we only need to expose the Service through a Route so that we can test it:

$  oc expose svc/rest-demo

Check that the Pod has started:

Thorntail application on Openshift

Now we can test the application, as discussed in the of the project:

curl |jq
    "id": 1,
    "name": "emp01"
    "id": 2,
    "name": "emp02"

Basically this application showed how to create a REST Service in a MicroProfile applications. As you can see, running Microprofile applications with Openshift is pretty simple and you can combine its features with the standard Enterprise API that are available as Thorntail fractions.