Cloud Technology Community Question

Can Kubernetes manage "Spot" instances for AI training to reduce cloud costs?

Posted on 2025-05-19 • In Cloud Technology • By Deborah King

Deep learning training is getting expensive. Can Kubernetes handle running our jobs on Spot or Preemptible instances? Specifically, if the cloud provider reclaims the node mid-training, does the cluster have a way to gracefully checkpoint the model and restart the job on a different node?

3 Answers 17,862 Views

All answers to this question 3 Answers

Laura Griffin Answered on 2025-05-21
Answered

Yes, and this is where Kubernetes really shines for cost-saving. You use "Node Affinity" to prefer Spot nodes for training jobs. To handle preemption, you need two things: a "Termination Handler" and model checkpointing in your code. The termination handler catches the 2-minute warning from the cloud provider and sends a SIGTERM to your pod. Your code should catch that signal, save the current weights to a persistent volume (like S3 or an Azure Disk), and exit. Kubernetes then sees the pod failed and, thanks to the "Job" controller, automatically reschedules it on a new available node to resume

Gary Peterson Answered on 2025-05-23
Answered

What happens if there are no more Spot instances available in that region? Does the training just stop forever, or can Kubernetes failover to a full-priced "On-Demand" node automatically?

Laura Griffin Commented on 2025-05-25
Commented

You can set up "Node Groups" with different priorities. You define a Spot group as priority 1 and an On-Demand group as priority 2. If the Cluster Autoscaler fails to find a Spot node after a certain timeout, it will fall back to provisioning an On-Demand node. This ensures your deadline is met even if the Spot market is tight. It’s the perfect balance between saving money and ensuring the job actually gets finished.

Brian Castro Answered on 2025-05-26
Answered

We use the "Karpenter" autoscaler for this. it’s much faster at picking the cheapest instance type available that fits the GPU requirements of the pod.

Deborah King Commented on 2025-05-28
Commented

I've heard great things about Karpenter. Its ability to "right-size" the node to the pod's exact request is a game changer for AI cost management.

Write a Comment

Your email address will not be published. Required fields are marked (*)

Join the LearnersEra Community

Ask questions, share knowledge and learn from professionals across technology, project management and certification topics.

Change Country and Nearest City

Select your country and nearest city to see courses available in your region.