Resources Clean Up Tool
This tool is designed to clean up stale test resources. For now it deletes GCR images and GKE clusters created during testing.
It can also be used to delete GCR images and GKE clusters from an arbitrary project.
go run cleanup.go with one of more of the flags below.
By default the current gcloud credentials are used to delete the images. If
necessary, use the flag
--service-account _key-file.json_ to specify a service
account that will be performing the access to the gcr.
Project(s) to be cleaned up are expected to be either defined in a text file or
passed (once or multiple times) using the
The following flags are available for the tool:
--project-resource-yamlPoints to a resources file containing the names of the projects to be cleaned up. Such file can be any form of text, as long as the project names can be extracted, one per line, using a regular expression.
--projectProject to be cleaned up.
--re-project-nameRegular expression for filtering project names from the resources file. Optional, defaults to
--days-to-keep-imagesOptional, defaults to 365 days (aka 1 year).
--hours-to-keep-clustersOptional, defaults to 720 hours (aka 30 days).
--gcrDefines the GCR hostname to use (e.g.,
us.gcr.io). Optional, defaults to
--dry-runOptional, performs a dry run for all gcloud functions, defaults to false.
This command deletes test images older than 90 days and test clusters created more than 24 hours ago in all Boskos projects.
$ go run cleanup.go --project-resource-yaml config/prod/prow/boskos_resources.yaml --days-to-keep-images 90 --hours-to-keep-clusters 24`
This command deletes test images older than 1 day and test clusters created more
than 24 hours ago in a personal project called
$ go run cleanup.go --project my-knative-project --days-to-keep-images 1 --hours-to-keep-clusters 24`
There is a weekly prow job that triggers this tool runs at 11:00/12:00PM(Day light saving) PST every Monday. This tool scans all projects defined in config/prod/prow/boskos_resources.yaml and deletes images older than 90 days and clusters older than 24 hours.
There is no documentation for this package.