Skip to content

Commit a367f80

Browse files
authored
Merge pull request #3281 from Ankitasw/spot-instance-doc
docs: Added documentation for usage of spot instances
2 parents 8011425 + 62f6811 commit a367f80

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

docs/book/src/SUMMARY_PREFIX.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- [Topics](./topics/index.md)
99
- [Using clusterawsadm to fulfill prerequisites](./topics/using-clusterawsadm-to-fulfill-prerequisites.md)
1010
- [Accessing EC2 instances](./topics/accessing-ec2-instances.md)
11+
- [Spot instances](./topics/spot-instances.md)
1112
- [Machine Pools](./topics/machinepools.md)
1213
- [Multi-tenancy](./topics/multitenancy.md)
1314
- [EKS Support](./topics/eks/index.md)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Spot Instances
2+
3+
[AWS Spot Instances](https://aws.amazon.com/ec2/spot/?cards.sort-by=item.additionalFields.startDateTime&cards.sort-order=asc&trk=a9b30b20-d23f-4d61-9452-c51a7e407fcd&sc_channel=ps&sc_campaign=acquisition&sc_medium=ACQ-P|PS-GO|Brand|Desktop|SU|Compute|EC2%20Spot|IN|EN|Text&s_kwcid=AL!4422!3!517651795636!e!!g!!amazon%20ec2%20spot&ef_id=Cj0KCQiA95aRBhCsARIsAC2xvfxB17BKyQFcn9UUKZ1GT2sfvxKyhboEKa87gl8wBO37fSrNXmx52cIaAtqwEALw_wcB:G:s&s_kwcid=AL!4422!3!517651795636!e!!g!!amazon%20ec2%20spot) allows user to reduce the costs of their compute resources by utilising AWS spare capacity for a lower price.
4+
5+
Because Spot Instances are tightly integrated with AWS services such as Auto Scaling, ECS and CloudFormation, users can choose how to launch and maintain their applications running on Spot Instances.
6+
7+
Although, with this lower cost, comes the risk of preemption. When capacity within a particular Availability Zone is increased, AWS may need to reclaim Spot instances to satisfy the demand on their data centres.
8+
9+
## When to use spot instances?
10+
11+
Spot instances are ideal for workloads that can be interrupted. For example, short jobs or stateless services that can be rescheduled quickly, without data loss, and resume operation with limited degradation to a service.
12+
13+
## How to use spot instances?
14+
15+
To enable AWS Machine to be backed by a Spot Instance, users need to add `spotMarketOptions` to AWSMachineTemplate:
16+
```yaml
17+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
18+
kind: AWSMachineTemplate
19+
metadata:
20+
name: ${CLUSTER_NAME}-md-0
21+
spec:
22+
template:
23+
spec:
24+
iamInstanceProfile: nodes.cluster-api-provider-aws.sigs.k8s.io
25+
instanceType: ${AWS_NODE_MACHINE_TYPE}
26+
spotMarketOptions:
27+
maxPrice: ""
28+
sshKeyName: ${AWS_SSH_KEY_NAME}
29+
```
30+
Users may also add a `maxPrice` to the options to limit the maximum spend for the instance. It is however, recommended not to set a maxPrice as AWS will cap your spending at the on-demand price if this field is left empty, and you will experience fewer interruptions.
31+
```yaml
32+
spec:
33+
template:
34+
spotMarketOptions:
35+
maxPrice: 0.02 # Price in USD per hour (up to 5 decimal places)
36+
```
37+
> **IMPORTANT NOTE**: The experimental feature `MachinePool` does not support using spot instances as of now.

0 commit comments

Comments
 (0)