Difficulty: beginner
Estimated Time: 15 minutes

The goal of this interactive scenario is to deploy two Java microservices to Kubernetes and change their configuration using MicroProfile Config, Kubernetes ConfigMaps and Secrets.

The online terminal is a pre-configured Linux environment that can be used as a regular console (you can type commands). Clicking on the blocks of code followed by the ENTER key will execute that command in the terminal.

Great Work! You're done!

You have used MicroProfile Config to externalize the configuration of two microservices, and then you configured them by creating a ConfigMap and Secret in your Kubernetes cluster.

If you would like to look at the code for these microservices follow the link to the github repository. For more information about the MicroProfile specification used in this tutorial, visit the MicroProfile website with the link below.

Github repository MicroProfile.io

Configuring a Kubernetes Microservice

Step 1 of 7

Build and Deploy the Java microservices

To begin, make sure your Kubernetes environment is set up. Once the terminal has finished outputting messages and is ready for input it should be setup. To confirm it is ready please run the following command:

kubectl version

You should now see the versions of your kubectl client and server. If so, your environment is all set up. If you do not see the version of your Kubernetes server wait a few moments and repeat the previous command until it is shown.

Now you need to navigate into the project directory that has been provided for you. This contains the implementation of the MicroProfile microservices, configuration for the MicroProfile runtime, and Kubernetes configuration.

cd guide-kubernetes-microprofile-config/start/

You will notice their is a 'finish' directory. This contains the finished code for this tutorial for reference.

The two microservices you will deploy are called 'system' and 'inventory'. The system microservice returns JVM properties information about the container it is running in. The inventory microservice adds the properties from the system microservice into the inventory. This demonstrates how communication can be achieved between two microservices in separate pod's inside a Kubernetes cluster. To build the applications with Maven, run the following commands one after the other:

mvn package -pl system

mvn package -pl inventory

Once the services have been built, you need to deploy them to Kubernetes. To do this use the following command:

kubectl apply -f kubernetes.yaml