Skip to content

Workshop: Get started to deploy a Java Microservices application to Code Engine

Objectives

The workshop addresses the topic containerized applications on IBM Cloud Code Engine.

After you complete this workshop, you'll have a basic understanding of the following:

  • Deploy an existing Java microservices containerized application example to Code Engine
    • See the usage of the IBM Cloud Code Engine CLI
  • Understand internal and external HTTP/HTTPS routing between the microservices
  • Use the Out-Of-The-Box monitoring for the example application
  • Use the Out-Of-The-Box logging for the example application

The scope of this workshop is not to explain every aspect of running an application or job on Code Engine. It's just about containerized applications.

Prerequisites

Code Engine has a free tier per month, and we expect, if you haven't used that free tier in current month, you can execute the workshop without creating any additional costs. For the monitoring and logging we will use free lite plans for the service instances IBM Cloud Monitoring and IBM Cloud Log Analysis.

  • You should have a basic understanding of containerized applications

Estimated time and level

Time Level
1 h beginners

Architecture

This workshop is related to the Cloud Native Starter project. In the workshop we use a costomized version of the security application example.

The example application simply shows articles protected with an Identity and Access Manegement. In the following picture you see the frontend with the articles and the valid user alice is logged on.

The following diagram shows the architecture of the example application. There is a web-app frontend application that serves the Javascript/Vue.js code to the browser. The web-app code running in the browser invokes a REST API of the web-api microservice. The web-api microservice in turn invokes a REST API of the articles microservice. Keycloak is used for the Identity and Access Manegement of that microservices based application. To see the results in the web application, users need to be authenticated and they need to have the role user.

The image below shows the dependencies of the example:

  • External and internal routing

In our context it's useful to have a basic understanding of the routing for example application. Based on the functionality of the application, we need three external routes for the example application.

Each external route communication will be automaticly secured with a TLS Encryption created by Code Engine using Let's encrypt. The three applications are the web-app which will be loaded into the browser, the Keycloak that must be available for the authentication/authorization to our application and for potential configruation the Identity and Access Manegement and finally the web-api microservice which provides the articles data and will be invoked be the web-app.

The articles microservice doesn't need to be invoked from external, so it's configured to provide only an internal route, which is used by the web-api microservice to get the articles from.

  • Basics about the deployment

For an easy deployment prebuild containers were created and pushed to a Quay container registry. In the following table you see the application/container, the exposed routes, uses of TLS Encryption, the scale to zero configuration, the container registry where the prebuild container comes from, the configuration for vCPU and Memory in GB and the min/max Instances for the applications.

Application Route TLS Encryption Scale to zero Container Registry vCPU Memory min Instances max Instances
web-app external yes yes Quey 0.5 1 GB 0 1
keycloak external yes no Docker 0.5 1 GB 1 1
web-api external yes yes Quey 0.5 1 GB 0 1
articles internal no (mTLS comming sone) yes Quey 0.25 0.5G GB 0 1

The Keycloak application for the Identity and Access Manegement isn't configured to scale to zero, because the application is stateful and contains the realm configuration, which will be delete, if you would restart the application.

Note: The project also contains the source code, that you can use to customize to your an own version of the microservices based example application.

About this workshop

Agenda

These are the sections of this workshop, go through all of them in sequence, start with Lab 1. Setup the example application :

  1. Setup the example application
  2. Inspect the Code Engine project
  3. Monitoring of the applications
  4. Logging of the applications
  5. Cleanup the example application

Optional Labs:

  1. Run the example application locally
  2. Push the example containers to a container registry

Compatibility

The workshop uses following IBM Cloud Services:

IBM Cloud Code Engine is build on Open Source technologies:

Technology Used

The example mircorservices application example is build with following technologies/tools/frameworks.

Credits

Additional resources