Container Services — AWS Solution Architect Associate Series — Part 9

Ata Erdemir
4 min readApr 13, 2024

Container services provide efficiency and portability for users. This enables you to execute operations in your applications more efficiently and have a more flexible architecture due to portability. Containers inherently encapsulate everything an application needs within a single package. It’s expected to operate consistently across different environments. AWS offers two container services in-house. The first one is Amazon Elastic Container Service (ECS). The second one is Amazon Elastic Kubernetes Service (EKS). In addition to the above, you can use Fargate for an alternative container space. AWS Fargate is a serverless compute engine.

Difference between VMs and Containers

As can be understood from the diagram above, there are two distinct differences between VMs and Containers. Firstly, while a guest operating system exists on VMs, it does not exist on the container side. This does not mean that there is no operating system on containers. In other words, Containers share the same operating system and kernel with the host on which they are deployed. Secondly, VMs, as the name suggests, operate with virtualization, while Containers operate directly through containerization.

Orchestrating Containers

In AWS, containers can run on EC2 instances. For example, you may have a large instance and run several containers on it. Running an instance can be simple from a management perspective but lacks high availability and scalability. Many companies and organizations run many containers on many EC2 instances across multiple Availability Zones.

If you’re trying to manage your computing at a large scale, you should consider the following:

- How you’ll place your containers on your instances
- What will happen if your container fails
- What will happen if your instance fails
- How you’ll monitor the deployments of your containers

This coordination is managed by a container orchestration service. AWS offers two container orchestration services: Amazon Elastic Container Service (Amazon ECS) and Amazon Elastic Kubernetes Service (Amazon EKS).

Managing containers with Amazon ECS

Amazon ECS is a full-fledged container orchestration service that helps you create new containers from start to finish. With Amazon ECS, your containers are defined within a task definition, and you use this definition to run an individual task or a task within a service. You have the option to run your tasks and services on a serverless infrastructure managed by another AWS service called AWS Fargate. Additionally, if you prefer more control over your infrastructure, you can run your tasks and services in a cluster of EC2 instances that you manage.

Cluster → Service → Task → Compute
If you prefer to have more control by running and managing your tasks in a cluster of Amazon EC2 instances, you will need to install the Amazon ECS container agent on your EC2 instances. Keep in mind that an EC2 instance with the container agent installed is often referred to as a container instance. This container agent is responsible for communicating with the Amazon ECS service regarding cluster management details and is open source. You can run the agent on both Linux and Windows AMIs.

When Amazon ECS container instances are running, you can perform a variety of tasks including, but not limited to:
- Launching and stopping containers
- Obtaining cluster status
- Scaling in and out
- Planning container placement across the cluster
- Assigning permissions
- Meeting availability requirements

To prepare your application to run on Amazon ECS, you create a task definition. A task definition is a text file in JSON format that defines one or more containers. It resembles a blueprint that outlines the resources needed to run a container, such as CPU, memory, ports, images, storage, and network information.

Here’s a sample task definition you can use for your enterprise directory application:

{
"family": "webserver",
"containerDefinitions": [ {
"name": "web",
"image": "nginx",
"memory": "100",
"cpu": "99"
} ],
"requiresCompatibilities": [ "FARGATE" ],
"networkMode": "awsvpc",
"memory": "512",
"cpu": "256"
}

Using Kubernetes with Amazon EKS

Kubernetes is a portable, scalable, open-source platform used to manage container-based workloads and services. By bringing together software development and operations in terms of design, Kubernetes has rapidly created a growing ecosystem that has become very popular and well-established in the market.

If you’re already using Kubernetes, you can use Amazon EKS to manage workloads in the AWS Cloud. Amazon EKS is a managed service that allows you to run Kubernetes on AWS without the need to set up, operate, and maintain your own Kubernetes control plane or nodes. Conceptually, Amazon EKS is similar to Amazon ECS but has the following differences:

- In Amazon ECS, the machine running the containers is an EC2 instance configured with an ECS agent to run and manage your containers, referred to as a container instance. In Amazon EKS, the machine running the containers is referred to as a worker node or Kubernetes node.
- An ECS container is referred to as a task, while an EKS container is referred to as a pod.
- Amazon ECS runs on AWS’s native technology, whereas Amazon EKS runs on Kubernetes.

If you have containers running on Kubernetes and need an advanced orchestration solution that offers simplicity, high availability, and fine-grained control over your infrastructure, Amazon EKS could be the right tool for you.

Hope you enjoyed when you read… :)

--

--