Overview
Tencent Container Registry (TCR) supports the hosting and distribution of container images and provides the image building feature to enable image building, push, and hosting to be automatically triggered by code changes. If customers need to quickly iterate their applications, they can adopt an automated pipeline to generate images. Large number of image tags will be generated continuously, and the old image tags will no longer be used. If a single image repository contains too many image tags, the burden of tag management is huge, and the quota of image tags in the repository will be used up. Therefore, TCR provides the image tag retention feature to allow users to create custom rules for tag retention. Such rules can be triggered periodically to automatically delete the image tags that fall outside the retention scope.
Tag retention rules support two types of retention policies: retaining the latest # tags pushed and retaining the tags pushed within # days, and simulated execution is supported.
Must-Knows
1. The version retention feature can be used to delete image versions not covered by the retention rules.
2. The version retention feature deletes only the image version information and retains the underlying image data. To completely clean up image data, use Cloud Object Storage (COS) cleanup. Directions
Creating tag retention rules
Note:
An image repository may contain multiple versions of an image that are exactly the same. For example, an image has different tags, but a new image layer is not generated. The image with different tags has the same and unique identifier Digest. Therefore, the image with different tags but the same Digest physically points to the same image content. When a tag is deleted, the image will be deleted, and the related tags and Digest will also be cleaned up.
The impact on Tencent Container Registry (TCR) version retention rules is as follows: If a repository contains images with different tags but the same Digest, and the two latest images are required to be retained, deleting one tag will cause all images in the repository to be deleted. Therefore, if your image repository contains images with the same Digest but different tags, use the version retention rules with caution or temporarily disable the existing rules.
1. Log in to the TCR console and select Tag Retention in the left sidebar. 2. On the Tag Retention page, view the tag retention rule list of the current instance. To switch to another instance, select the target instance from the Instance Name drop-down list at the top of the page.
3. Click Create Rule, and in the Create Tag Retention Rules window, configure the rules by seeing the prompts as shown below. There are two optional configuration modes:
Associated Instance: currently selected instance.
Namespace: The namespace where the version retention rule takes effect. Currently, only one rule can be created in a namespace.
Configuration mode: Basic configuration.
Retained tags: No tags are filtered out, that is, all repositories and tags in a namespace are retained by default.
Retention rule: Two modes are supported: Retain the most recently pushed # tags, or Retain tags pushed within the last # days. The number of tags or days needs to be specified.
Execution cycle: Execution cycle of the version retention rules. The tag retention rules can be manually executed or automatically executed on a daily, weekly, or monthly basis. The specific execution time is as follows: 00:00 on each day, 00:00 on each Monday, or 00:00 on the first day of each month.
Enabling rules: The rules are enabled by default.
Associated Instance: currently selected instance.
Namespace: The namespace where the version retention rule takes effect. Currently, only one rule can be created in a namespace.
Configuration mode: advanced configuration.
Retention rules: Multiple retention rules can be configured, and their union set is applied, that is, an image version meeting any of the retention rules will be retained.
Repository filtering: Certain repositories are matched or excluded. Regular expressions are used for filtering repository names. An asterisk (*) and double asterisks (**) can match any long string, while an asterisk (*) cannot match a multi-level repository name. A question mark (?) can match any single character other than the slash (/).
Version filtering: Certain versions in a repository are matched or excluded. Regular expressions are used for filtering version names. The filtering rules are the same as those for repository filtering.
Retention rule: Two modes are supported: Retain the most recently pushed # tags, or Retain tags pushed within the last # days. The number of tags or days needs to be specified.
Execution period: Execution cycle of the tag retention rules. The tag retention rules can be manually executed or automatically executed on a daily, weekly, or monthly basis.
Enabling rules: The rules are enabled by default.
4. Click Confirm to create a tag retention rule.
Managing tag retention rules
After successfully creating tag retention rules, you can view the created tag retention rules on the Tag Retention page. You can also perform the following operations to manage the rules. See the figure below: View the rule execution logs: You can click the name of a rule to view its triggering logs. For more information, see Viewing execution logs. Configure: You can reconfigure a tag retention rule but cannot modify the namespace for which it takes effect.
Delete: You can delete a tag retention rule.
Viewing execution logs
1. Click the name of the target tag retention rule to view the triggering logs of the rule, as shown in the figure below: Task ID: ID of a tag retention task, unique within the instance.
Creation Time: Time when a tag retention task was created.
Time Spent: Time consumed to complete all the tag retention tasks.
Execution Method: Manual or automatic. You can click Execute Now or Simulate Execution for manual execution. Automatic execution is based on the cycle specified in the tag retention rule.
Execution Type: Real execution or simulate execution. Simulate execution can be used to confirm whether the rule is effective, but it does not actually clear image tags.
Execution Status: Status of task completion.
2. You can click a task ID to view the task details and click a specific repository to view its execution log.
References
You can also use the CreateTagRetentionRule API to create tag retention rules. For more information, see CreateTagRetentionRule.