When you let a game dev make an UI for a cloud housekeeping tool ( Link to source in post )

that’s pretty sick

Star Trek vibes. Love it

dont like it, too many stimules, is distracting

“It’s a Unix system, I know this”

Hack the gibson…

How do you grep?

Really cool, would be great if you could give a brief spiel on what the tool does besides what has been demoed

So the UI is just a prototype for the backend tool. Cloudkeeper is doing cloud housekeeping. I wrote it at my last job for my own needs and we open sourced it.

It crawls your AWS or GCP account(s) fetches the resources it currently knows about (mostly EC2, IAM, RDB, ALB/ELB, Cloudformation i.e. infrastructure and compute stuff) puts them into a large graph and allows you to query them and optionally call the delete() method on most of them for cleanup.

There’s also K8S, Slack, OneLogin and VSphere collector plugins but AWS and GCP are most mature.

That’s the brief description.

Here’s some more extensive info:

Query example: find all the EBS volumes that are not in use, older than 30 days and had no I/O in the past 7 days:

match is(aws_ec2_volume) and volume_status = available and ctime < -30d and atime < -7d and mtime < -7d

Now if you want to clean them up just add a | clean behind the query and all the found resources get marked for cleanup during the next cleanup cycle (for this to work the ckworker component needs to be purposefully started with the --cleanup flag, otherwise no delete code is loaded).

If you wanted to do the same for GCP disks replace is(aws_ec2_volume) with is(gcp_disk) or if you would like to target any storage volume regardless of the cloud use is(volume). Both aws_ec2_volume and gcp_disk inherit from volume.

Behind the scenes it does some fancy trickery like for volumes it fetches cloudwatch metrics and look for the last read or write requests to map their timestamps to primitives like atime and mtime. When you have a user object or an access key atime would be the time that access key was last used, etc. So it maps those fields depending on the type of resource.

You can get pretty complex with your conditions. Like take this query:

is(aws_alb) and ctime < -7d with(empty, <-- is(aws_alb_target_group) and target_type = instance and ctime < -7d with(empty, <-- is(aws_ec2_instance) and instance_status != terminated)) <-[0:1]- is(aws_alb_target_group) or is(aws_alb)

This would find all the ALBs and ALB target groups where both are older than 7 days and the ALB either has no target group or all the target groups attached to the ALB are of type “instance” (so any ALBs with IP of Lambda target groups are not selected) have no instances or all the instances attached to any of the target groups are in a terminated state. I.e. it find’s orphaned load balancers.

And then like before you could pipe the output of that query into a | clean and they get flagged for cleanup.

Queries can be scheduled so you could configure the system to run them whenever it updates the graph with the latest data from your clouds.

There’s also a metrics component ckmetrics that can export your cloud metrics like “how many cores of which instance type do I have in what account and region” into Prometheus. So then you can have nice Grafana dashboards showing your resource usage and cost over time.

We’re currently putting most work into writing documentation because it’s really lacking. The tool is quite the beast but the docs right now only show very simple examples.

Hope this gives a good overview and maybe is useful for someone.

Just start typing to enter “search” mode. Alternatively at the bottom of the screen is the CLI or on the shell run cksh and use something like match is(aws_ec2_instance) and tags.owner ~ thatguy to find all the EC2 Instances where thatguy has tagged himself as the owner :slight_smile:

What’s the UI written in?

Any plans to support Azure in addition to those platforms? Or openness to contributions in that direction?

Yes, we have Azure as well as others like IBM Cloud, Digital Ocean, Scaleway, OVH, Alibaba, etc. in our backlog. AWS and GCP are there simply because they are the ones I used in my last job.

If you know Python and are interested in contributing, there is an example collector in the plugins/example_collector/ folder. Again documentation is lacking, but if you’re interested I could help with the details.

The basic idea is this: We have a central component ckcore maintaining the global graph and one or more ckworker loading collector plugins.

Every collector plugin is responsible for building its own subgraph which at the end of the collect run gets merged with the others and send to the core.

How the plugin builds that graph is entirely up to the plugin. If you wanted to write a collector that fetches data from your plant watering sensors you could do that.

We have a set of base resources (https://github.com/someengineering/cloudkeeper/blob/main/cklib/cklib/baseresources.py) that your own collector resources can inherit from. So for instance Amazon Elastic Block Store, Google Compute Engine Persistent Disks and Azure Managed Disks would all inherit from BaseVolume which provides some common attributes like storage size, IOPS, encryption setting, etc.

The advantage of this approach is that once a resource inherits from a common base resource it’ll automatically show up in your metrics and also all existing policies apply to it. So if you have a rule saying “all storage volumes must be encrypted” it would automatically apply to any new cloud added without the need to adjust the query that makes up the policy.

Or in my last company we had a rule saying all resources in our dev accounts must be tagged with an owner. Anything not properly tagged 2h after creation was cleaned up again.

We’re using an MIT licensed 2D/3D engine called Godot. It’s made for games but has incredibly powerful UI components and is very lightweight (70MB download). If you ever worked with Qt you’ll know what I mean (multi GB).

But that looks awesome!