Adding a Trigger
Scenarios
SWR works with Cloud Container Engine (CCE) to enable automatic application updates. This can be achieved if a trigger is added for images.
Prerequisites
- You have permission to access CCE. For details, see Fine-grained CCE Authorization or Fine-grained CCI Authorization.
- A containerized application has been created in CCE by using an image from SWR.
If no applications are created, log in to the CCE console and create one. For details, see Creating a Deployment or Creating a StatefulSet. To create an application in CCI, see Creating a Deployment.
Procedure
- Log in to the SWR console.
- In the navigation pane, choose My Images. Then click the name of the target image.
- Click the Triggers tab, and then click Add Trigger. Configure parameters based on 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 a new image tag is generated.
- 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 any of the options.
Action
Currently, only the action "update" can be a trigger. You need to specify the application to be updated and containers of the application.
Status
Select Enable.
Type
Select CCE.
Target
Select the containers whose image you want to update.
Example 1: Trigger Condition Is All
A Deployment named nginx is created using the Nginx image v1. The Deployment provides services to external systems with a welcome page displaying Hello, SWR!
- Add a trigger to the Nginx image.
Set Name to All_tags and Condition to All. Select the application and all its containers that use the Nginx image.
- Push the Nginx image v2 to SWR. The welcome page of the Deployment created using this new image should display Hello, SoftWare Repository for Container!
Figure 2 Image 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 ResultThe welcome page of the Deployment displays Hello, SoftWare Repository for Container!
Example 2: Trigger Condition Is RegEx
A Deployment named nginx is created using the Nginx image v0. The Deployment provides services 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, and regular expression to ^v2.*. Select the application and all its containers that use the Nginx image.
- Push the Nginx image v1 to SWR. The welcome page of the Deployment created using this new image should display Hello, SWR! (v1).
- Push the Nginx image v2 to SWR. The welcome page of the Deployment created using this new image should display Hello, SWR! (v2).
- Check whether the deployment is triggered successfully.
On the Triggers tab, click
to check the result. Only the deployment of the nginx image tagged with v2 is triggered, because the image name matches the regular expression ^v2.*.
Figure 4 ResultThe 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