npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eks-spot-blocks

v0.2.373

Published

A sample JSII construct lib for AWS CDK

Downloads

10

Readme

awscdk-jsii-template NPM version PyPI version Release

cdk-eks-spotblocks

cdk-eks-spotblocks is a JSII construct library for AWS CDK to provison Amazon EKS cluster with EC2 Spot Blocks for defined workloads with the advantages of ensured availability and considerable price reduction for your kubernetes workload.

Features

  • [x] support the upstream AWS CDK aws-eks construct libraries by extending its capabilities
  • [x] addSpotFleet() to create your spot fleet for your cluster
  • [x] define your blockDuration, validFrom and validUntil for fine-graned control
  • [x] support any AWS commercial regions which has Amazon EKS and EC2 Spot Block support, including AWS China regions

Sample

import * as eksspot from 'eks-spot-blocks';
import * as cdk from '@aws-cdk/core';
import * as ec2 from '@aws-cdk/aws-ec2';

const clusterStack = new eksspot.EksSpotCluster(stack, 'Cluster', {
  clusterVersion: eks.KubernetesVersion.V1_16,
});

clusterStack.addSpotFleet('FirstFleet', {
  blockDuration: eksspot.BlockDuration.SIX_HOURS,
  targetCapacity: 1,
  defaultInstanceType: new ec2.InstanceType('p3.2xlarge'),
  validUntil: clusterStack.addHours(new Date(), 6).toISOString(),
  terminateInstancesWithExpiration: true
})

clusterStack.addSpotFleet('SecondFleet', {
  blockDuration: eksspot.BlockDuration.ONE_HOUR,
  targetCapacity: 2,
  defaultInstanceType: new ec2.InstanceType('c5.large'),
  validUntil: clusterStack.addHours(new Date(), 1).toISOString(),
  terminateInstancesWithExpiration: true
})

check eks-spot-blocks-demo for a full AWS CDK demo with this construct library.

Custom AMI support

const clusterStack = new EksSpotCluster(stack, 'Cluster', { 
  clusterVersion: eks.KubernetesVersion.V1_16,
  customAmiId: 'ami-xxxxxx'
});

FAQ

Does eks-spot-blocks support existing eks clusters created by eksctl, terraform or any other tools?

No. This construct library does not support existing Amazon EKS clusters. You have to create the cluster as well as the spot fleet altogether in this construct library.

Can I write the CDK in other languages like Python and Java?

Not at this moment. But we plan to publish this construct with JSII so we can install this library via npm, pypi, maven or nuget.

How much time can I block the spotfleet?

You can block the fleet with hourly increments up to 6 hours.

What happens after the blockDuration?

Spot Blocks ensure the availability of your spot instances during the blockDuration and avoid termination during the price disruption. After the blockDuration, by default, your spot instances will still be in running state but it doesn't ensure the availability, which means it might be terminated anytime after the blockDuration.

Can I terminate the fleet immediately after the blockDuration to save the money?

Yes. Basically you can configure validFrom, validUntil and terminateInstancesWithExpiration to achieve this.

However, consider the following scenario

<deploy start at 1:00>|--------(one hour)-----------------------|<2:00>
                           |<fleet created at 1:05>--------(one-hour block)-------|<2:05>

Your fleet will be terminated at 2:00 rather at 2:05.

Are tains and labels supported?

Yes.

(samples TBD)

Does it support AWS China regions?

Yes. Including Beijing(cn-north-1) and Ningxia(cn-northwest-1).

How much can I save from the EC2 Spot Block compared to the on-demand?

According to this document

Spot Instances are also available to run for a predefined duration – in hourly increments up to six hours in length – at a discount of up to 30-50% compared to On-Demand pricing.

Will this library become part of the upstream aws-eks construct library?

Probably. As it's still in the preliminary stage, we are still collecting feedbacks from the community to make eks-spot-blocks ready for production workloads. Eventually we will commit this feature to the upstream aws-eks construct library in AWS CDK through pull requests.