In this workshop, learn how to build a microservice with Java and deploy it to Kubernetes on IBM Cloud. The microservice in this workshop is kept as simple as possible so that it can be used as a starting point for other microservices.
After you complete this workshop, you will:
- Understand the Java implementation of a cloud-native RESTful Java microservice built on the open technologies Eclipse MicroProfile and Open Liberty
- Be able to describe how to effectively build and run a microservice on a local machine in a container
- Understands the steps needed to deploy a single microservice to Kubernetes and on the IBM Cloud Kubernetes service
Once you complete the workshop, you can earn the Cloud Native Starter Level 1 Badge by passing the quiz with a score of at least 80%.
In order to run this workshop, you will need to:
- Create an IBM Cloud account (or log in to your existing account)
- Create an IBM Cloud Kubernetes Cluster
- Install Docker Desktop on your local machine to access the Docker image that contains all the needed CLIs
It should take about 1 hour to complete this workshop.
Set up local and IBM Cloud environments
Follow the steps in the “Overview” section of this workshop to:
- Register for IBM Cloud
- Create a Kubernetes Cluster
- Configure the container registry
- Set up for local development and cloud deployment
- Access the Kubernetes cluster
Locally run the Java microservice
Once you are set up, you will define in Dockerfile how to build the container image. Using a multi-stage build, you will create one container responsible to build the microservice (the build environment container) and another container that will contain the microservice itself (the production container). Using the production container, you will then locally run the microservice.
Complete the steps in the “Locally run the Java microservice” section of the workshop.
Understand how to use Maven for this project, how to configure the Open Liberty server, and how to implementat the REST GET endpoint with MicroProfile. Then get hands-on by changing the code of the authors microservice and locally running the service in a container.
Complete the steps in the “Java implementation” section of the workshop.
Deploy to Kubernetes
In this section, you will work in the Kubernetes web console and with the Kubernetes CLI.
This section has two parts:
- Start build and save the container image
Deploy the application and expose the service, in which you will:
- Define and apply a deployment configuration (yaml) to create a Pod with our microservice
- Define a service that routes requests to the Pod with our microservice
You now know how to build a microservice with Java and how to deploy it to Kubernetes on IBM Cloud. Use the microservice in this workshop a starting point for other microservices.
You can also verify your learning and earn the Cloud Native Starter Level 1 Badge.