Skip to content

Commit f017df8

Browse files
committed
Added ECS/Docker notes to CDA
1 parent a4026c3 commit f017df8

1 file changed

Lines changed: 87 additions & 1 deletion

File tree

CDA.md

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,4 +1619,90 @@ providing transient cache that can be used for multiple invocations
16191619
- Users can login through Public Social, OIDC, SAML & Cognito User Pools
16201620
- Users can be unauthenticated (guests)
16211621
- Users are mapped to IAM roles & policies, can leverage policy variables
1622-
- CUP + CIP = manage user / password + access AWS services
1622+
- CUP + CIP = manage user / password + access AWS services
1623+
1624+
----------------------------------------------
1625+
1626+
# ECS
1627+
1628+
## Docker
1629+
- Docker is a software development platform to deploy apps
1630+
- Apps are packaged in containers that can be run on any OS
1631+
- Apps run the same, regardless of where they’re run
1632+
- Any machine
1633+
- No compatibility issues
1634+
- Predictable behavior
1635+
- Less work
1636+
- Easier to maintain and deploy
1637+
- Works with any language, any OS, any technology
1638+
1639+
## Docker Containers Management
1640+
- To manage containers, we need a container management platform
1641+
- Three choices:
1642+
- ECS: Amazon’s own platform
1643+
- Fargate: Amazon’s own Serverless platform
1644+
- EKS: Amazon’s managed Kubernetes (open source)
1645+
1646+
## ECS Clusters
1647+
- ECS Clusters are logical grouping of EC2 instances
1648+
- EC2 instances run the ECS agent (Docker container)
1649+
- The ECS agents registers the instance to the ECS cluster
1650+
- The EC2 instances run a special AMI, made specifically for ECS
1651+
1652+
## ECS Task Definitions
1653+
- Tasks definitions are metadata in JSON form to tell ECS how to run a Docker Container
1654+
- It contains crucial information around:
1655+
- Image Name
1656+
- Port Binding for Container and Host
1657+
- Memory and CPU required
1658+
- Environment variables
1659+
- Networking information
1660+
- IAM Role
1661+
- Logging configuration (ex CloudWatch)
1662+
1663+
## ECR
1664+
- So far we’ve been using Docker images from Docker Hub (public)
1665+
- ECR is a private Docker image repository
1666+
- Access is controlled through IAM (permission errors => policy)
1667+
- AWS CLI v1 login command (may be asked at the exam)
1668+
- $(aws ecr get-login --no-include-email --region eu-west-1)
1669+
- AWS CLI v2 login command (newer, may also be asked at the exam - pipe)
1670+
- aws ecr get-login-password --region eu-west-1 | docker login --username AWS -- password-stdin 1234567890.dkr.ecr.eu-west-1.amazonaws.com
1671+
- Docker Push & Pull:
1672+
- docker push 1234567890.dkr.ecr.eu-west-1.amazonaws.com/demo:latest
1673+
- docker pull 1234567890.dkr.ecr.eu-west-1.amazonaws.com/demo:latest
1674+
1675+
## Fargate
1676+
- When launching an ECS Cluster, we have to create our EC2 instances
1677+
- If we need to scale, we need to add EC2 instances
1678+
- So we manage infrastructure…
1679+
- With Fargate, it’s all Serverless!
1680+
- We don’t provision EC2 instances
1681+
- We just create task definitions, and AWS will run our containers for us
1682+
- To scale, just increase the task number. Simple! No more EC2
1683+
1684+
## ECS Task Placement Process
1685+
- Task placement strategies are a best effort
1686+
- When Amazon ECS places tasks, it uses the following process to select container instances:
1687+
1. Identify the instances that satisfy the CPU, memory, and port requirements in the task definition.
1688+
2. Identify the instances that satisfy the task placement constraints.
1689+
3. Identify the instances that satisfy the task placement strategies.
1690+
4. Select the instances for task placement.
1691+
1692+
## ECS Task Placement Strategies
1693+
- **Binpack**
1694+
- Place tasks based on the least available amount of CPU or memory
1695+
- This minimizes the number of instances in use (cost savings)
1696+
- **Random**
1697+
- Place the task randomly
1698+
- **Spread**
1699+
- Place the task evenly based on the specified value
1700+
- Example: instanceId, attribute:ecs.availability-zone
1701+
1702+
## ECS – Service Auto Scaling
1703+
- CPU and RAM is tracked in CloudWatch at the ECS service level
1704+
- Target Tracking: target a specific average CloudWatch metric
1705+
- Step Scaling: scale based on CloudWatch alarms
1706+
- Scheduled Scaling: based on predictable changes
1707+
- ECS Service Scaling (task level) ≠ EC2 Auto Scaling (instance level)
1708+
- Fargate Auto Scaling is much easier to setup (because serverless)

0 commit comments

Comments
 (0)