Difficulty: beginner
Estimated Time: 15 minutes

In this scenario you will learn more about developing Spring Boot applications using the Red Hat Runtimes platform. You will learn about how OpenShift uses monitoring tools to keep your application running / notify you when something unrecoverable happens through the use of probes .

In this scenario you learned about Spring Boot and how to monitor Spring Boot applications using OpenShift. 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 started by deploying our basic Spring Boot application to OpenShift via jkube. Then we checked on our application by accessing it through the route, which allows for external connection through a hostname. After we knew the application was up and available for all, we decided to add a health check with Spring Actuator to provide OpenShift with more information about our container and allow them to handle the restarting of failed instances. We then took a deeper dive into Actuator and looked at some of the other endpoints it provides, which allowed us to get all types of additional information about our application.

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 can be found here:

  • Red Hat 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.

Monitoring Spring Applications

Step 1 of 3

Step 1

Import the code

Let's refresh the code we'll be using. Run the following command to clone the sample project:

cd /root/projects && rm -rf rhoar-getting-started && git clone https://github.com/openshift-katacoda/rhoar-getting-started && cd rhoar-getting-started/spring/spring-monitoring

Review the base structure of the application

For your convenience, this scenario has been created with a base project using the Java programming language and the Apache Maven build tool.

As you review the content, you will notice that there are a couple TODO comments. Do not remove them! These comments are used as markers for later exercises in this scenario. Open src/main/java/com/example/service/FruitController.java. This is our rest controller. We will be adding our logging commands here later in this module.

1. Test the application locally

As we develop the application we want to be able to test and verify our change at different stages. One way we can do that locally is by using the spring-boot maven plugin.

Run the application by executing the following command:

mvn spring-boot:run

Once that's completed, click on the Local Web Browser tab and navigate to the /fruits endpoint or use this link.

You should now see an HTML page with a Success welcome message that looks like this:


If you see this then you've successfully set up the application! If not check the logs in the terminal. Spring Boot adds a couple helper layers to catch common errors and print helpful messages to the console so check for those first.

2. Stop the application

Before moving on, click in the terminal window and then press CTRL+C to stop the running application!


You have now successfully executed the first step in this scenario. In the next step we will login to OpenShift and create a new project.