Skip to main content

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

  • support the upstream AWS CDK aws-eks construct libraries by extending its capabilities
  • addSpotFleet() to create your spot fleet for your cluster
  • define your blockDuration, validFrom and validUntil for fine-graned control
  • 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.

Metadata

Release files for eks-spot-blocks 0.2.373

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for eks-spot-blocks 0.2.373
File Size Uploaded Provenance Actions
eks-spot-blocks-0.2.373.tar.gz 52.4 kB Without provenance Details for eks-spot-blocks-0.2.373.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for eks-spot-blocks 0.2.373
File Interpreter ABI Platform Actions
eks_spot_blocks-0.2.373-py3-none-any.whl Python 3 none any Details for eks_spot_blocks-0.2.373-py3-none-any.whl

Total release size: 103.2 kB

Release files / eks-spot-blocks-0.2.373.tar.gz

Download URL eks-spot-blocks-0.2.373.tar.gz
Size 52.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a5cd7a821c177a1ed5a3a4d34ba27c8637d7f3d8b3eda372192c847bb8566f8d
BLAKE2b-256 checksum
How to use checksums
2b6dd2ac92036da916a206c91bf8f3926eb14db4f1af74c400f11842257f1d81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.6.4 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.7.10

Release files / eks_spot_blocks-0.2.373-py3-none-any.whl

Download URL eks_spot_blocks-0.2.373-py3-none-any.whl
Size 50.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ce1f4e1d19e76b3459508a12f2818a3f49b8938c05360dfe482cf469afccac6
BLAKE2b-256 checksum
How to use checksums
de2ad91292b8912868fd8315f9f1f4c1b592fa87e9a882af2da0d057c2e33511
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.6.4 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.7.10

Security for eks-spot-blocks 0.2.373

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.373 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page