40

Developing and debugging Microservices with Java

 5 years ago
source link: https://www.tuicool.com/articles/hit/3AzuQrb
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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.

eY3eMjU.png!web

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

y2aIriZ.png!web

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.

mA36RvM.png!web

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

iyQjQzf.png!web

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

mANbMvN.png!web

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.

iIRnqaI.png!web

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 aboutIBM Cloud Functions. The following screenshot shows the debugger in Visual Studio Code accessing the running code in a container.

Vja2yuZ.png!web

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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK