Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I delete container images from Google Cloud Storage artifacts bucket?

I have a Google App Engine app, which connects to Google Cloud Storage.

I noticed that the amount of data stored was unreasonably high (4.01 GB, when it should be 100MB or so).

So, I looked at how much each bucket was storing, and I found that there was an automatically created bucket called us.artificats. that was taking up most of the space.

I looked inside, and all it has is one folder: containers/images/.

From what I've Googled, it seems like these images come from Google Cloud Build.

My question is, can I delete them without compromising my entire application?

like image 793
Caleb H. Avatar asked Jan 27 '20 19:01

Caleb H.


People also ask

How do I clear my cloud storage bucket?

In the Google Cloud console, go to the Cloud Storage Buckets page. Select the checkbox of the bucket you want to delete. Click Delete.

Where do you store container images in Google Cloud?

[HOSTNAME] is the location where the image is hosted, and is one of four options: gcr.io , us.gcr.io , eu.gcr.io , or asia.gcr.io . [PROJECT-ID] is the Google Cloud console project ID. If your project ID has a colon in it ( : ) see Domain-scoped projects. [IMAGE] is the image's name in Container Registry.

How do I clean out my Google Cloud?

In the Google Cloud console, go to the Manage resources page. In the project list, select the project that you want to delete, and then click Delete. In the dialog, type the project ID, and then click Shut down to delete the project.


2 Answers

For those of you seeing this later on, I ended up deleting the folder, and everything was fine.

When I ran Google Cloud Build again, it added items back into the bucket, which I had to delete later on.

As @HarshitG mentioned, this can be set up to happen automatically via deletion rules in cloud storage. As for myself, I added a deletion step to my deployment GitHub action.

like image 23
Caleb H. Avatar answered Sep 23 '22 05:09

Caleb H.


I have solved this problem by applying a deletion rule. Here's how to do it:

  1. Open the project in Google Cloud console
  2. Open the storage management (search for "Storage" for example).
  3. In the Browser tab, select the container us.artifacts....
  4. Now, open the Lifecycle section. You should see something like:

enter image description here

  1. Click on Add a rule and provide the following conditions:
    1. In the action, select Delete object
    2. In the conditions, select Age and enter for example 3 days
  2. Click on create to confirm the creation

Now all objects older than 3 days will be automatically deleted. It might take a few minutes for this new rule to be applied by Google Cloud.

like image 130
HarshitG Avatar answered Sep 22 '22 05:09

HarshitG