Containers
Containers
• Amazon ECS is a highly scalable, fast, container management service that allows you to
run, stop, and manage Docker containers on a cluster.
• Containers are defined in a Task Definition, which is used to run individual tasks or
multiple tasks within a service.
• ECS allows you to run tasks and services on either Fargate (serverless infrastructure) or
EC2 instances.
ECS Components
1. Containers:
o ECS uses Docker containers, which are packaged units of software including code,
runtime, libraries, and system tools.
o Images are stored in Container Registries like Amazon ECR (Elastic Container
Registry).
o A Task Definition is a JSON file describing one or more containers (up to 10) that
form an application.
3. Clusters:
• ECS on EC2:
o You are responsible for provisioning and scaling the EC2 instances.
• Fargate:
o Each task gets its own Elastic Network Interface (ENI) and IP address.
o Ideal for applications that require auto-scaling without managing EC2 instances.
o Manage and scale batch processing tasks (e.g., pulling logs from RDS to S3).
3. Microservices:
ECS Features
• Task Scheduler:
o Schedules tasks across the cluster based on resource needs and availability.
• Container Agent:
o Runs on each container instance, reporting back to ECS on resource utilization and
task status.
• VPC Integration:
o ECS clusters run within an Amazon VPC, allowing for advanced networking and
security configurations.
• Fargate Tasks:
o Each Fargate task can have its own ENI and IP address, enabling multiple
applications to run on the same port number without conflict.
• Fargate vs. ECS on EC2: Understand the differences in infrastructure management and
when to use each.
• Task Definitions: Know how to define and manage them, and their role in deploying
containers.
• IAM Roles: Understand how they apply to ECS tasks and how they secure containerized
applications.
Which service allows you to run containers without managing the underlying infrastructure?
• A) Amazon EC2
• B) AWS Fargate
• C) Amazon S3
• D) AWS Lambda
• B) Amazon S3
• C) AWS Lambda
• D) Amazon RDS
Which ECS launch type requires you to manage the EC2 instances in your cluster?
• A) ECS on EC2
• B) Fargate
• C) Lambda
• D) AWS Batch
What is a key benefit of using AWS Fargate over ECS on EC2?
Which feature allows multiple ECS tasks to run on the same port without conflict when
using Fargate?
• D) Security Groups
What is the primary difference between ECS tasks and ECS services?
• B) Tasks are individual executions of a Task Definition, while services maintain the
desired number of task instances.
• C) Tasks are for short-running processes, and services are for long-running processes.
• A) When you need more control over the underlying EC2 instances
• ECS Cluster is a logical grouping of tasks or services, and it manages the EC2 instances
where containers are run.
Launch Types
o Each EC2 instance runs the ECS agent, which registers the instance with the ECS
cluster.
o Containers (ECS tasks) are placed on EC2 instances based on availability and
resources.
o AWS manages the infrastructure, and you do not need to provision EC2 instances.
o It is a serverless option where AWS runs containers based on the CPU and RAM
requirements you specify.
o Easier to manage but with less control over the underlying infrastructure.
o Exam Note: Fargate is often recommended due to its simplicity and ease of use.
o Option to switch between old and new interfaces is available on the ECS homepage.
2. Create a Cluster:
▪ Monitoring and tagging options are available but can be left at default
settings.
4. Cluster Deployment:
5. Cluster Details:
o Capacity Providers:
o View the Auto Scaling Group in the ECS cluster for scaling settings and capacities.
What is the main difference between the EC2 and Fargate launch types in Amazon ECS?
• C) Both EC2 and Fargate require manual provisioning and management of instances.
When creating an ECS cluster with the EC2 launch type, which of the following must you
configure?
• B) ECS Agent
What is the role of the ECS agent in an EC2 launch type cluster?
Which AWS service is used to automate the creation of resources when an ECS cluster is
created?
• A) AWS Lambda
• B) AWS CloudFormation
• C) AWS Auto Scaling
In an ECS cluster using the EC2 launch type, what happens when the load on instances
increases beyond the desired capacity?
• B) The ECS cluster creates additional EC2 instances using the ASG.
• Answer: B) The ECS cluster creates additional EC2 instances using the ASG.
What is the default launch type selected when creating a new ECS cluster using the ECS
console?
• A) EC2
• B) Fargate
• C) EC2 Spot
• D) Lambda
• Answer: B) Fargate
Which of the following is a benefit of using the Fargate launch type in ECS?
After creating an ECS cluster, which AWS service should you check to verify the creation of
underlying infrastructure components like EC2 instances?
• A) Amazon S3
• B) AWS Lambda
• D) AWS IAM
• Task Placement Policies are strategies that ECS uses to determine the best EC2 instance
to place a new task or which task to terminate when scaling in.
• Task Placement Constraints are rules that ensure tasks are placed on EC2 instances that
meet specific conditions.
1. Binpack Strategy:
o Places tasks on instances with the least available amount of CPU or memory.
o Optimizes resource utilization and minimizes the number of EC2 instances in use,
leading to cost savings.
2. Random Strategy:
o Simple and straightforward, but not necessarily optimized for resource usage.
3. Spread Strategy:
o Example: If tasks are spread based on availability zones, they will be distributed
evenly across all zones to ensure redundancy and high availability.
Combining Strategies:
• ECS allows the combination of multiple placement strategies. For instance, you can spread
tasks across availability zones and then use a binpack strategy to optimize resource
utilization within each zone.
1. Distinct Instance:
2. Member Of:
o Allows tasks to be placed on instances that satisfy a specific expression defined in
the cluster query language. This is an advanced option that provides granular
control over task placement.
Implementation in ECS:
• When creating an ECS service, you can select a task placement strategy. The default
strategy can be changed based on your requirements.
• ECS will create necessary infrastructure, such as load balancers and auto-scaling groups,
as part of the service creation process.
• Task placement is crucial in ensuring that your ECS tasks are efficiently and reliably placed
across your EC2 instances, considering both performance and cost optimization.
Practical Example:
• In a lab scenario, an ECS service is created, and a task is launched using the selected
placement strategy. The process includes creating a cluster, defining a task, and configuring
a load balancer and security groups to access the container.
Summary:
• Task placement strategies and constraints in Amazon ECS allow for efficient and optimized
deployment of tasks across EC2 instances, ensuring high availability, cost-effectiveness,
and adherence to specific requirements.
What is the purpose of the Binpack task placement strategy in Amazon ECS?
• B) To minimize the number of EC2 instances in use by placing tasks on instances with
the least available resources
Which task placement strategy would you use to ensure tasks are evenly distributed across
availability zones?
• A) Binpack
• B) Random
• C) Spread
• D) Distinct Instance
What does the "Distinct Instance" task placement constraint in ECS ensure?
Which ECS launch type does the task placement policy and strategy apply to?
• A) EC2
• B) Fargate
• C) Lambda
• D) EKS
Which task placement strategy should be selected if you want to prioritize cost savings by
using the fewest possible EC2 instances?
• A) Binpack
• B) Spread
• C) Random
• D) Member Of
What is the function of the "Member Of" task placement constraint in ECS?
Which strategy should be used to ensure that ECS tasks are placed on instances with the
least available CPU or memory resources?
• A) Binpack
• B) Random
• C) Spread
• D) Distinct Instance
When using the Spread strategy, which of the following values can be specified to determine
how tasks are spread?
• A) CPU usage
• B) Availability Zone
• C) Memory allocation
• A) Tasks are placed on the instance with the most available resources
• B) Tasks are placed without any specific logic across available instances
• D) Tasks are placed based on specific constraints defined in the cluster query language
Which ECS task placement strategy would be most appropriate for maximizing high
availability across multiple availability zones?
• A) Binpack
• B) Random
• C) Spread
• D) Member Of
• Amazon EKS is a managed service that simplifies the process of running Kubernetes on
AWS without the need to install, operate, and maintain your own Kubernetes control plane.
o Amazon EKS manages the control plane, including master nodes, ETCD (a
distributed key-value store), and control plane components.
o Ensures high availability and scalability without requiring users to manage these
components.
3. Node Groups:
o EKS allows for the creation and management of groups of Amazon EC2 instances,
known as Node Groups, to serve as worker nodes.
5. Security:
o Monitoring and logging integration with AWS CloudWatch and AWS CloudTrail.
6. Load Balancing:
o EKS integrates with Elastic Load Balancers (ELB) to manage traffic to applications
and services.
7. Auto-scaling:
8. Fargate Integration:
Use Cases:
o Efficiently run distributed training jobs using EC2 GPU instances and deploy training
and inference using Kubeflow.
3. Web Applications:
o Build applications that can automatically scale and run across multiple availability
zones with high availability.
Key Components:
1. Nodes:
o Master Nodes: Managed by EKS, responsible for the Kubernetes control plane.
o Worker Nodes: EC2 instances in Node Groups that run container workloads.
2. Node Groups:
o Groups of containers that share networking, storage, IP addresses, and port spaces.
4. Control Plane:
o The central management and control hub for the EKS cluster, including master
nodes and ETCD database.
5. API Servers:
o Manages API interactions, including those with kubectl and REST API.
6. Controller Manager:
o Manages VMs, storage, databases, and other resources associated with the
Kubernetes cluster.
7. Scheduler:
o Determines when and where workloads should run, integrating with the Controller
Manager and API Servers.
Deployment Options:
1. On AWS Cloud:
2. AWS Outposts:
o Run EKS on-premises using AWS Outposts, extending AWS infrastructure services
to customer data centers.
3. EKS Anywhere:
Pricing:
• EC2 Instances: Pay for resources like EC2 instances, EBS volumes, etc.
• EKS on AWS Outposts: Same pricing as in the cloud, $0.10 per hour per cluster.
Conclusion:
• Amazon EKS simplifies the management of containerized applications, reduces operational
overhead, and leverages Kubernetes for orchestrating containers in a scalable and highly
available manner.
Which service does Amazon EKS integrate with to provide a managed container registry for
storing Docker images?
• A) Amazon S3
• B) Amazon ECR
• C) AWS Lambda
• D) Amazon RDS
Which feature of Amazon EKS allows you to automatically scale the worker nodes based on
resource utilization?
• A) Auto-scaling Groups
• C) Node Groups
• D) AWS Fargate
Which of the following AWS services is used by Amazon EKS to monitor and log cluster
activity?
• A) AWS IAM
• B) AWS CloudWatch
• C) Amazon S3
• D) AWS Lambda
Which of the following is a key component of the Kubernetes control plane managed by
Amazon EKS?
• B) ETCD
• C) Amazon RDS
• D) AWS Lambda
What AWS service can be integrated with Amazon EKS to provide a serverless compute
environment for containers?
• A) Amazon EC2
• B) AWS Fargate
• C) Amazon S3
• D) AWS Lambda
Which Kubernetes feature is responsible for grouping containers that share networking and
storage resources in Amazon EKS?
• A) Node Group
• B) Pods
• C) Control Plane
• D) Load Balancer
Which Amazon EKS deployment option allows you to run Kubernetes clusters on your on-
premises infrastructure?
• A) EKS CloudFormation
• B) EKS Fargate
• C) AWS Outposts
• D) AWS Lambda
Overview of AWS ECR:
• AWS Elastic Container Registry (ECR) is a secure, scalable, and managed container image
registry service in AWS.
• It is similar to Docker Hub but is AWS-managed, allowing you to store, manage, and deploy
Docker container images.
• It integrates with AWS services like ECS, EKS, Lambda, and the Docker CLI.
1. Registry:
o Requires an authorization token for client access, ensuring that the client must
authenticate as an AWS user before pushing or pulling images.
2. Repositories:
o Stores Docker images, Open Container Initiative (OCI) images, and OCI-compatible
artifacts.
o Images in the repository can be used by local development environments, ECS task
definitions, and EKS pod specifications.
3. Authorization Workflow:
o An EC2 instance or other service assumes an IAM role that grants access to issue a
GetAuthorizationToken.
o This token is used to authenticate and retrieve the image from ECR.
ECR Features:
1. Lifecycle Policies:
o Manage the lifecycle of images within a repository by defining rules that clean up
unused images.
▪ Since image pushed: Time-based expiry after the image was pushed.
▪ Image count more than: Expire if the number of images exceeds a certain
count.
2. Image Scanning:
o Identifies software vulnerabilities in container images.
o Can be set to automatically scan on push, or manually after the image is stored in
the repository.
4. Encryption:
o Enhanced security is possible by using AWS Key Management Service (KMS) for
encrypting repository images.
Which AWS services can directly integrate with ECR for pulling container images?
• A) Expire
• B) Delete
• C) Archive
• D) Replicate
What is required for a client to push and pull images from an ECR repository?
• A) API Gateway
• B) Authorization Token
• C) SSL Certificate
• D) Security Group
Which of the following encryption options is available for images stored in ECR?
What does the ECR authorization workflow involve for an EC2 instance?
• B) Assuming an IAM role, getting an authorization token, and pulling the image