In this part of the workshop you’ll experience how modern software development using the OpenShift tooling can be done in a fast, iterative way. Inner loop here means this is the way, sorry, process, for developers to try out new things and quickly change and test their code on OpenShift without having to build new images all the time or being a Kubernetes expert.
OpenShift Dev Spaces is a browser-based IDE for Cloud Native Development. All the heavy lifting is done through a container running your workspace on OpenShift. All you really need is a laptop. You can easily switch and setup a customized environment, plugin, build tools and runtimes. So switching from one project context to another is as easy a switching a website. No more endless installation and configuration marathons on your dev laptop. It is already part of your OpenShift subscription. If you want to find out more have a look here
openshift-operators
status > chePhase: Active
), look up the devspaces
Route in the openshift-workspaces
project (If you can see the openshift-workspaces
, you may need to toggle the Show default project button).We could create a workspace from one of the templates that come with Dev Spaces, but we want to use a customized workspace with some additionally defined plugins in a v2 devfile in our git repo. With devfiles you can share a complete workspace setup and with the click of a link and you will end up in a fully configured project in your browser.
You will now need to access the Gitea repository where your Quarkus app resides and specifically get the path to the devfile.
git
project in openshift and then Networking > Routesgitea/quarkus-build-options
devspaces_devfile.yml
It is important that you have the URL to the Raw version, otherwise DevSpace will recieve a website that it cannot parse.
Now back in your DevSpaces Workspace :
Yes, I trust the authors
When your workspace has finally started, have a good look around in the UI. It should look familiar if you have ever worked with VSCode or similar IDEs.
While working with Dev Spaces make sure you have AdBlockers disabled, you are not on a VPN and a have good internet connection to ensure a stable setup. If you are facing any issues try to reload the Browser window. If that doesn’t help restart the workspace in the main DevSpaces Web Console under Workspaces and then menu Restart Workspace
As an example you’ll create a new Java application. You don’t need to have prior experience programming in Java as this will be kept really simple.
We will use a Java application based on the Quarkus stack. Quarkus enables you to create much smaller and faster containerized Java applications than ever before. You can even transcompile these apps to native Linux binaries that start blazingly fast. The app that we will use is just a basic example created with the Quarkus Generator with a simple RESTful API that answers to http requests. But at the end of the day this setup will work with any Java application.
Fun fact: Every OpenShift Subscription already provides a Quarkus Subscription.
Let’s clone our project into our workspace :
OpenShift DevSpaces
in your browsergit clone
until you can select the Git: Clone item
Git URL
to your Gitea Repository (You can copy the URL by clicking on the clipboard icon in Gitea) and press enter
/projects
dir, then click the button OKYes, I trust the authors
again. Last time, promise :)
Now we want to create a new OpenShift project for our app:
terminal
in your DevSpaces IDE
oc
OpenShift cli client is already installed and you are already logged into the clusterworkshop-dev
oc new-project workshop-dev
odo or ‘OpenShift do’ is a cli that enables developers to quickly get started with cloud native app development without being a Kubernetes expert. It offers support for multiple runtimes and you can easily setup microservice components, push code changes into running containers and debug remotely with just a few simple commands. To find out more, have look here
First we need to make sure we are in the folder of the cloned project.
Enter the following command in the terminal:
pwd
if you are not in the /projects/quarkus-build-options
folder, change into with the cd
command
odo is smart enough to figure out what programming language and frameworks you are using. So let’s let initialize our project
odo init
odo is now intialized for your app. Let’s deploy the app to openshift in odo dev mode
odo dev
This will compile the app, start a pod in the OpenShift project and inject the app.
There will be a couple of popups in the bottom right corner (Click on all of them as explained below)
New tabs will open. One with the DevFile Editor and one showing the Quarkus webpage of your app. You may have to wait a reload in a few seconds.
To test the app in the Quarkus App tab:
Your app should be displayed as a simple web page. In the RESTEasy JAX-RS
section click the @Path
endpoint /hello
to see the result.
Now for the fun part:
Using odo
you can dynamically change your code and push it again without the need t o build a new container image! No dev magic involved:
In your DevWorkspace on the left, expand the file tree to open file src/main/java/org/acme/GreetingRessource.java
and change the string “Hello RESTEasy” to “Hello Workshop” (DevSpaces auto saves every edit directly. No need to save the file manually.)
And reload the app webpage.
Bam! The change should be there in a matter of seconds