Configuring Lifecycle
CAE provides callback functions for the lifecycle management of containerized applications. For example, if you want a container to perform a certain operation before stopping, you can register a hook function.
Procedure
- Log in to CAE.
- Choose Component Configurations.
- Select the target component from the drop-down list in the upper part of the page.
Figure 1 Selecting a component
- Click Edit in the Lifecycle Management module.
- Configure PostStart or PreStop. They can be enabled at the same time.
- PostStart: triggered after a container is started. For details, see Table 1.
- PreStop: triggered before a container is stopped. This ensures that necessary tasks can be executed in advance of upgrades or instance deletions. For details, see Table 2.
If a while infinite loop is configured for PostStart and health check is also configured, the container health check may fail. As a result, component deployment or upgrade fails.
Table 1 PostStart parameters Parameter
Description
Command
Command to be executed in the container. The command format is Command Args[1] Args[2].... Command is a system command or a user-defined executable program. If no path is specified, an executable program in the default path will be selected. If multiple commands need to be executed, write the commands into a script for execution. Commands that are executed in the background or asynchronously are not supported.
For example, to write files using post-start processing, run the following commands:/bin/bash -c echo 'Hello, postStart' > /lifecycle.txt
Figure 2 Configuring PostStart commands
Table 2 PreStop parameters Parameter
Description
Command
Command to be executed in the container. The command format is Command Args[1] Args[2].... Command is a system command or a user-defined executable program. If no path is specified, an executable program in the default path will be selected. If multiple commands need to be executed, write the commands into a script for execution.
For example, to gracefully stop Nginx using pre-stop processing, run the following commands:
/bin/bash -c nginx -s quit;while killall -0 nginx;do sleep 1;done
Figure 3 Configuring PreStop commands
- Click OK.
- Make the configurations take effect.
- If the component has been deployed, click Activate Settings in the upper part of the page. In the dialog box displayed on the right, confirm the configurations and click OK for the configurations to take effect.
- If the component has not been deployed, click Set and Deploy Component in the upper part of the page. In the dialog box displayed on the right, click OK. After the deployment is complete, the configurations take effect.
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