3.1.2.7. Deploying Container-Based Applications (Amazon ECS, Amazon EKS)
3.1.2.7. Deploying Container-Based Applications (Amazon ECS, Amazon EKS)
Container deployment patterns differ significantly between ECS and EKS. The exam tests your ability to choose the right deployment strategy for each platform.
ECS deployment options:
- Rolling update (default): Replaces tasks in batches. Configure
minimumHealthyPercent(e.g., 50%) andmaximumPercent(e.g., 200%) to control rollout speed vs. availability. - Blue/Green (via CodeDeploy): Routes ALB traffic from old task set to new task set. Supports canary and linear traffic shifting. Instant rollback.
EKS deployment options:
- Rolling update (default K8s): Replaces pods in batches using
maxUnavailableandmaxSurgesettings in the Deployment spec. - Blue/Green (via Ingress): Use NGINX Ingress or AWS ALB Ingress Controller to shift traffic between two Deployments.
- Canary (weighted routing): Istio, or Amazon VPC Lattice listener rules with weighted target groups (through the AWS Gateway API Controller), route a percentage of traffic to the canary version.
ECR image management for deployments:
# Tag and push new image
docker build -t my-app:v2 .
docker tag my-app:v2 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-app:v2
docker push 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-app:v2
# Update ECS service to use new image
aws ecs update-service --cluster prod --service my-app \
--task-definition my-app:v2 --force-new-deployment
Exam Trap: ECS rolling updates can cause brief periods where both old and new versions serve traffic simultaneously. If your application can't handle two versions running concurrently (e.g., database schema changes), use Blue/Green deployment with CodeDeploy instead. Blue/Green ensures traffic shifts atomically from old to new.
ECS task placement (EC2 launch type): the placement strategies are binpack (fill instances by CPU or memory to use the fewest), spread (distribute evenly across an attribute such as attribute:ecs.availability-zone or instanceId) and random. Placement constraints (distinctInstance, memberOf expressions) filter which instances are eligible — they aren't strategies, and there is no priority or weighted strategy.