When building a cloud native application based on the Spring Boot framework and deploying this in Oracle Kubernetes Engine (OKE) on Oracle Cloud Infrastructure (OCI), you might want to use the Spring Boot native admin server functionality. Using Spring Boot native components on OCI provides you a direct benefit of the combination of proven enterprise grade components running on an enterprise grade cloud.
Spring Boot Admin and Actuator
Spring Boot Admin is a web application, used for managing and monitoring Spring Boot applications. Each application is considered as a client and registers to the admin server. Behind the scenes, the magic is given by the Spring Boot Actuator endpoints.
The Actuator endpoints automatically added when you include Spring Boot Actuator to your application. Spring Boot includes numerous features to help you monitor and manage your application when you push it to production. You can choose to manage and monitor your application by using HTTP endpoints or with JMX. Auditing, health, and metrics gathering can also be automatically applied to your application.
When building your service to communicate with the Spring Boot admin server, the service instance registers itself when started and provide the Spring Boot admin server the Actuator endpoints. From that moment onwards, the Spring Boot admin server consumes all details form the Actuator endpoints and appears in the UI.
Actuator endpoints
Actuator provides the following endpoints:
-
Auditevents: Exposes audit events information for the current application. Requires an AuditEventRepository bean.
-
Beans: Displays a complete list of all the Spring beans in your application.
-
Caches: Exposes available caches.
-
Conditions: Shows the conditions that were evaluated on configuration and auto-configuration classes and the reasons why they did or did not match.
-
Configprops: Displays a collated list of all @ConfigurationProperties.
-
Env: Exposes properties from Spring’s ConfigurableEnvironment.
-
Flyway: Shows any Flyway database migrations that have been applied. Requires one or more Flyway beans.
-
Health: Shows application health information.
-
Httptrace: Displays HTTP trace information (by default, the last 100 HTTP request-response exchanges). Requires an HttpTraceRepository bean.
-
Info: Displays arbitrary application info.
-
Integrationgraph: Shows the Spring integration graph. Requires a dependency on spring-integration-core.
-
Loggers: Shows and modifies the configuration of loggers in the application.
-
Liquibase: Shows any Liquibase database migrations that have been applied. Requires one or more Liquibase beans.
-
Metrics: Shows metrics information for the current application.
-
Mappings: Displays a collated list of all @RequestMapping paths.
-
Quartz: Shows information about Quartz Scheduler jobs.
-
Scheduledtasks: Displays the scheduled tasks in your application.
-
Sessions: Allows retrieval and deletion of user sessions from a Spring Session-backed session store. Requires a Servlet-based web application using Spring Session.
-
Shutdown: Lets the application be gracefully shutdown. Disabled by default.
-
Startup: Shows the startup steps data collected by the ApplicationStartup. Requires the SpringApplication to be configured with a BufferingApplicationStartup.
-
Threaddump: Performs a thread dump.
Building a Spring Boot Admin server
The Spring Boot admin server is a Spring Boot application, and to run it, you need to build it as you would build any other service. You can use the resulting .jar file from the build process in a container to run the actual Spring Boot Admin server itself. As for the build, when using Maven, you need a pom.xml file. The following code shows an example pom.xml to be placed in the root of your source tree:
In addition to the pom.xml file, you need the following files:
-
An AdminServerApplication.java file in src/main/java/com/cegCloudNative/
-
Under src/main/resources/, find a file named application.properties. In our example, this file only contains a single line of code to configure the port: server.port=8888.
-
Under src/test/java/com/cegCloudNative/AdminServer/, find the file named AdminServerApplicationTests.java.
Ensuring that the mentioned files are present, you can initiate a Maven build. After successfully building the code, you can start the resulting .jar file and have a running Spring Boot admin server. When deploying on Kubernetes in Oracle OKE, ensure that your continuous integration and deployment (CI/CD) build pipeline creates a container that includes this .jar file and start it. This configuration provides a simple way of including the Spring Boot admin server in your Spring Boot project when running your cloud native project in OCI.
Conclusion
For more information on the concepts in this blog post, see the following resources:
