Automatically Updating a Workload Version Using SWR Triggers
Application Scenarios
CCE and SWR work together to enable automatic application updates. Whenever images are updated, the applications that are built from them can be automatically updated. This could be realized by adding a trigger to the desired images.
Prerequisites
A containerized application has been created on CCE and a container image has been deployed in the application.
If no workload is created, log in to the CCE console and create one. For details, see Creating a Deployment or Creating a StatefulSet.
Procedure
- Log in to the SWR console.
- In the navigation pane, choose My Images and click the name of the target image.
- Click the Triggers tab and click Add Trigger. On the page displayed, configure the parameters by referring to Table 1 and click OK.
Figure 1 Adding a trigger
Table 1 Trigger Parameter
Description
Name
The name of a trigger.
The name can contain 1 to 64 characters, and must start with a letter. Only letters, digits, underscores (_), and hyphens (-) are allowed. The name cannot end with an underscore or hyphen. Consecutive underscores or hyphens are not allowed and an underscore cannot be placed next to a hyphen.
Condition
The following trigger conditions are supported:
- All: Deployment is triggered when any image tags are generated or updated.
- Specified: Deployment is triggered when a specific image tag is generated or updated.
- RegEx: Deployment is triggered when an image tag that matches the regular expression is generated or updated. The regular expression rules are as follows:
- *: matches any field that does not contain the path separator /.
- **: matches any field that contains the path separator /.
- ?: matches any single character except /.
- {option 1, option 2, ...}: matches multiple options.
Action
Currently, only operation of updating images will be triggered. You need to specify the application to be updated and the container of the application.
Status
Select Enable.
Type
Select CCE.
Target
Select the application whose image is to be updated and its container.
Example 1: The trigger condition is All.
A Deployment named Nginx is created using the Nginx v1 image. The Deployment provides service to external systems with a welcome page displaying Hello, SWR!
- Add a trigger to the Nginx image.
Set Name to All_tags, Condition to All, and select the application and all its containers that use the Nginx image.
- The Nginx v2 image is pushed to SWR. The welcome page of the Deployment created using this new image should display Hello, SoftWare Repository for Container!
Figure 2 Image tag v2
- Check whether the Deployment is triggered successfully.
On the Triggers tab, locate the trigger and click Records to check whether the trigger is successful.
Figure 3 Result
The welcome page of the Deployment displays Hello, SoftWare Repository for Container!
Example 2: The trigger condition is RegEx.
A Deployment named nginx is created using the Nginx image v0. The Deployment provides service to external systems with a welcome page displaying Hello, SWR!
- Add a trigger to the Nginx image.
Set Name to Tags_regular_expression, Condition to RegEx, enter the ^v2.* regular expression, and select the application and all its containers that use the Nginx image.
Figure 4 Selecting RegEx
- Push the Nginx image v1 to SWR. The welcome page of the Deployment created using this new image should display Hello, SWR! (v1).
Figure 5 Image tag v1
On the Triggers tab, click to check the result. The workload redeployment of the Nginx image v1 is not triggered.
The workload access page still displayed Hello, SWR!.
- Push the Nginx image v2 to SWR. The welcome page of the Deployment created using this new image should display Hello, SWR! (v2).
Figure 6 Image tag v2
- Check whether the Deployment is triggered successfully.
On the Triggers tab, click to check the result. As shown in Figure 7, only the deployment of the Nginx image v2 is triggered.
The welcome page of the Deployment displays Hello, SWR! (v2).
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