Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCP: How to prune/maintain Artifact Registry storage?

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.

like image 664
Peter V. Mørch Avatar asked Jan 28 '26 07:01

Peter V. Mørch


2 Answers

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.

like image 72
sethvargo Avatar answered Feb 01 '26 05:02

sethvargo


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
    }
  }
]
like image 42
Jack Clark Avatar answered Feb 01 '26 07:02

Jack Clark