GithubHelp home page GithubHelp logo

powerupcloud / kubernetes-spot-webinar Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 6.0 108 KB

Run your Kubernetes Workloads on Amazon EC2 Spot Instances

Dockerfile 8.33% Ruby 9.32% Python 31.20% HTML 15.22% JavaScript 9.72% Java 26.21%
aws kubernetes spot ec2 clusterautoscaler eks pod spot-instances demand-instances autoscaling-groups

kubernetes-spot-webinar's Introduction

Run your Kubernetes Workloads on Amazon EC2 Spot Instances

Reference: https://aws.amazon.com/blogs/compute/run-your-kubernetes-workloads-on-amazon-ec2-spot-instances-with-amazon-eks/

Provision EKS Worker Nodes

With Spot Instances, each instance type in each Availability Zone is a pool with its own Spot price based on the available capacity. A recommended best practice when working with Spot Instances is to use a diversified fleet of instances with multiple instance types, as created by Spot Fleet or EC2 Fleet. Unfortunately, Cluster Autoscaler does not support Spot Fleets at this time. You need a different strategy to provide diversification. Cluster Autoscaler for AWS provides integration with Auto Scaling groups. For Cluster Autoscaler and other cluster administration and management pods that run on EKS worker nodes, create a small Auto Scaling group using On-Demand Instances. This ensures that the health of the cluster is not impacted by Spot interruptions. The Cloudformation template deploys Auto Scaling groups dedicated to the following instance types:

  • Spot Instances, m4.large, across three Availability Zones.
  • Spot Instances, t2.medium, across three Availability Zones.
  • On-Demand Instances, across three Availability Zones. Create a Cloudformation stack in the AWS Console to provision the EKS worker nodes. Make sure that you apply the aws-auth-cm.yaml file with the appropriate NodeInstanceRole value, as provisioned by the CloudFormation template.

Cluster Autoscaler

Cluster Autoscaler scales the worker nodes available for pods to be placed. It automatically increases the size of an Auto Scaling group so that pods have a place to run. And it attempts to remove idle nodes, that is, nodes with no running pods. Update the below variables in cluster-autoscaler-ds.yaml:

  • Autoscaling Group Names of Ondemand and Spot Groups
  • MIN Count of the Autoscaling Groups
  • MAX Count of the Autoscaling Groups
  • AWS Region
kubectl apply -f cluster-autoscaler-ds.yaml

A PDB limits the number of replicated pods that can be down at a given time. Create a PDB to ensure that you always have at least one Cluster Autoscaler pod running.

kubectl apply -f cluster-autoscaler-pdb.yaml

Spot Interrupt Handler

The workflow of the Spot Interrupt Handler can be summarized as:

  • Identify that a Spot Instance is being reclaimed.
  • Use the 2-minute notification window to gracefully prepare the node for termination.
  • Taint the node and cordon it off to prevent new pods from being placed.
  • Drain connections on the running pods.
  • To maintain desired capacity, replace the pods on remaining nodes.
kubectl apply -f spot-interrupt-handler.yaml

Sample Application

The sample application is composed of 4 seperate microservices:

kubernetes-spot-webinar's People

Contributors

dependabot[bot] avatar powerupcloud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.