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 sign 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 by running the following command:

kubectl version

You should now see the versions of your kubectl client and cluster. 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 projects directory that has been provided for you. You may notice their is a finish directory. This contains the finished code that you will not require for this tutorial.

cd guide-kubernetes-microprofile-config/start/

The two microservices you will deploy are called name and ping. The name microservice displays a brief greeting with the name of the container that contains the application. The ping microservice pings the Kubernetes Service that encapsulates the pod running the name microservice. The ping microservice demonstrates how communication can be established between pods inside a cluster. To build the applications with Maven, run the following commands;

mvn package -pl name

mvn package -pl ping

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