Reputation: 15967
We've started to use Google Cloud Platform's Artifact Registry where pricing is pr. GB pr. month.
But how can I see how much storage is being used and by what?
It also looks like all pushed images are saved forever by default. So for each build, the repository will only grow and grow? How do I (automatically?) delete old builds, keeping only the most recent one (or N, or tagged images) available?
It seems disingenuous to price us pr. GB, but not provide any means to investigate or prune how much storage is being used, so I'm hoping we've missed something.
Edited to add: We have CI/CD pipelines creating between 20-50 new images a day. Having to manually delete them is not maintainable in the long run.
Edited to add: Essentially I'm looking for sethvargo/gcr-cleaner: Delete untagged image refs in Google Container Registry, as a service but for Artifact Registry instead of the Container Registry, which it will replace. Or the shell-script gist (also GCR-only) that inspired gcr-cleaner.
Upvotes: 15
Views: 7631
Reputation: 31
This could be a good and new option for your problem. I don't believe this was available when you were looking, I hope it's not too late.
https://cloud.google.com/artifact-registry/docs/repositories/cleanup-policy
[
{
"name": "delete-prerelease",
"action": {"type": "Delete"},
"condition": {
"tagStatus": "tagged",
"tagPrefixes": ["alpha", "v0"],
"olderThan": "30d"
}
},
{
"name": "keep-tagged-release",
"action": {"type": "Keep"},
"condition": {
"tagStatus": "tagged",
"tagPrefixes": ["release"],
"packageNamePrefixes": ["webapp", "mobile"]
}
},
{
"name": "keep-minimum-versions",
"action": {"type": "Keep"},
"most_recent_versions": {
"packageNamePrefixes": ["webapp", "mobile", "sandbox"],
"keepCount": 5
}
}
]
Upvotes: 3
Reputation: 699
The Artifact Registry service should introduce a support for retention policies in Q4'22. Until then some GCP customers will be able to subscribe for this feature as early previewers. You can see more information at Configure cleanup policies for repositories
Other way around would be to use Cloud Scheduler or Cloud Run jobs to do the work.
Upvotes: 2
Reputation: 26997
GCR Cleaner does support purging from Artifact Registry. I verified this myself and updated the documentation to reflect so. I don't plan on changing the tool's name since it's pretty well-recognized, but it will work with GCR and AR.
Upvotes: 10
Reputation: 15967
I hope somebody can come with a better answer, but I came across [FR] Show Image size information in Artifact Registry GUI [156322291] in Google's Issue Tracker. So this is a known issue.
And gcr-cleaner has this issue: Support for Artifact Registry · Issue #9 · sethvargo/gcr-cleaner - that is closed because it went stale.
Its looking like Artifact Repository is not yet mature enough for prime-time, and that I'm better off using Container Registry for the time being. A shame though.
Upvotes: 1