Skip to content

Amazon ECS

It is container orchestration service. 💡 You are still responsible for maintaining the underlying EC2 instances.

ECS Components

  • Cluster: consists of services
  • Service: consists of identical tasks
    • managed by ECS service scheduler
    • scale out and scale in
    • availability Zone-aware
  • Task: consist of containers
    • You can run task without service:
      • managed by ECS task Scheduler
      • run once or at intervals
      • optimal for batch jobs

ECS Options:

  1. run your tasks and services on a serverless infrastructure that's managed by AWS Fargate 2023103015443030 AWS Fargate
  2. For more control over your infrastructure, you can run your tasks and services on a cluster of EC2 instances that you manage.
    • you need to install the Amazon ECS container agent on your EC2 instances.
    • 💡 an EC2 instance with the container agent installed is often called a container instance.
    • What you can do:
      • run and stop containers
      • get cluster state
      • scale in and out
      • assign permissions
      • schedule the placement of containers across your cluster
      • achieve availability requirements
      • other..
    • You need to create json file described a task. For example:
      {
      "family": "webserver",
      "containerDefinitions": [ {
      "name": "web",
      "image": "nginx",
      "memory": "100",
      "cpu": "99"
      } ],
      "requiresCompatibilities": [ "FARGATE" ],
      "networkMode": "awsvpc",
      "memory": "512",
      "cpu": "256"
      }
      

Task/Service placement

  1. cluster constraints
    1. CPU, memory and networking requirements
  2. custom constraints
    1. filter for location, instance type, AMI, or other attribute constraints
  3. task/service placement strategies.Best effort. You can use several strategies.
    1. random
    2. binpack
    3. spread
  4. task/service placement constraints. Binding.
    1. distinctInstance
    2. memberOf

ECR

  • fully managed cloud-based docker image registry
  • Scalable and HA
  • Secure
    • At rest encryption
    • IAM-based access controls
  • Fully integrated with ECS and docker CLI

References

  1. https://explore.skillbuilder.aws/learn/course/external/view/elearning/1851/aws-technical-essentials?da=sec&sec=prep Module 2
  2. Amazon ECS Primer course
  3. AWS website: Amazon Elastic Container Service (Amazon ECS)(opens in a new tab)
  4. External website: Github: Amazon ECS Agent(opens in a new tab)
  5. AWS developer guide: Amazon ECS Container Instances(opens in a new tab)
  6. External website: Coursera course: Building Containerized Applications on AWS(opens in a new tab)