This article explains how to deploy Quarkus applications on OpenShift as quickly as possible. All you need is an OpenShift cluster with enough memory. Everything else can be done in the browser.
In times of Corona in our team of developer advocates we do a lot of online workshops. There are great tools available to host these workshops, but they don’t replace the onsite experience. For example one thing that is difficult is that you can’t look easily over the shoulders of attendees and help them. Additionally attendees often don’t want to stay for hours.
Because of these reasons it needs to be possible for attendees to get started as quickly as possible and potential issues need to be minimised. The typical first lab where you need to set up prerequisites should be shortened or completely removed.
That’s why I’m very interested in CodeReady Workspaces which give you an IDE integrated in OpenShift. CodeReady Workspaces is based on the open source version Eclipse Che and can be installed in Kubernetes and OpenShift via operators. Check out my article Deploying CodeReady Workspaces to learn how to use Workspaces either locally via CodeReady Containers or in the IBM Cloud.
Let’s take a look how Quarkus applications can be developed in the browser and deployed to OpenShift.
Once you have CodeReady Workspaces installed, you can create a new workspace based on the ‘Quarkus Tools’ template. This template comes with the CLIs and runtimes you need, for example Maven, Java, the oc CLI etc.
Additionally every template contains the Eclipse Theia IDE which contains a text editor. The editor looks similar to Visual Studio Code, but is actually a different technologies. However, you can use Visual Studio Code plugins since both editors support the same plugin model. That allows for example to use the Java developer tools in the web editor.
The ‘Quarkus Tools’ workspace can be created with a Quarkus quick start sample. You can launch the application via the Maven terminal.
Run the command ‘./mvnw compile quarkus:dev’.
In order to access the application via URL an external route is generated. ‘localhost’ would obviously not work.
In order to deploy applications to Kubernetes and OpenShift, check out the Quarkus guides DEPLOYING ON OPENSHIFT and KUBERNETES EXTENSION. In this article the OpenShift extension is used which you can install via command line or from the web editor.
With the OpenShift extension all yaml files are generated automatically. The command ‘/mvnw clean package -Dquarkus.kubernetes.deploy=true’ triggers a container image build and will apply the generated OpenShift resources, right after. The generated resources are using OpenShift’s DeploymentConfig that is configured to automatically trigger a redeployment when a change in the ImageStream is noticed. In other words, any container image build after the initial deployment will automatically trigger redeployment, without the need to delete, update or re-apply the generated resources.
You can check in the user interface for the build status.
As result your image stream shows up in addition to the s2i-java image stream which is used to build your image.
The pod with your container will be started automatically. The second pod in the screenshot is the pod with the web IDE which consists of five containers.
To access the application you can create a route via the Maven command above, you can define it the application properties file in Quarkus or do it in the OpenShift web console.
To find out more about Quarkus, OpenShift and reactive programming, check out the open source project Cloud Native Starter.