Difficulty: beginner
Estimated Time: 15 minutes

In this scenario you will learn more about developing Spring Boot Microservices using the Red Hat OpenShift Application Runtimes platform. You will learn about Externalized Configurations and how we can use Externalized Configurations to change specific values/variables without having to take down the entire application.

In this scenario you learned about Spring Boot and how it can be used to create Microservices and modify them with Externalized Configuration. We will add additional scenarios that explain more how to build Spring Boot applications on OpenShift shortly, so check back to learn.openshift.com

To summarize: We first deployed our application with the default values. Then we were able to modify the values by editing our application.properties file and rolling out a new version of our application. Our changes were reflected in the live application but didn't require us to have any downtime.

Spring Boot is a powerful and easy to use framework for developing everything from monolithic applications to microservices, but Spring Boot becomes every better when we package it in a container and use an orchestrated platform like OpenShift. When using OpenShift we can, in a very consistent and fast way, deploy our Spring application to multiple environments without worry of environment differences. OpenShift also enables things like Deployment Pipelines and Blue/Green deployments but that was not covered in this scenario.

Additional Resources

More background and related information on Red Hat OpenShift Application Runtimes and Eclipse Vert.x can be found here:

  • Red Hat OpenShift Application Runtimes for Developers - Here you can get started with a project using different boosters and clone that project to your local computer. This also enables you to deploy your application on your own private OpenShift Container Platform or use OpenShift Online that is provided for free from Red Hat.
  • Project Snowdrop homepage - This site has a lot of details of the work that Red Hat is doing to make Spring work great on Kubernetes and OpenShift.

Externalized Configuration and Health Checks

Step 1 of 3

Step 1

Review the base structure of the application

For your convenience, this scenario has been created using the OpenShift Launcher found here. This launcher will automatically generate a zip file of a project that's in a ready-to-deploy state. We've selected the Externalized Configuration project and will be using the Spring Boot runtime option.

1. Understanding the Application

The project is a simple Greeting application, where a user inputs a fruit and is greeted by our service. Opening up our greeting-service/src/main/java/io/openshift/booster/service/FruitController.java file we can see the logic used to respond to our user. The interesting part of this logic is right here, where we retrieve the message:

String message = String.format(properties.getMessage(), name);

If we take a closer look at this properties object, we see that it's of type MessageProperties. When we look at that file greeting-service/src/main/java/io/openshift/booster/service/MessageProperties.java we see an annotation linking to a configuration file, @ConfigurationProperties("greeting"), which is pointing to our greeting-service/src/main/resources/application-local.properties file.

Our application-local.properties file contains only one property, greeting.message. This is the message that we return and display to the user. In order to get an understanding of the flow, let's run the application locally. First cd into the project directory and build the project:
mvn -f greeting-service spring-boot:run

mvn spring-boot:run

When the application finishes building click the local web browser or click here. You should see the same message that is in the application-local.properties file.

Be sure to stop the application with ctrl-c.


You have now successfully executed the first step in this scenario. in the next step we're going to be deploying the project and testing it our for ourselves, as well as modifying this greeting through External Configuration.

Local Web Browser
OpenShift Console
This tab will not be visible to users and provides only information to help authors when creating content.

Creating Katacoda Scenarios

Thanks for creating Katacoda scenarios. This tab is designed to help you as an author have quick access the information you need when creating scenarios.

Here are some useful links to get you started.

Running Katacoda Workshops

If you are planning to use Katacoda for workshops, please contact [email protected] to arrange capacity.

Debugging Scenarios

Below is the response from any background scripts run or files uploaded. This stream can aid debugging scenarios.

If you still need assistance, please contact [email protected]