In this blog post I want to show the easy setup of an own MicroProfile/OpenLiberty project with MicroProfileStarter . From my perspective that is very useful for new Java developers, who want to build microservices. The prerequisite is, you have installed maven and Java on your local machine.
You can use for more information the MicroProfileStarter it self and the OpenLiberty getting started documentation.
That’s fits perfect to the topic Cloud-Native. Maybe you already know, we (Niklas, Harald and I) working on the open sourced Cloud Native Starter project. That project contains sample code that demonstrates, how to get started with Cloud-Native applications and microservices based architectures. Here we use also MicroProfile/OpenLiberty.
We created a new 60 -90 min hands-on workshop with the focus on Java microservice development with MicroProfile/OpenLiberty and the deployment to Kubernetes on IBM Cloud. This workshop is perfect to get a basic understanding of the Cloud-Native and Java development topics and the combination with MicroProfileStarter is awesome for newer Java Developers.
Let’s start with the usage of the MicroProfileStarter. The MicroProfileStarter creates two microservices called service-a and service-b, which do implement the selected functionalities for MicroProfile. It took me less than 10 min to get the microservices up and running.
Here are the steps:
- Step 1: Just configure the project name and content with MicroProfileStarter. In my situation I select Health Checks, Fault Tolerance, OpenAPI and TypeSafe RestClient functionalities, which we also use in our Cloud Native Starter project. In the gif you see, how easy the web configuration is.
- Step 2: Now unzip the downloaded file and open the folder with an editor. Here you find two microservices projects. Just take a brief look in readme’s and the pom file .
- Step 3: Then open two terminal sessions. One in each project directories of the microservices and follow the steps written in the readme’s.In the last output of the gif, we see the different URLs, where we also can check our different used functionalities of MicroProfile .
$ mvn install liberty:run-server $ mvn clean package $ java -jar target/sample.jar
Btw. I used the command:
$ mvn install liberty:run-server
- Step 4: Verify the implementation of microservices
Just visit http://localhost:8181/index.html and test the functionalities, as described in the readme.
With these steps we created two microservices based on MicroProfile/OpenLiberty very easily on our local machine, that is awesome. By the way, there is also a new visual studio code integration for the MicroProfileStarter available.
But microservices are running usually on Kubernetes. How to setup that? Just take a look in our Cloud Native Starter project and in the hands-on workshop. Here we show how build and deploy the service to Kubernetes. We build and test the container locally, with docker and deploy the microservice container to Kubernetes. In our hands-on workshop we define a Dockerfile for the microservice and we specify the deployment and service for Kubernetes. Check it out 😉
I hope this was useful for you and let’s see what’s next?
Greetings,
Thomas
PS: You can try out Cloud Foundry Apps or Kubernetes on IBM Cloud. By the way, you can use the IBM Cloud for free, if you simply create an IBM Lite account. Here you only need an e-mail address.
#ibmdeveloper, #microprofile, #openliberty, #cloudnativestarter, #cns, #kubernetes, #docker
Leave a Reply