GithubHelp home page GithubHelp logo

henrysher / ecs-cid-sample Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aws-samples/ecs-cid-sample

0.0 2.0 0.0 7.83 MB

In this code provided with the blog, we will demonstrate how to use the draining state to update the AMI used by EC2 instances in your cluster by updating the launch configuration of your auto-scaling group. The process also ensures that the EC2 instances get the tasks drained the tasks launch on new container instance before termination occurs.

License: Apache License 2.0

Python 100.00%

ecs-cid-sample's Introduction

ECS Container draining

Amazon EC2 Container Service (Amazon ECS) is a container management service that makes it easy to run, stop, and manage Docker containers on a cluster of Amazon EC2 instances. When you run tasks using Amazon ECS, you place them on a cluster, which is a logical grouping of EC2 instances. Amazon ECS downloads your container images from a registry that you specify, and runs those images on the container instances within your cluster.

There are times when EC2 instances need to be removed from the cluster, for example cluster scale-down or updating an AMI. Today we have delivered Container Instance Draining to simplify these scenarios. The draining state prevents new tasks from being started on the container instance, notifies the service scheduler to move tasks that are running on the instance to other instances in the cluster, and enables you to wait until tasks have successfully moved before terminating the instance.

Overview of steps

  1. Download index.zip from this repository

  2. Upload the downloaded index.zip containing Lambda code index.py to [Your_AWS_Account_S3_Bucket]

  3. Download the CloudFormation template

  4. Launch the CloudFormation template that creates the following AWS resources:

  • CloudFormation will require S3 bucket name as one of the parameters you created in Step 2 above.
  • The VPC and associated network elements (subnets, security groups, route table, etc)
  • ECS Cluster, ECS service, a sample ECS task definition
  • Auto scaling group with two EC2 instances and a termination lifecycle hook
  • Lambda function, permissions to invoke lambda, and lambda execution roles
  • SNS topic, policy

For the full solution overview visit Blog link.

CloudFormation template

  • cform/ecs.yaml

Solution code

  • code/index.py

Copyright 2016-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at

http://aws.amazon.com/apache2.0/

or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

PLEASE NOTE

Lambda version of boto3 DOES NOT have the latest version of boto3 that (as of February 10th). This leads to user experiencing issue similar to one reported in aws-samples#2 . Please use the index.zip package provided, or if you are customizing code, package up the latest boto3 in the Lambda zip file.

ecs-cid-sample's People

Contributors

mperi avatar cbbarclay avatar hyandell avatar

Watchers

Henry Huang 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.