• hey@aysharshad.com
  • Trondheim, Norway.
AWS
Container Orchestration on AWS: ECS, EKS, Fargate, and ECR

Container Orchestration on AWS: ECS, EKS, Fargate, and ECR

As Tech World is progressing from Monolith architecture to Microservice-based Architecture it is important to the concepts of Container Orchestration. Hence this guide will introduce you to the containerization options provided by Amazon Web Services. 

In a Microservices-based Architecture, the whole application is broken down into small units. Each unit sticks to a specific section of the processing required by the application. In a microservice-based architecture, high cohesion and loose coupling are primary objectives. These tiny units are developed and contained in containers. 

Now a high-level concept simply states that 

  1. Each microservice takes an input, performs some processing function, and then releases the output either to be processed by another microprocessor or consumed by the customer themselves.
  2. Microservices are encapsulated in containers. These containers provide a virtual running environment to the code and they are scaled as per requirement.

Now in order to deploy these containers a host environment is required. Some companies host these containers on-premise data centers and some host them in the cloud, which depends on the deployment models they are using. Amazon Web Services provides a comprehensive set of services that can be used to host and manage micro-services based architecture on their virtual environment for container orchestration.

Note: If you are migrating your architecture to containers which was previously based on a monolith architecture. I Suggest your first step should be Re-architecting your application rather than just Refactoring or Re-platforming. Your code must be broken down into small units before it is hosted on containers.

Containers on AWS

Containers on EC2

If you are migrating your containerized application from an on-premise setup to Cloud the first and most primitive option that you can use is EC2 instances. Just as deployed on-premise your containerized application can be deployed on EC2 instances that have docker installed on them. 

Yet the question that arises at this point will be about container management. How are you going to manage these containers? Because the only difference that you are going to observe in this on-premise vs cloud based deployment is a virtually available server. For an application that is in its initial stages of development it might be the right option for you to deploy your containers on an EC2 instance. Or may be an application that is not live yet is merely in the development and testing stage. But for a full fledged application that requires scaling from time to time due to increased incoming traffic AWS managed Containerization services are a must. AWS provides following services that can help with Container Orchestration.

Why go for AWS Container Orchestration if you have EC2?

  1. Maintenance: Just like any resource containers are required to be managed. Continuous monitoring is required to tell the remaining resource capacity and current container health situation. Operations such as maintenance and troubleshooting are tedious tasks. Hence some of the load needs to be taken away from the end user if the hosted application has a greater scope or impact. 
  2. Scaling Infrastructure vs Scaling Containers: How can you tell how many instances are required to support the traffic hitting your application. Hence scaling EC2 instances becomes a difficult task. And Scaling the containers would be another job since you’ll have to manually create and dispose of containers every time you are required to do so.
  3. Cost: EC2 instances are not a cost effective option for containerized applications since you will be paying for the whole server even if you are not using it.

Container Orchestration Tool

A container orchestration tool helps you automate tedious operations of Container:

  1. Deployment
  2. Management
  3. Scaling

Of-course there are tools that you can use for container orchestration and some of them include Kubernetes, Docker Swarm, HashiCorp Nomad and an AWS managed service called Elastic Container Service (ECS).

AWS Elastic Container Service (ECS)

Elastic Container Services as a container orchestration tool automates the daily operations like Container lifecycle Management that decides when a container will be :

  1. Started
  2. Restarted
  3. Removed
  4. Reschedule
  5. Load Balanced

How to use ECS for Container Orchestration?

  1. Container Orchestration: Simply create an ECS Cluster which acts as a Control Center. ECS includes services that are required to manage the whole LifeCycle of your Containers.
  2. Hosting: In order to host these containers you still need an underlying infrastructure so for that AWS provides its EC2 instances.

 

How is this setup different from the previous one?

  1. ECS Agents will be installed on these EC2 instances to help you manage and monitor the containers.
  2. EC2 instances act as an underlying architecture and you are partially responsible for managing these instances. These instances have Docker Agent installed on them so that they can host your containers.

What hasn’t changed?

ECS Agent just takes control of the Docker side management and EC2 still remains your responsibility.

  1. You’ll have to make the EC2 instance part of the ECS cluster whenever a new instance is created.
  2. Also that you are responsible for scaling your EC2 instances so that you have enough resources to scale your Containers.
  3. You are still responsible for maintenance, upgradation and patching these EC2 instances.
Fargate managed ECS

So far ECS is handling your Container Orchestration and Infrastructure (EC2 instances) falls under your jurisdiction. Now, If you don’t want this headache of Hosting Infrastructure Management either and want to delegate this operation to AWS. AWS provides this amazing service called AWS Fargate which is based on the concept of serverless technology.

 

AWS Fargate is simply an engine that takes away the headache of provisioning and managing EC2 instances for your Containers. AWS Fargate is proved to be the fastest way of scaling your Containers. AWS Fargate acts similarly as Autoscaling does in case of EC2. Depending upon the requirement for containers to scale AWS Fargate scales hosting VMs as well.

 

How does it work?

You are simply responsible for providing the container to AWS Fargate engine which automatically scales after analyzing the resource requirement of your container.

 

Advantages?

  1. You pay as you go.
  2. You don’t have to manage infrastructure and scaling becomes easy.
  3. Maximum Utilization of resources you are paying for.

 

Other AWS Services that you can Integrate with ECS:

  1. Monitoring: Cloud Watch
  2. Elastic Load Balancer
  3. Virtual Private Cloud
  4. Web Application Firewall etc.
AWS Managed Elastic Kubernetes Service (EKS)

AWS managed Elastic Kubernetes Service allows you to use Kubernetes as your primary container Orchestration Tool. AWS manages Kubernetes Clusters for you just like ECS helps with managing Containers running on EC2 instances. If your organization is already using Kubernetes Clusters to scale and manage micro-services then EKS is your AWS hosted solution. A huge advantage of hosting your Kubernetes Clusters on AWS is that Master nodes become responsible for AWS.

How does it work?

  1. You create an EKS Cluster where the Master nodes are managed by AWS and you just manage Worker nodes. 
  2. Master Nodes already has Kubernetes Master Services installed on these nodes and automatically these master nodes are replicated across multiple availability zones for availability. 
  3. The Etcd storage used to store Cluster Configuration is also managed by AWS
  4. As for Worker nodes similar to ECS you are responsible for creating EC2 instance based Compute Fleet which will host your Kubernetes Clusters. Unlike ECS although EKS provides a partially managed approach to manage your EC2 instances. Instances are scaled up or down for you yet configuration remains your responsibility.

EKS vs ECS

The following comparison between both ECS and EKS shows when you should choose ECS and when EKS will be your best option. This comparison is not targeting pros vs cons.

  1. If you’re already using Kubernetes then EKS will be a familiar choice for you. In case you are just getting started with container based architecture ECS gives you a safe playground to start.
  2. An EKS based architecture allows you to keep your options open for migration which is not an option in case of ECS which is a proprietary solution of AWS. In case your EKS Cluster is using other AWS Services then it is still going to be difficult to migrate.
Fargate managed EKS

Similarly as Fargate managed ECS in this setup AWS completely manages your EKS Cluster for you.

AWS Elastic Container Registry (ECR)

ECR as the name indicates is a Container Registry Service that acts simply as a replacement of DockerHub for companies that are reluctant to share their docker images online. 

error: Content is protected. You are automatically reported to the Authorities!