I made a cleaning tool for Google Container Registry

Introduction

In Google Container Registry, I made a tool to delete images by parallelizing them appropriately.

https://github.com/h-r-k-matsumoto/gcr-garbage-collect

Background

When I want to erase unnecessary images without tags in Google Container Registry for mental health, I do it from the console screen.

If you do 10 or more at once, it will almost certainly be as follows ** Could not delete one or more selected images. ** ** Is displayed and some deletions fail. image.png

Then, if you execute the following from the shell, you can delete it stably, but it takes about 5 seconds to delete one image, ** It is extremely slow. ** **

# get image list 
gcloud container images list-tags asia.gcr.io/{project-id}/${image-name}  --filter="NOT tags:* AND timestamp.datetime < '2018-06-01'"

# delete image
gcloud container images delete asia.gcr.io/{project-id}/${image-name}@sha256:{digest} --force-delete-tags  --quiet

Then you can parallelize and delete it! That's why I made a tool.

tool

What was made

https://github.com/h-r-k-matsumoto/gcr-garbage-collect

** Confirmation of deletion target **

$ java -jar gcr-garbage-collect-0.0.1-SNAPSHOT.jar --dry-run=true

** Delete execution **

$ java -jar gcr-garbage-collect-0.0.1-SNAPSHOT.jar --dry-run=false

** Delete only specific images **

java -jar gcr-garbage-collect-0.0.1-SNAPSHOT.jar --gcloud.container.image=asia.gcr.io/{gcp-project-id}/{image-name}

** Change the number of parallels **

$ java -jar gcr-garbage-collect-0.0.1-SNAPSHOT.jar --parallelism=16

Regarding creation

--I haven't seen the API for the container registry in Google Docs ... Since there is no help for it, I am using gcloud direct execution format. --In the windows environment, application.yaml or as a runtime argument
--gcloud.command =" C: / Program Files (x86) /Google/Cloud SDK/google-cloud-sdk/bin/gcloud.cmd Please specify "
etc.

Other

――I've used ProcessBuilder for a long time, but it doesn't absorb < and " depending on each OS. ――I wanted to make it a docker image, but I stopped because it was troublesome around gcloud authentication. ――I wondered how fast it was, but I decided to compare it, but I stopped because I didn't plan the speed in the first place. --I'm deleting it because of mental health problems only. Even if the old one remains, it doesn't hurt much. (GCS charges aren't too much to worry about)

Recommended Posts

I made a cleaning tool for Google Container Registry
I made a useful tool for Digital Ocean
I made a user management tool for Let's Chat
I made a dash docset for Holoviews
I made a client / server CLI tool for WebSocket (like Netcat for WebSocket)
I made a scaffolding tool for the Python web framework Bottle
I made a browser automatic stamping tool.
I made a library for actuarial science
I made a Docker container to use JUMAN ++, KNP, python (for pyKNP).
I made a python dictionary file for Neocomplete
I made a spare2 cheaper algorithm for uWSGI
I made a router config collection tool Config Collecor
I made a downloader for word distributed expression
I made a tool to compile Hy natively
I made a tool to get new articles
I made a peeping prevention product for telework.
〇✕ I made a game
I made a window for Log output with Tkinter
I made a VM that runs OpenCV for Python
[Python] I made a classifier for irises [Machine learning]
I made a repeating text data generation tool "rpttxt"
I made a python text
Made a command for FizzBuzz
I made a discord bot
[VSCode] I made a user snippet for Python print f-string
I made a tool to create a word cloud from wikipedia
I tried using Tensorboard, a visualization tool for machine learning
I made a resource monitor for Raspberry Pi with a spreadsheet
I made a learning kit for word2vec / doc2vec / GloVe / fastText
I made a face diagnosis AI for a female professional golfer ③
[Titan Craft] I made a tool to summon a giant to Minecraft
I made a tool that makes it convenient to set parameters for machine learning models.
I made a C ++ learning site
I touched PyAutoIt for a moment
I made a Line-bot using Python!
I made a CUI-based translation script (2)
Python> I made a test code for my own external file
I made a fortune with Python.
I made a lot of files for RDP connection with Python
I made a CUI-based translation script
I made a development environment for Django 3.0 with Docker, Docker-compose, Poetry
I made a daemon with Python
I made a Python wrapper library for docomo image recognition API.
I made a tool to automatically browse multiple sites with Selenium (Python)
[Updated Ver1.3.1] I made a data preprocessing library DataLiner for machine learning.
I made a note of Google colaboratory which can use Spleeter easily.
I made a CLI tool to convert images in each directory to PDF
I made a kind of simple image processing tool in Go language.
I made a tool to convert Jupyter py to ipynb with VS Code
I made a tool that makes decompression a little easier with CLI (Python3)
I made a new AWS S3 bucket
I made a payroll program in Python!
I touched "Orator" so I made a note
I made a character counter with Python
I made an alternative module for japandas.DataReader
Beginner: I made a launcher using dictionary
Memo for creating a text formatting tool
I made a conversation partner like Siri
I made a script to display emoji
A tool for easily entering Python code
I made a Hex map with Python