Volume Sweeper
A tool to scan and clean cloud infrastruture for unattached block volumes without kubernetes clusters persistent volumes.
- Supported Clouds
- Supported Kubernetes
- Prerequisits
- Installation
- Usage
- Documentation
- Design
- Algorithm
- Deployment
- Code
- Limitations
- Contributing
- License
Supported Clouds
- OCI
- AWS.
- GCP.
Supported Kubernetes
Any distributions + v1.19.
Prerequisits
- Kubernetes: a service account with read/update access to the cluster is required, scoped to
PVresources. - Cloud: access is required for block volumes service (BV) with read and delete roles.
Installation
$ gem install volume_sweeperUsage
To scan and generate a report:
volume_sweeper --account-id <ID> --cloud aws|oci --region <region>To apply deletion for unattached block volumes:
volume_sweeper --mode deleteFor all options:
volume_sweeper -h
Documentation
This tool tracks down unused block volumes in cloud accounts to clean once certain conditions met.
Design
Algorithm
FOR each_cluster IN oci|aws:
A] Fetch PVs (name, volHandle)
B] Fetch BLOCK VOL where (instance_attachment) = nil
C] Compare A ^ B to Extract Bx NOT IN Ax
THEN:
DEL [C] result
ENDDeployment
- Models:
- Can be run on demand as a CLI locally or remotely.
- background processing [CronJob].
- Has 2 modes: audit and delete.
- Notifications for email and teams channels.
Code
-
The library is a ruby CLI-based application.
-
Cluster integration layer is unified, using Kubernetes REST API server.
-
The cloud integration layer is written in provider design pattern.
-
Functionality can be extended for different cloud providers per the interface contract.
module VolumeSweeper module Providers class Base attr_reader :base_link def initialize **kwargs ... end def scan_volumes; end def delete_volumes ids_list; end end end end
Limitations
- No support for multiple clusters in the accounts or compartment.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/abarrak/volume_sweeper.