Amazon Web Services is the leading Infrastructure as a Service (IaaS) provider. They have over 50+ groups of services that run the gamut from mobile services to services to support Internet of Things (IoT). They are most well known for their EC2 and S3 services, and in leveraging this broad base, they are able to layer additional, more complex services on top. The EC2 Container Service leverages EC2 compute instances to provide a quick way to set up and scale a container cluster.
The EC2 instances backing ECS use all of the supporting features you are familiar with in AWS. When you configure your initial cluster (or any subsequent cluster for that matter), ECS configures EC2 instances as cluster hosts and configures security groups, VPCs, subnets, routes, and gateways to support them. The cluster also comes online with a suite of basic metrics on CPU and memory utilization.
EC2 leverages the docker engine as a container primitive. This is different, and not to be confused with any of Docker’s enterprise-geared cluster management offerings like Docker Datacenter. ECS is designed to replace the need for a container cluster manager to manage these Docker containers in production. Another benefit of using ECS as an AWS-aware cluster manager is that if the cluster needs to increase the number of hosts, it can do so as needed. You can also pair scaling your hosts with scaling your service running containerized leveraging Service Auto Scaling and CloudWatch.
Head’s up – here are a couple of items to be aware of when you are first getting started. There is currently no Windows support for the ECS CLI. (You will quickly run into a known bug if you try and follow the Getting Started tutorial from a PC.) Also, during the initial configuration of ECS, you will be prompted to create a build repository. This repository will be hosted on S3, and will be used as a source for images used to launch services and tasks.
Clusters and Instances
EC2 Container Service, as the name describes, runs on EC2 instances. When starting for the first time, you will use a wizard to build your initial cluster. From there, you can modify or build additional clusters on the Clusters tab. These EC2 instances use the AWS-developed open-source “ecs agent” to run the containers. The multiple clusters can be accessed through the Management Console or using different AWS profiles on the command line.
Services and Tasks
The functions of ECS you will be engaging with the most are services and task definitions. A task definition describes the details of a particular group of containers; what data volumes they should attach at run time; what interfaces should be exposed and how they are addressed; and how they should be operated together.
A service is the running state of this task definition. As part of the task, a minimum healthy percentage and maximum percentage can be set. The service will be maintained to those specifications. Additional containers will be launched if needed to maintain the service above the minimum health, and shut down if it exceeds the maximum. A number of task instances running can be set to duplicate the definition a number of times as separate services. The task instance value is set to one by default. The task definition can be revised (everything is version controlled), and a new service will be spun up to match the newly modified definition. ECS will ensure the new service is accessible, and then terminate the old service.
A recent addition to the ECS now allows for an Elastic LoadBalancer (ELB) to be placed in front of a service, and dynamic ports to be assigned. This update now lets multiple instances of the same task run on the same host. This update also adds an initial framework to support service discovery. The AWS team blog post on the update can be found here.
AWS is great for building and running instances for a cluster, and is slowly accumulating features to effectively manage a cluster running on those instances. If you are looking to run containers in production and already use AWS, ECS is definitely worth checking out.
About the Author
Over the last 10 years, Sara Jeanes has held numerous program management, engineering, and operations roles. She has led multiple team transformations and knows first-hand the pain of traditional waterfall development. She is a vocal advocate for DevOps, microservices, and the cloud as tools to create better products and services. You can follow Sara on Twitter @sarajeanes.
Getting Started with AWS EC2 Container Service (ECS) is published by the Sumo Logic DevOps Community. If you’d like to learn more or contribute, visit devops.sumologic.com. Also, be sure to check out Sumo Logic Developers for free tools and code that will enable you to monitor and troubleshoot applications from code to production.