12

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.

Jen Person
  • 7,356
  • 22
  • 30
Peter V. Mørch
  • 13,830
  • 8
  • 69
  • 103
  • 1
    Log into the Google Cloud Console. Search (at the top) or select "Container Registry". You can see each of your images, revisions, size, etc. You can delete unneeded images. Note: you can delete images that are in use by another service such as Cloud Run ... I am not aware of an automatic tool to purge as there is no linkage between Container Register and other services that might use an image. Container Registry is like a storage bucket, it is up to you to manage what is kept there. – John Hanley Oct 27 '20 at 18:24
  • Please see the link [1](https://cloud.google.com/artifact-registry/docs/how-to)- How-to guides on Artifact Registry, there you can find Creating and managing repositories (add, delete,label and list). – Sohail Alvi Oct 28 '20 at 01:03
  • 1
    @JohnHanley: This is "Artifact Registry", not "Container Registry". Artifact Registry is the evolution of Container Registry. [docs](https://cloud.google.com/artifact-registry/docs/transition/transition-from-gcr) say: "As a fully-managed service with support for both container images and non-container artifacts, Artifact Registry will eventually replace Container Registry." I don't know about Container Registry, but Artifact Registry doesn't show size in the console. – Peter V. Mørch Oct 28 '20 at 10:47
  • @SohailAlvi: Yes, I've tried using gcloud following the HowTo docs. `gcloud beta artifacts packages list` shows the list of different image names, and `gcloud beta artifacts docker images list` shows me a list of every sha256 sum of every image name. Neither of these outputs contain any information about size. – Peter V. Mørch Oct 28 '20 at 10:55

4 Answers4

11

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.

sethvargo
  • 26,739
  • 10
  • 86
  • 156
  • 2
    Cool! Fantastic! Thanks a bunch! Didn't think this 1-upvote question would generate attention from both the author of gcp-cleanup and a member of Google Cloud Platform Support Team but... Fantastic! I'll give it a go tomorrow or one of the the next days, as its 1am here now. Thanks! – Peter V. Mørch Oct 30 '20 at 00:05
  • 1
    As I understand, Google announced that effective from May 2022, Artifacts Registry will replace Container Registry. But before that, Google Firebase Support told me that images in Artifact Container is **SAFE to be deleted** because they're just backup for rollback purposes. So I just want to know, after the replacement, are images in Artifacts Container still safe to be deleted, even all of them? Many thanks! – Antonio Ooi Aug 03 '22 at 08:30
1

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.

Peter V. Mørch
  • 13,830
  • 8
  • 69
  • 103
  • 2
    Thank you for your feedback , the GCR -Cleaner/ Pruning feature currently not available with Artifact Registry , I'll raise this with the product team". You can Also follow this [FR](https://issuetracker.google.com/113559510) for the updates. – Sohail Alvi Oct 29 '20 at 19:47
1

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.

Daniel Compton
  • 13,878
  • 4
  • 40
  • 60
Leo Y
  • 659
  • 7
  • 22
0

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
    }
  }
]