- Consulting
- Training
- Partners
- About Us
x
A Spot Fleet is a collection, or fleet, of Spot Instances, and optionally On-Demand Instances. The Spot Fleet attempts to launch the number of Spot Instances and On-Demand Instances to meet the target capacity that you specified in the Spot Fleet request. The Spot Fleet also attempts to maintain its target capacity fleet if your Spot Instances are interrupted.
Why Spot Instances?
Spot Instances are available at up to a 90% discount compared to On-Demand prices. You can use Spot Instances for various stateless, fault-tolerant, or flexible applications such as big data, containerized workloads, CI/CD, web servers, high-performance computing (HPC), and test & development workloads. Spot Instances are typically used to supplement On-Demand Instances, where appropriate, and are not meant to handle 100% of your workload.
OnDemand, Spot Instances and Spot Instance pool
With On-Demand Instances, you pay for compute capacity by the second with no long-term commitments. You have full control over its lifecycle—you decide when to launch, stop, hibernate, start, reboot, or terminate it.
A Spot Instance is an unused EC2 instance that is available for less than the On-Demand price. Because Spot Instances enable you to request unused EC2 instances at steep discounts, you can lower your Amazon EC2 costs significantly. Your Spot Instance runs whenever capacity is available and the maximum price per hour for your request exceeds the Spot price. Spot Instances are a cost-effective choice if you can be flexible about when your applications run and if your applications can be interrupted.
A Spot Instance pool is a set of unused EC2 instances with the same instance type (for example, m5.large), operating system, Availability Zone, and network platform. When you make a Spot Fleet request, you can include multiple launch specifications, that vary by instance type, AMI, Availability Zone, or subnet. The Spot Fleet selects the Spot Instance pools that are used to fulfill the request, based on the launch specifications included in your Spot Fleet request, and the configuration of the Spot Fleet request. The Spot Instances come from the selected pools.
Creating Spot Fleet
Tag your OnDemand Instance:
Before Migration from OnDemand to Spot instance, lets tag/label our OnDemand nodes. This will help us to distinguish between both the Instance type.
1 |
kubectl get nodes |
1 |
Kubectl label nodes –all ‘lifecycle=OnDemand’ |
1 |
Kubectl get nodes --label-columns=lifecycle --selector=lifecycle=OnDemand |
Create autoscaling group for Spot fleet:
1 |
--kubelet-extra-args ' --node-labels=lifecycle=Ec2Spot' |
1 |
Kubectl get nodes |
1 |
Kubectl get nodes --label-columns=lifecycle --selector=lifecycle=Ec2Spot |
Creating k8s spot termination Handler:
Demand for the spot instance varies significantly. The availability of spot instance also varies according to the availability of unused ec2 instance which might cause interruption. So, in this case we will be needing spot termination handler which will help us to send the interruption notice 2 minutes ahead to wrap up the things. so, k8s spot termination handler will help to detect and re deploy the application somewhere else in the cluster. we will deploy handler on each of the spot instances with the help of helm chart.
1 |
helm search repo |
1 |
helm fetch --untar stable/k8s-spot-termination-handler |
1 |
helm install k8s-spot-termination-handler k8s-spot-termination-handler/ \ |
1 |
-n kube-system |
1 |
helm upgrade k8s-spot-termination-handler k8s-spot-termination-handler/ -- set |
1 |
nodeSelector.lifecycle=Ec2Spot -n kube-system |
1 |
kubectl --namespace=kube-system get daemon sets |
Now change the Max count for OnDemand worker node autoscaling group same as Desired count. Cordon and Drain the OnDemand Instance which will migrate all the pods to spot instances.
In this way, we can use spot fleet on EKS worker Node.
If you want to learn more about Spot Fleet and Kubernetes, check out our Website.
Please comment if you have any questions.
Reference: https://docs.aws.amazon.com
Voiced by Amazon Polly |
CloudThat is a leading provider of cloud training and consulting services, empowering individuals and organizations to leverage the full potential of cloud computing. With a commitment to delivering cutting-edge expertise, CloudThat equips professionals with the skills needed to thrive in the digital era.
Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!
Praful Tamrakar
Sep 1, 2020
Nice and helpful
Click to Comment