在我们的ECR中,每天都会推送很多带有标签16_XXXX的图片。有些推送的图片并不是应用的稳定版本。当有稳定版本的时候,我们就用标签16.XXXX重新标记图片。
我们设置了一个生命周期策略,在imageCountMoreThan (500)时清理带有16_XXXX标签的图片,由于有一些图片带有两个标签(即稳定版)(如16_0715和16.0715),它们是否也会被清理?
我们不想删除所有稳定版的图片。是否有办法重新标记图像并删除旧的标签以将其排除在ECR生命周期策略中?
谢谢!在我们的ECR中,我们推送的是图片的稳定版本。
如果你只有一条规则,确实会删除你的稳定版图片。
然而,你可以在一个策略中使用2条规则来实现这一点。优先级为10的规则将保证你的稳定版图像(16.XXXX)的安全,而优先级为20的规则将 "看到 "你的不稳定版(16_XXXX)的标签数量,但将永远无法删除稳定版图像,因为它的优先级更高。下面是一个例子。
{
"rules": [
{
"rulePriority": 10,
"description": "Keep Stable Images",
"selection": {
"tagStatus": "tagged",
"tagPrefixList": ["16."],
"countType": "imageCountMoreThan",
"countNumber": 9999
},
"action": {
"type": "expire"
}
},
{
"rulePriority": 20,
"description": "Delete Old Unstable Images",
"selection": {
"tagStatus": "tagged",
"tagPrefixList": ["16_"],
"countType": "imageCountMoreThan",
"countNumber": 500
},
"action": {
"type": "expire"
}
}
]
}
来源: 我写了生命周期策略的规则评估逻辑 :) 你也可以查看文档,在这个页面的底部描述了一些关于系统的事实,用户可以利用。https:/docs.aws.amazon.comAmazonECRlatestuserguideLifecyclePolicies.html。
An image that matches the tagging requirements of a rule cannot be expired by a rule with a lower priority.