eks-spot-blocks


Nameeks-spot-blocks JSON
Version 0.2.92 PyPI version JSON
download
home_pagehttps://github.com/pahud/cdk-eks-spotblocks.git
SummaryA sample JSII construct lib for AWS CDK
upload_time2020-10-24 01:20:21
maintainer
docs_urlNone
authorPahud Hsieh<pahudnet@gmail.com>
requires_python>=3.6
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![awscdk-jsii-template](https://img.shields.io/badge/built%20with-awscdk--jsii--template-blue)](https://github.com/pahud/awscdk-jsii-template)
[![NPM version](https://badge.fury.io/js/eks-spot-blocks.svg)](https://badge.fury.io/js/eks-spot-blocks)
[![PyPI version](https://badge.fury.io/py/eks-spot-blocks.svg)](https://badge.fury.io/py/eks-spot-blocks)
![Release](https://github.com/pahud/eks-spot-blocks/workflows/Release/badge.svg)

# 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.

![](images/pahud_eks-spot2.svg)

## 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

```python
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import eks_spot_blocks as eksspot
import aws_cdk.core as cdk
import aws_cdk.aws_ec2 as ec2

cluster_stack = eksspot.EksSpotCluster(stack, "Cluster",
    cluster_version=eks.KubernetesVersion.V1_16
)

cluster_stack.add_spot_fleet("FirstFleet",
    block_duration=eksspot.BlockDuration.SIX_HOURS,
    target_capacity=1,
    default_instance_type=ec2.InstanceType("p3.2xlarge"),
    valid_until=cluster_stack.add_hours(Date(), 6).to_iSOString(),
    terminate_instances_with_expiration=True
)

cluster_stack.add_spot_fleet("SecondFleet",
    block_duration=eksspot.BlockDuration.ONE_HOUR,
    target_capacity=2,
    default_instance_type=ec2.InstanceType("c5.large"),
    valid_until=cluster_stack.add_hours(Date(), 1).to_iSOString(),
    terminate_instances_with_expiration=True
)
```

check [eks-spot-blocks-demo](https://github.com/pahud/eks-spot-blocks-demo) for a full AWS CDK demo with this construct library.

## Custom AMI support

```python
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
cluster_stack = EksSpotCluster(stack, "Cluster",
    cluster_version=eks.KubernetesVersion.V1_16,
    custom_ami_id="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](https://aws.amazon.com/ec2/spot/pricing/?nc1=h_ls)

`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.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pahud/cdk-eks-spotblocks.git",
    "name": "eks-spot-blocks",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Pahud Hsieh<pahudnet@gmail.com>",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/a2/01/7f8554c81ec0b5143b975b697c996ce5c56facd67af312fddd67e2c9daa2/eks-spot-blocks-0.2.92.tar.gz",
    "platform": "",
    "description": "[![awscdk-jsii-template](https://img.shields.io/badge/built%20with-awscdk--jsii--template-blue)](https://github.com/pahud/awscdk-jsii-template)\n[![NPM version](https://badge.fury.io/js/eks-spot-blocks.svg)](https://badge.fury.io/js/eks-spot-blocks)\n[![PyPI version](https://badge.fury.io/py/eks-spot-blocks.svg)](https://badge.fury.io/py/eks-spot-blocks)\n![Release](https://github.com/pahud/eks-spot-blocks/workflows/Release/badge.svg)\n\n# cdk-eks-spotblocks\n\n`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.\n\n![](images/pahud_eks-spot2.svg)\n\n## Features\n\n* [x] support the upstream AWS CDK `aws-eks` construct libraries by extending its capabilities\n* [x] `addSpotFleet()` to create your spot fleet for your cluster\n* [x] define your `blockDuration`, `validFrom` and `validUntil` for fine-graned control\n* [x] support any AWS commercial regions which has Amazon EKS and EC2 Spot Block support, including AWS China regions\n\n## Sample\n\n```python\n# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826\nimport eks_spot_blocks as eksspot\nimport aws_cdk.core as cdk\nimport aws_cdk.aws_ec2 as ec2\n\ncluster_stack = eksspot.EksSpotCluster(stack, \"Cluster\",\n    cluster_version=eks.KubernetesVersion.V1_16\n)\n\ncluster_stack.add_spot_fleet(\"FirstFleet\",\n    block_duration=eksspot.BlockDuration.SIX_HOURS,\n    target_capacity=1,\n    default_instance_type=ec2.InstanceType(\"p3.2xlarge\"),\n    valid_until=cluster_stack.add_hours(Date(), 6).to_iSOString(),\n    terminate_instances_with_expiration=True\n)\n\ncluster_stack.add_spot_fleet(\"SecondFleet\",\n    block_duration=eksspot.BlockDuration.ONE_HOUR,\n    target_capacity=2,\n    default_instance_type=ec2.InstanceType(\"c5.large\"),\n    valid_until=cluster_stack.add_hours(Date(), 1).to_iSOString(),\n    terminate_instances_with_expiration=True\n)\n```\n\ncheck [eks-spot-blocks-demo](https://github.com/pahud/eks-spot-blocks-demo) for a full AWS CDK demo with this construct library.\n\n## Custom AMI support\n\n```python\n# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826\ncluster_stack = EksSpotCluster(stack, \"Cluster\",\n    cluster_version=eks.KubernetesVersion.V1_16,\n    custom_ami_id=\"ami-xxxxxx\"\n)\n```\n\n## FAQ\n\n### Does `eks-spot-blocks` support existing eks clusters created by `eksctl`, `terraform` or any other tools?\n\nNo. 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.\n\n### Can I write the CDK in other languages like `Python` and `Java`?\n\nNot at this moment. But we plan to publish this construct with `JSII` so we can install this library via `npm`, `pypi`, `maven` or `nuget`.\n\n### How much time can I block the spotfleet?\n\nYou can block the fleet with hourly increments up to 6 hours.\n\n### What happens after the `blockDuration`?\n\nSpot 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`.\n\n### Can I terminate the fleet immediately after the `blockDuration` to save the money?\n\nYes. Basically you can configure `validFrom`, `validUntil` and `terminateInstancesWithExpiration` to achieve this.\n\nHowever, consider the following scenario\n\n```\n<deploy start at 1:00>|--------(one hour)-----------------------|<2:00>\n                           |<fleet created at 1:05>--------(one-hour block)-------|<2:05>\n```\n\nYour fleet will be terminated at `2:00` rather at `2:05`.\n\n### Are `tains` and `labels` supported?\n\nYes.\n\n(samples TBD)\n\n### Does it support AWS China regions?\n\nYes. Including **Beijing**(`cn-north-1`) and **Ningxia**(`cn-northwest-1`).\n\n### How much can I save from the EC2 Spot Block compared to the on-demand?\n\nAccording to this [document](https://aws.amazon.com/ec2/spot/pricing/?nc1=h_ls)\n\n`Spot Instances are also available to run for a predefined duration \u2013 in hourly increments up to six hours in length \u2013 at a discount of up to 30-50% compared to On-Demand pricing.`\n\n### Will this library become part of the upstream `aws-eks` construct library?\n\nProbably. 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.\n\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "A sample JSII construct lib for AWS CDK",
    "version": "0.2.92",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "d9ddfa41fad708489c1e91c083977bfa",
                "sha256": "8dab962973840c7b26f8cf55caff7adf9fab39af6b44350186a355e928c420f2"
            },
            "downloads": -1,
            "filename": "eks_spot_blocks-0.2.92-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d9ddfa41fad708489c1e91c083977bfa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 42250,
            "upload_time": "2020-10-24T01:20:20",
            "upload_time_iso_8601": "2020-10-24T01:20:20.206320Z",
            "url": "https://files.pythonhosted.org/packages/bf/ab/595d435e7f29eb28138f4d7f8e80c7429b07fea015b0a0b9cc4680ef642e/eks_spot_blocks-0.2.92-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "66fdd0eba2a6d21fe787f3ac9d025d1c",
                "sha256": "30f63ed5d9e21c230bf4b171f515069726eaaec3be984a7821d2657f317bf1c0"
            },
            "downloads": -1,
            "filename": "eks-spot-blocks-0.2.92.tar.gz",
            "has_sig": false,
            "md5_digest": "66fdd0eba2a6d21fe787f3ac9d025d1c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 44116,
            "upload_time": "2020-10-24T01:20:21",
            "upload_time_iso_8601": "2020-10-24T01:20:21.636605Z",
            "url": "https://files.pythonhosted.org/packages/a2/01/7f8554c81ec0b5143b975b697c996ce5c56facd67af312fddd67e2c9daa2/eks-spot-blocks-0.2.92.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-10-24 01:20:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "pahud",
    "error": "Could not fetch GitHub repository",
    "lcname": "eks-spot-blocks"
}
        
Elapsed time: 0.19506s