Deploying a Quarkus App on OpenShift With S2I and OpenShift Pipelines
Here's a quick guide to creating a pipeline to deploy your Quarkus app with S2I on OpenShift.
Join the DZone community and get the full member experience.
Join For FreeIn this article, I'll guide you through a simple way to deploy your Quarkus app on OpenShift by creating a Pipeline and using Source-to-Image(S2I) capabilities.
Pre-Requisites
You can create your free account on here and try OpenShift for free locally using Code Ready Containers, and for the app, we're deploying we'll be using a simple timezone converter camel route that is available here.
Installing OpenShift Pipelines
To install the Openshift pipelines operator we go to the Operator Hub and search for Openshift Pipelines.
And we install with the recommended options.
When the Operator is installed and ready we move on to deploy the application
The Quarkus S2I Configuration
For the S2I process to function correctly in Openshift, we need to create a folder called .s2i with a file called environment and add the following to the file
MAVEN_S2I_ARTIFACT_DIRS=target/quarkus-app
S2I_SOURCE_DEPLOYMENTS_FILTER=app lib quarkus quarkus-run.jar
JAVA_OPTIONS=-Dquarkus.http.host=0.0.0.0
AB_JOLOKIA_OFF=true
JAVA_APP_JAR=/deployments/quarkus-run.jar
With this, we ensure the correct behavior of the S2I process.
Deploying the App and the Pipeline
Now we change for the developer perspective in Openshift and will add an application from there.
We'll choose +add -> From Git and add these values as per the screenshot below:
Git Repo Url: here
Git Reference: main
Context-dir: /quarkus-camel-tz-converter
For the builder image, we can use any of the java-11 available (openjdk-11-ubi8 or openjdk-11-el7) and we'll check the box that says Add pipeline, so it'll suggest a base template parameter for java based apps just like the screenshot below:
With that done we click on create and wait for our pipeline to execute. We can check by going to the Pipeline Runs screen.
Testing the App
To test the app we can make a curl request to the route and see that our value is converted.
curl $(oc get route camel-examples-git -o jsonpath='{.spec.host}')/convert/2021-07-20%2011%3A30/UTC/Universal
2021-07-20T11:30
Next Steps
A good next step is to deploy using the native builder image, but this will be covered in another article. Hope you all enjoy this simple way of deploying a Quarkus app on OpenShift.
Opinions expressed by DZone contributors are their own.
Comments