-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
rehno-lindeque
wants to merge
34
commits into
NixOS:master
Choose a base branch
from
rehno-lindeque:spot-fleet
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
WIP: Spot fleets #149
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 toMachineState
s 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
(This is my first nixops PR, feel free to point out any improvements I could make.)