Run a Kubernetes Cluster on Spot Instances in 4 Steps
In this tutorial, you will learn how to run your Kubernetes cluster on Amazon EC2 Spot instances, using Elastigroup.
Elastigroup lets you run Kubernetes clusters on Spot instances, without having to manage the underlying servers.
Containerized applications in general and Kubernetes services, in particular, are fault tolerant by nature, making them ideal candidates for Spot Instances. With Spot Instances, you can achieve substantial cost savings (up to 90%) without compromising on performance or availability. And with Elastigroup, there is no need to provision, manage or scale instances – we take care of all that for you.
You are now minutes away from running your Kubernetes cluster on Spot Instances. Let’s get started!
- A verified Spotinst Account.
- A Kubernetes cluster
Step 1: Open the Kubernetes creation wizard
Login to the Elastigroup Console (console.spotinst.com) and navigate to the Creation Wizard by clicking on the Create button in the Elastigroups tab.
Then, choose ‘Kubernetes – Join Existing Cluster’ to launch the creation wizard:
Step 2: Import Instance Configuration
With Elastigroup, you can get started quickly by importing instance configuration from existing instances. Elastigroup will import instance configurations such as AMI, security groups, and VPC. For a full list of configurations imported by Elastigroup, visit our docs.
You can select an autoscaling group, or an existing instance to import from:
Once you’ve selected an instance or ASG to import configuration from, click on ‘Next’
Step 3: Configure your cluster
In this step, we will start by setting the cluster’s capacity:
- The ‘target’ is the initially desired number of instances.
- The ‘minimum’ is the low boundary for your cluster size. Elastigroup will not scale below the minimum you set.
- The ‘maximum’ is the high boundary for your cluster size. Elastigroup will not scale above the maximum you set.
Next, we will select multiple ‘Spot types’ – these are instance types that you deem suitable for your Kubernetes cluster, based on the RAM and CPU that your applications are expected to consume.
Finally, you will need to select the availability zones and subnets in which your instances will be provisioned.
On the top right, you will find the Spotinst Spot Market scoring. Spotinst’s proprietary algorithms take into account vast amounts of availability and pricing data in order to provide scores for each Spot market (between 0 and 100), based on the market’s attractiveness. Spotinst then uses these scores to ensure your instances are provisioned in the markets that are the most cost-effective, and the least likely to get interrupted.
NOTE: Each Spot market is a combination of an AZ and instance type. It is recommended to enable as many Spot markets as possible (i.e. add instance types or AZs) for optimal performance and minimize costs.
Step 4: Install the Spotinst Kubernetes controller
We are almost there! All that is left is to install the Spotinst Kubernetes controller in your cluster. The Spotinst Kubernetes controller is a designated pod inside your Kubernetes cluster that reports cluster-related information, such as node utilization.
Elastigroup uses this information to scale your cluster up and down to ensure your optimal node packing.
To install it, simply run the bash script provided to you in the creation wizard’s ‘Connectivity’ stage. The script can be run from any machine that has Kubectl installed and is configured for your cluster.
You have now learned how to create a Kubernetes cluster on Spot instances with Spotinst, letting you:
- Cut your costs by up to 80%, while maintaining high availability.
- Run on spot instances with zero overhead, and no servers to manage – The Spotinst Elastigroup platform manages your infrastructure for you.
- Enjoy a Hands-free scaling experience – no need to define scaling policies; Spotinst Elastigroup will automatically scale your cluster up and down for optimized performance, and minimal costs.
Now that you have learned to deploy your Kubernetes cluster on Spot Instances with Spotinst, try Spotinst for other workloads.