OpenShift: Bringing to life a SpringBoot binary

This article promises on bringing a SpringBoot binary file to life and make from it a fully running application on OpenShift.

Our today’s Use-Case: Deploy to Openshift a resultant artifact of an already built packaged springboot application. This is useful for software built on a platform different from the one where the application is going to run.

Prerequisites for our Experiments

First, we need a running OpenShift cluster on which we can do our experiments. I invite you then to run the next steps using either a free account on or download & run an OpenShift cluster locally using minishift.

Do not forget to download/install the OpenShift-Client tool.

Our Project

OpenShift provides natively with different options for building and deploying containers, which includes building/deploying applications either from source code or from binaries.

Platforms like Java allows developers to package all the dependencies, resources and configuration files in a single archive file, which we call JAR binary files.

Our project is based on an OpenSource SpringBoot project. The JAR file can be downloaded from hereHelloWorld-2.0.jar”. I renamed the file to “springboot.jar” and placed it in a deployments folder.

Build Process

For our use-case, we need a builder image that contains tools like Maven to build our artifacts provided as a jar file.

In OpenShift, an OpenJDK Image stream is already provided in the “openshift” namespace.

Let’s check what images are available for us:

Create a new Project

Let’s start by creating an OpenShift project.

Create a new Build

We’re going to use a builder image, so we’ll use the “redhat-openjdk18-openshift”. The following creates a build, and accept a binary content as a source.

Here we are naming the application as myspringboot.

Executing the Build

Once the BuildConfig is created in OpenShift, we can then take care of the creation of a final docker container image. This image is based on OpenJDK as a Base-Image and our artifact file, which is mainly a binary JDK file.

The command starts by uploading/copying the binary file into the appropriate location within the destination container.

The “ — follow” flag is helpful as it provides you with the ability to watch the build logs.

You can check the builds history by launching this command:

Create the Application

Now we already have the image built, including the application artifcats. One easy step is remaining to make the application deployed and up & running.

Let’s launch the creation of our spring boot application:

As a result, this command dynamically generates a DeploymentConfig, make the application run as pods and expose it using a Service. However, there is no route for this application yet. So you cannot access this application from outside.

Expose your application

Let’s create an OpenShift route to make the “myspringboot” service exposed to the internet.

We can check the exposed routes:

Let’s curl our application:

What’s next?

We’ve succeeded in building, and deploying a basic JAR file. Now there’s an opportunity to improve these experiments and I have some suggestions for you:

  • Set up a Github webhooks to react to source code changes,
  • Make the exposed route secure,
  • Make it repeatable and configurable: abstract all the complexities in one template and then instantiate the template by providing the location of the artifacts.

This how you can export / create a template file from an existing OpenShift resources:

Please do not hesitate to tweet me with your valuables comments/questions.

Is a DevOps & Cloud enthusiast with 10 plus years of experience. He’s continuously immersing himself in the latest technologies trends & projects.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store