Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Spot fleets #149

Draft
wants to merge 34 commits into
base: master
Choose a base branch
from
Draft

Conversation

rehno-lindeque
Copy link

@rehno-lindeque rehno-lindeque commented Oct 6, 2021

This is a draft PR, please don't review it yet. (Right now it includes unrelated commits)

I just wanted to share that I'm working on spot fleets for now in case anyone is specifically interested in the topic.

Use cases

AWS supports two types of persistence for spot fleets: request, maintain

  • Individual spot instance requests:
    Right now one-off spot requests with nixops are pretty inconvenient because you often have to play battleship with your configuration until you manage to find capacity.
    By contrast, a spot fleet request allows you to specify a range of availability zones, instance types, etc. That is, AWS is given the freedom to pick one for you.

  • Maintained fleet of instances
    It's also possible to create a fleet of instances that will scale and terminate / respawn with AWS's available capacity.
    I don't plan to support this use case directly with nixops machine provisioning for now, but never-the-less it's quite possible to simply use an AMI image that has been captured from some initial ec2 machine.

Methodology

  • The spot fleet request is defined as a resource, unlike how spot instance requests are currently defined in nixops. This is done to support both use cases above (and perhaps others I'm not aware of).

  • TODO: I'm not 100% sure yet how provisioning will work, but I imagine we can give a machine definition a target fleet request id and then proceed in a somewhat similar way to spot instance requests.
    (I.e. call describe_spot_fleet_instances to find a list of available instances and assign them to MachineStates until they are all fullfilled.)

  • A possible implementation detail which I think might be future work is to automatically modify TargetCapacity of the spot fleet based on the number of machine definitions that reference the spot fleet. My gut feeling is that this is an extension of the basic functionality that ought to be added in a future PR rather than this one. I prefer specifying target capacity directly for the base implementation.

Work in progress

  • Resource: Launch template (TODO: split into its own PR - it is based on aws: add aws-ec2-launch-template resource #21)
  • Resource: Spot fleet request
    • Spot fleet based on launch template configuration + overrides
    • Spot fleet based on launch specification
  • Provisioning machines by referencing a spot fleet

(This is my first nixops PR, feel free to point out any improvements I could make.)

roberth and others added 30 commits October 2, 2021 09:44
It has been defined as the identity function for a long time.

See NixOS/nixpkgs#129993
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants