There are many good examples that demonstrate specific MicroProfile functionality and there are also good examples that showcase Istio functionality, especially the BookInfo application. Since I couldn’t find a comprehensive application that utilizes MicroProfile and Istio, my colleague Harald Uebele and I have built one.
The example is available as open source. The GitHub repo is called cloud-native-starter. It contains a lot of useful information for Java developers to get started with microservices and to learn cloud-native patterns.
Kubernetes, Istio and Java
When building cloud-native applications, developers are challenged to figure out how to address topics like traffic routing, resiliency, distributed monitoring, service discoveries and more. Fortunately most of these new challenges are handled by the orchestration platform Kubernetes and the service mesh Istio. This functionality works generically for microservices, regardless of the language they are implemented in and without changes to the application logic.
However, some functionality can not be covered by orchestration platforms and service meshes. Instead it must be handled in the business logic of the microservices, for example application specific failover functionality, metrics, and fine-grained authorizations.
Java developers can leverage Eclipse MicroProfile to implement this functionality. MicroProfile is an extension to Java EE (Enterprise Edition) to build microservices-based architectures and it complements Kubernetes and Istio capabilities. In addition to the application specific logic which Kubernetes and Istio cannot handle, it also comes with convenience functionality that you typically need when developing microservices, for example mechanisms to invoke REST APIs and functionality to implement REST APIs including their documentation.
The example application follows these design principles:
- Leverage platforms as much as possible – Use frameworks for app specific logic
- Use open-source components for the core services of the application only
- Make the first time experience as simple as possible
- Be able to run the application in different environments
Let me explain the design principles in more detail.
Leverage platforms as much as possible – Use frameworks for app specific logic
The advantage of using Kubernetes and Istio for features like traffic management is, that these features are language agnostic. Cloud-native applications can be, and often are, polyglot. This allows developers to pick the best possible languages for the specific tasks. Whenever possible, the example app utilizes platform features from Kubernetes and Istio.
For application specific logic, the example uses various MicroProfile functionality. Read the article MicroProfile, the microservice programming model made for Istio to learn how Istio and MicroProfile fit together.
Use open-source components for the core services of the application only
In order to reach as many developers as possible, the sample application uses for the core services of the application only open source projects. For example the Java stack leverages OpenJ9, OpenJDK from AdoptOpenJDK, OpenLiberty and MicroProfile. Kubernetes and Istio are obviously open source projects as well. The components of the application that are not available as open source are optional and can be exchanged.
Make the first time experience as simple as possible
There are many samples, snippets, articles and tutorials available for the various cloud-native features and many of them are really good. However, I’ve had issues to run some of these features together in one application. Sometimes they used different Java stacks, sometimes different versions and sometimes the articles were outdated.
The example application shows several features working together, see below for details. There are also scripts to deploy services very easily, basically one script per service, similar to the ‘cf push’ experience for Cloud Foundry applications.
Be able to run the application in different environments
Fortunately this is one of the main advantages of Kubernetes since you can run workloads on-premises, hybrid or public cloud infrastructures. The repo has instructions how to deploy the application to Minikube and to the managed IBM Cloud Kubernetes Service.
Functionality of the Sample Application
The project demonstrates the following functionality:
- Dockerizing Java MicroProfile services
- Traffic management
- Authentication and authorization
- REST APIs implementations including documentation
- REST API invocations
- Monitoring and metrics
- Distributed logging and monitoring
The deck How to develop your first cloud-native Applications with Java gives an overview of the application functionality.
This diagram shows the services and components:
The web application invokes an API of a BFF (backend for frontend) service to display articles with authors.
Call to Action
If you want to learn cloud-native applications, get the code of the example application and follow the instructions to set up a local Minikube environment and to deploy the microservices. If you have already a Kubernetes cluster, the setup should not take longer than half an hour.
You can also run this application on the IBM Cloud Kubernetes Service which is a managed service that comes with an Istio plugin. IBM provides an IBM Cloud Lite account which is free, no credit card is required and there is no time restriction. In order to use the Kubernetes service, contact Harald and myself to get a promo code. Then follow these instructions to deploy the services to the IBM Cloud.
As always, I’d like to get feedback. Please let me know what you think about the example and how it could be improved. My direct messages on Twitter are open: @nheidloff