This command finds and removes orphaned disks created by the kyma-gke-integration
job in a Google Cloud Platform (GCP) project.
When the kyma-gke-integration
job installs Kyma on the GKE cluster, GCP creates disk resources automatically.
Usually, the job that provisions the cluster cleans all such disks.
It can happen, however, that the job is terminated before its clean-up finishes.
This causes a resource leak that generates unwanted costs.
The garbage collector finds and removes such disks.
There are three conditions used to find disks for removal:
- The disk name pattern that is specific for the
kyma-gke-integration
job - The disk users count where zero means the disk is unused
- The disk
creationTimestamp
value that is used to find disks existing at least for a preconfigured number of hours
Disks that meet these conditions are subject to removal.
For safety reasons, the dry-run mode is the default one. To run it, use:
env GOOGLE_APPLICATION_CREDENTIALS={path to service account file} go run main.go \
--project={gcloud project name}
To turn the dry-run mode off, use:
env GOOGLE_APPLICATION_CREDENTIALS={path to service account file} go run main.go \
--project={gcloud project name} \
--dryRun=false
See the list of available flags:
Name | Required | Description |
---|---|---|
--project | Yes | GCP project name |
--dryRun | No | The Boolean value that controls the dry-run mode. It defaults to true . |
--ageInHours | No | The integer value for the number of hours. It only matches disks older than now()-ageInHours . It defaults to 2 . |
--diskNameRegex | No | The string value with a valid Golang regexp. It is used to match disks by their name. It defaults to ^gke-gkeint.*[-]pvc[-] . |
See the list of available environment variables:
Name | Required | Description |
---|---|---|
GOOGLE_APPLICATION_CREDENTIALS | Yes | The path to the service account file. The service account requires at least compute.zones.list , compute.disks.list , and compute.disks.delete Google IAM permissions. |