This project contains sample code that demonstrates how to get started with cloud-native applications and microservice based architectures.
The project focusses on how to build microservices with Java EE and the open source technologies Eclipse MicroProfile, Eclipse OpenJ9, AdoptOpenJDK and Open Liberty.
The microservices can be easily deployed on Kubernetes environments running Istio like Minikube or the IBM Cloud Kubernetes Service.
The project showcases the following functionality:
- REST APIs implementations incl. documentation
- REST API invocations
- Traffic management
- Resiliency via fallbacks and circuit breakers
- Authentication and authorization
- Distributed tracing and logging
- Monitoring and metrics
This diagram shows the key components:
The next screenshot shows the web application. More screenshots are in the images folder.
The sample application can be run locally on Minikube or on the IBM Cloud. The following instructions describe how to install everything locally.
If you would like to run the cloud native starter application on IBM Cloud Kubernetes Service, follow these instructions.
Before the microservices can be installed, make sure you've set up Minikube and Istio correctly or follow these instructions to set up Minikube and Istio from scratch. This should not take longer than 30 minutes.
The microservices can be installed via scripts. In addition to Minikube and Istio you need the following tools to be installed.
Prerequisites:
Deploy (and redeploy):
$ git clone https://github.com/nheidloff/cloud-native-starter.git
$ cd cloud-native-starter
$ scripts/check-prerequisites.sh
$ scripts/deploy-articles-java-jee.sh
$ scripts/deploy-web-api-java-jee.sh
$ scripts/deploy-authors-nodejs.sh
$ scripts/deploy-web-app-vuejs.sh
$ scripts/deploy-istio-ingress-v1.sh
$ scripts/show-urls.sh
After running the scripts above, you will get a list of all URLs in the terminal.
Example URL to open the web app: http://192.168.99.100:31380
Example API endpoint: http://192.168.99.100:31380/web-api/v1/getmultiple
In order to demonstrate traffic routing you can run the following commands. 20 % of the web-api API request to read articles will now return 10 instead of 5 articles which is version 2. 80 % of the requests are still showing only 5 articles which is version 1.
$ scripts/deploy-web-api-java-jee-v2.sh
$ scripts/deploy-istio-ingress-v1-v2.sh
In order to demonstrate resiliency you can run the following command to delete the authors service:
$ scripts/delete-authors-nodejs.sh
In the next step delete the articles service:
$ scripts/delete-web-api-java-jee.sh
The web-api service produces some application specific metrics.
Run 'scripts/show-urls.sh' to get the URL to display the unformatted metrics of this microservice (for example http://192.168.99.100:31223/metrics/application) as well as the URL to generate load (for example http://192.168.99.100:31223/web-api/v1/getmultiple).
In order to display the metrics with the Prometheus UI, Prometheus needs to be configured first:
$ scripts/configure-prometheus.sh
After this wait until the Prometheus pod has been restarted. Then run the command to forward the Prometheus port which is displayed as result of 'scripts/configure-prometheus.sh'.
The metrics are displayed in the Prometheus UI (http://localhost:9090) when you search for 'web-api' or 'articles'.
For example the amount of times /web-api/v1/getmultiple has been invoked can be displayed as well as the duration of these requests.
Run the following command to delete all cloud-native-starter components from Istio.
$ scripts/delete-all.sh
You can also delete single components:
$ scripts/delete-articles-java-jee.sh
$ scripts/delete-articles-java-jee-quarkus.sh
$ scripts/delete-web-api-java-jee.sh
$ scripts/delete-authors-nodejs.sh
$ scripts/delete-web-app-vuejs.sh
$ scripts/delete-istio-ingress.sh
Here is a series of blog entries about this project:
- Setup of a Local Kubernetes and Istio Dev Environment
- Debugging Microservices running in Kubernetes
- Dockerizing Java MicroProfile Applications
- Developing resilient Microservices with Istio and MicroProfile
- Using Quarkus to run Java Apps on Kubernetes
- Managing Microservices Traffic with Istio
- Web Application to demo Traffic Management with Istio
- Implementing and documenting REST APIs with JavaEE
- Invoking REST APIs from Java Microservices
- Prometheus Metrics for MicroProfile Microservices in Istio
- Moving from Minikube to IBM Cloud Kubernetes Service
- Distributed logging with LogDNA
- Monitoring with IBM Cloud Monitoring with Sysdig
- Istio Healthchecks for MicroProfile Microservices
- Configuration of MicroProfile Microservices in Istio
- Authentication via OpenID Connect
- Authorization via Istio
- Authorization via MicroProfile
- SQL PersistenceSQL via JPA and JDBC
Here is more information about Microservices, MicroProfile and Istio:
- MicroProfile, the microservice programming model made for Istio
- Migrating Java Microservices to MicroProfile – Epilogue
- Video: Istio Platform vs Spring and MicroProfile frameworks
- Video: Java EE, Jakarta EE, MicroProfile, Or Maybe All Of Them?
- Video: Istio: Canaries and Kubernetes, Microservices and Service Mesh