kvaps

Startup ideas

A cluster that reads the power exchange

energy kubevirt scheduling bare-metal cost

A controller that uses day-ahead market prices to hibernate deferrable VMs, cap node power and run heavy jobs in the hours when electricity is almost free.

Problem #

Small data centers, server rooms at factories, university clusters and miners who have switched to GPUs increasingly buy electricity on a dynamic tariff tied to the spot price. In Europe this is already routine: the price changes every 15 minutes, and on sunny weekends it drops to zero or below. In the Czech Republic such hours number in the hundreds per year.

And the cluster knows nothing about it. Nightly CI, rendering, model training, analytics recomputation and reindexing all start from cron at the same time every day, when the price may be at its peak. There is money to be saved, but right now it is done by a person with a spreadsheet, and, as usual, once a quarter.

Why now #

The move of European markets to 15-minute intervals made the price signal more precise, and price dips have become regular thanks to solar generation. At the same time, decent building blocks have appeared: KubeVirt can stop and start VMs, Kepler estimates per-pod consumption, and RAPL and nvidia-smi let you cap CPU and GPU power right from the node. All that’s left is to connect the signal to the action.

Why it’s cool #

The unfair advantage is three levers instead of one. Existing solutions mostly move replicas around. Here:

  1. Time shifting. Jobs and CronJobs with an annotation saying “can be deferred by up to N hours” wait for a cheap window. Essentially, this is a scheduler driven by deadlines, not by a timetable.
  2. Hibernation. VMs labeled interruptible are paused when the price peaks and woken up when it is cheap. For lab environments, CI runners in VMs and dev environments this just works.
  3. Power capping. If the work can’t be deferred, the node’s power limit is lowered via RAPL or nvidia-smi -pl. The job runs slower, but draws less during expensive hours.

Plus it works the other way too: when the price goes negative, the cluster picks up deferred work on its own, and the consumer gets paid for computing. That’s the part I like most :)

How to build it #

Stack: Go, controller-runtime, KubeVirt API, a DaemonSet on the nodes.

  1. Price source. Adapters for public day-ahead data (OTE, ENTSO-E Transparency Platform) and for the electricity supplier’s API. The result is an EnergyPrice object in the cluster with a forecast for the next day.
  2. Policy. An EnergyPolicy CRD: an “expensive” threshold, a “cheap” threshold, which workload classes may be moved and by how much.
  3. Deferred job controller. A mutating webhook puts a Job into suspend, and the controller lifts the suspend at the start of a cheap window or at the deadline. The deadline matters more than the savings.
  4. VM controller. Changes runStrategy on labeled VMs and respects a minimum run time so they don’t get flipped every 15 minutes.
  5. Node agent. Sets power limits on command and reports actual consumption.
  6. Report. How many kWh were shifted and what that would have cost on a fixed tariff.

First slice in two weeks: price from a single source, suspend and resume of Jobs by threshold, and the report. VMs and power capping are added in the next steps.

Who has tried #

  • Carbon Aware KEDA Operator from Azure changes KEDA’s maxReplicaCount based on carbon intensity. A different signal, and only one lever, replicas. Judging by its releases, the project hasn’t been developed in a long time.
  • Kepler (CNCF Sandbox) measures per-pod energy but does nothing with the workload. Here it is a data source.
  • Google has published work on carbon-intelligent computing that shifts flexible load in time, but it is an internal system; you can’t buy it from outside.

The difference: the target is the price in money for a specific consumer, and the tools include VM hibernation and power capping, not just scaling.

First customers #

Owners of GPU farms on a dynamic tariff, for whom electricity is the main expense. University and research clusters with a job queue. Small data centers with their own solar generation, for whom consuming the surplus pays better than selling it to the grid.

What kills it #

If a customer has a fixed tariff or electricity is included in the colocation price, there is nothing for them to save, and such customers are the majority. The second risk is the workload itself: there may turn out to be very little truly deferrable work, and people won’t let you touch the rest. And finally, if electricity suppliers start selling “smart load management” through their own gateways, we end up between them and the customer without much value.

Discuss with kvaps