Graceful Startup of a Spring Cloud Application
Overview
This section describes how to configure graceful startup for Spring Cloud application to perform operations such as upgrade, restart, and scale-out during component O&M.
Prerequisites
- You have created an environment.
- You have created an application.
- You have created and deployed a Spring Cloud component.
Procedure
- Enable spring-boot-starter-actuator for Spring Cloud.
- Add the spring-boot-starter-actuator dependency to the pom.xml file of the source code corresponding to the component. (Version 2.3.0 or later is recommended.)
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> <version>{Your Spring boot version}</version> </dependency>
- Add the following configurations to the application.properties file:
Table 1 application.properties Spring Boot Version
Configuration
2.3.0/2.3.1
management.health.probes.enabled=true
>= 2.3.2
management.endpoint.health.probes.enabled=true
management.health.livenessState.enabled=true
management.health.readinessState.enabled=true
- Update code.
- If your component is deployed using source code, update the modified source code to the source code repository.
- If your component is deployed using a software package, pack the new code into a software package and upload the new package to the software package repository.
- Use the new source code or software package to upgrade the component.
- Add the spring-boot-starter-actuator dependency to the pom.xml file of the source code corresponding to the component. (Version 2.3.0 or later is recommended.)
- Configure component health check.
- Log in to CAE. Choose Component Configurations.
- Select the target component from the drop-down list in the upper part of the page.
- Configure readiness probe by referring to Configuring Health Check. The parameters are as follows:
Table 2 Readiness probe parameters Parameter
Description
Check Method
Select HTTP.
Port
Enter the listening port of your component.
Path
- For Spring Boot 2.3 and later, enter /actuator/health/readiness.
- For Spring Boot versions earlier than 2.3, enter /actuator/health.
Protocol
Select the protocol of your component.
Check Interval
Enter 10.
Latency
Enter 0.
Timeout Interval
Enter 1.
Success Threshold
Enter 1.
Failure Threshold
Enter 3.
- Upgrade the component. For details, see Upgrading a Component.
- Verify the configuration.
- Choose Components. If the status of the target component is Running, go to the next step. Otherwise, the configuration fails.
- Choose Component Events and select the target component from the drop-down list in the upper part of the page. If the Component instance healthy event exists, the configuration is successful. Otherwise, the configuration fails.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot