Friday, November 4, 2016

Setting up Amazon EC2 Container Service (ECS)

I've been experimenting with deploying containers to the AWS cloud. There's a really detailed guide on the AWS site that they provide on running containers using their container service, ECS. Yesterday I successfully deploy a couple of containers running a simple ruby Sinatra app! Here's a high level view of what you'll need to do in order to get your containers running.
  1. Create an AWS account 
  2. Sign up for AWS ECS
  3. Create a private docker image repository on ECS
  4. Build and push your docker image to your ECS image repository
  5. Create a task definition using your docker image
  6. Create a cluster
  7. Create an EC2 instance using an ECS-optimized image and register it with your cluster
  8. Create an elastic load balancer (ELB)
  9. Create a container service in your cluster and configure it to use your ELB
By the end, you will be able to visit the public DNS of your ELB which will forward requests to one of the containers you have running inside an EC2 instance. Most of the work lies in the configuration and a lot of that is not fun. I'm trying to reduce the job of deploying containers down to:
  1. Build and push your docker image to your ECS image repository
Everything else will be done automatically based on default configuration. I should be able to just visit a URL and see my running application. Adding more layers of the stack to it will take more work, but just running containers using a single image should be as easy as that.

Some questions I still have are:
  • What's the easiest way to deploy new images for an application to ECS? Ideally I just have to hit push and then the existing containers are replaced by new containers running my new image.
  • How do IAM roles and security groups work? 
  • How do I know requests are actually being distributed evenly by the ELB?
  • How should I stop my running containers? Do I stop it via the service level or the container level?
  • What happens to my containers if I shut down my EC2 instances?
  • Where are my logs located? If my app crashes, where do I look? 
  • How do I connect my app running in a container to another app running in a different container? Say, a database server for instance. 

No comments:

Post a Comment