Home

Awesome

Spot Instances use and management for Kubernetes

The minion-manager enables the intelligent use of Spot Instances in Kubernetes.

🚨 ⚠️THIS PROJECT IS NOW BEING ABANDONED ⚠️ 🚨

We originally developed Minion Manager in 2018 to intelligently manage the use of AWS Spot Instances in Kubernetes. Since then, there have been many changes to how Kubernetes is run and operated in AWS, the most significant being the introduction of EKS, Managed Node Groups, and, most recently, Karpenter.

We recommend using Karpenter to manage Spot Instances. The Minion Manager repository will be archived, and there will be no further updates or releases.

What does it do?

Prerequisites

It's best to run the minion-manger on an on-demand instance.

The IAM role of the node that runs the minion-manager should have the following policies.

{
    "Sid": "kopsK8sMinionManager",
    "Effect": "Allow",
    "Action": [
        "ec2:DescribeInstances",
        "ec2:TerminateInstances",
        "ec2:DescribeSpotPriceHistory",
        "ec2:DescribeSpotInstanceRequests",
        "autoscaling:CreateLaunchConfiguration",
        "autoscaling:DeleteLaunchConfiguration",
        "autoscaling:DescribeLaunchConfigurations",
        "autoscaling:DescribeAutoScalingGroups",
        "autoscaling:TerminateInstanceInAutoScalingGroup",
        "autoscaling:UpdateAutoScalingGroup",
        "autoscaling:DescribeScalingActivities",
        "iam:PassRole"
    ],
    "Resource": [
	"*"
    ]
}

Installing

Modify the deploy/mm.yaml by

  1. Add the names of your cluster instead of <my-cluster-name>
  2. Change the namespace where the minion-manager will be run.

Then, kubectl apply -f deploy/mm.yaml.

Design:

What happens when:

1. User runs k8s-minion-manager without any ASG having the "k8s-minion-manager" tag?

k8s-minion-manager ignores all ASGs. It simply continues to keep polling AWS for the tags every "refresh-interval" seconds.

2. User runs k8s-minion-manager, adds the "k8s-minion-manager" tag and the "use-spot" value to start with. But later wants to not use spot instances.

User should then change the key from "use-spot" to "no-spot". This will indicate to the k8s-minion-manager that the ASG should have all on-demand instances and it will make sure of that.

3. User runs k8s-minion-manager, adds the "k8s-minion-manager" key and the "use-spot" value to start with. But later simply removes the tag and the value.

Once the tag is removed, k8s-minion-manager simply considers the ASG to be off-limits and does not act upon it. The ASG will remain in whatever condition it is in.

4. User runs k8s-minion-manager, adds the "k8s-minion-manager" key and the "no-spot" value to start with. But later simply removes the tag and the value.

Same as above. The ASG will remain in whatever condition it is in.

5. User is running k8s-minion-manager and using spot instances. But now wants to stop using instances forever.

This will be a multi-step process:

How do I:

1. Run unit tests: Ensure that your AWS cli is set up correctly. Then simply run make docker-test