Developing and debugging Microservices with Java

Kubernetes has become the de facto standard for deploying and managing containerized applications in public, private and hybrid cloud environments. While Kubernetes is really powerful, it’s not the easiest way for developers to deploy applications.

To make developers more productive, several technologies have emerged to make creations and deployments of applications on Kubernetes easier, for example Cloud Foundry, which can be run on Kubernetes, and Knative.

Another technology is Microclimate. Here is the description from the Microclimate home page:

Microclimate is an end to end development environment that lets you rapidly create, edit, and deploy applications. Applications are run in containers from day one and can be delivered into production on Kubernetes through an automated DevOps pipeline using Jenkins.

In the easiest case developers can write microservices locally and push code via git which triggers pipelines that generate the images and run the containers. This works when running locally, it is supported for IBM Cloud Private and with scripts and Helm charts microservices can be also deployed to other Kubernetes platforms like IBM Cloud.

Let’s take a closer look how to use Microclimate locally. Via the web application developers can create new projects in Java, Node.js, Python, Swift and Go.

microclimate-1

For Java projects you can choose between MicroProfile/Java EE, Spring and Lagom. In my example I’ve used MicroProfile.

microclimate-2

The following screenshot shows the overview page of the project. I’ve put the code on GitHub. Whenever the code changes, pipelines can be triggered automatically.

microclimate-3

For smaller changes Microclimate comes with an integrated text editor in the web application.

microclimate-4

In addition to the build logs and application logs, application metrics are displayed too (Garbage Collection Time, HTTP Throughput, Heap, HTTP Incoming Requests, CPU):

microclimate-5

In order to run Microclimate you need Docker since everything is containerized: Microclimate itself as well as the containers running your microservices. I like this concept a lot since it allows working in the same containers locally which are later deployed on Kubernetes. This minimizes the risk to run into issues because of different environments.

microclimate-6

For Eclipse and Visual Studio Code there are plugins to connect to Microclimate. This allows running and debugging your application code directly from the development environments. This is very similar to what I blogged about IBM Cloud Functions. The following screenshot shows the debugger in Visual Studio Code accessing the running code in a container.

microclimate-7

You can also do changes from the IDEs and run the changed code without having to restart containers or application servers manually!

Check out the Microclimate documentation to learn more.