Nicolò Gasparini
Nicolò Gasparini

Reputation: 2396

Google Container Registry images lifecycle

I would like to know if there is a way to setup an objects lifecycle in GCP Container Registry?

I would like to keep the last n versions of an image, automatically deleting the older ones as new ones are pushed online.

I can't work directly on the Cloud Storage bucket because, having multiple images saved, the storage objects are not recognizable.

Upvotes: 3

Views: 2317

Answers (3)

guillaume blaquiere
guillaume blaquiere

Reputation: 75775

Seth Vargo, a Google Cloud developer advocate has release GCRCleaner.

Follow the instruction for setting up a scheduler and a Cloud Run for cleaning the GCR.

Edited - (2024-08-12):

The GCRCleaner functionality is now baked in to the GCR Registry itself. It's disclamed in the GCRCleaner homepage, and refers here:

Upvotes: 5

Jaroslav
Jaroslav

Reputation: 742

Unfortunately, at this time there’s no feature able to do such in GCR, however there’s already a feature request created. You can follow on it and write comments.

Also check this example, where image deletion was implemented in specific time.

Upvotes: 2

Raunak Jhawar
Raunak Jhawar

Reputation: 1651

Unfortunaltely, there is no concept pf managed lifecycle management of images managed in GCR just like there is in AWS which allows creating policies to manage images in the registry.

You have to plan this yourself i.e. a script which emulates the following behavior and runs periodically.

gcloud container images delete -q --force-delete-tags "${IMAGE}@${digest}"

Upvotes: 2

Related Questions