AWS Fargate and How to create task definition,cluster and service

Reading Time: 5 minutes

Introduction

Hello readers, I’ll be covering about the details of AWS Fargate which is a compute engine for Amazon Elastic container service but before it let’s take a look at topics that we’ll be discussing in this blog.Firstly we’ll discuss Fargate,need for Fargate,how it works,few key concepts that you must know when you are dealing with Fargate and finally we’ll see the demo how to create Task definition, Cluster and Service.

AWS Fargate

It is an Amazon Elastic Container Service (ECS) compute engine that enables you to run containers without having to having to provision, configure, and scale clusters of VMs. With Amazon Web Services Fargate, there is no longer a need to choose server kinds, decide whether to extend your clusters, or optimise cluster packing.

When you run your Amazon Elastic Container Service tasks and services with the Fargate launch type or a Fargate capacity provider, you package your application in containers, specify the OS, central processing unit and memory requirements, define networking and Identity and Access Management policies, and launch the application. Each Fargate task has its own isolation boundary and does not share the underlying kernel, central processing unit resources, memory resources, or elastic network interface with another task.

What Problems Does AWS Fargate Solve?

The key issue that Fargate addresses is the difficulty of managing infrastructure for container hosting.

Most of the other issues with deploying and managing containerized apps have already been addressed by modern container technology. Containers built automatically using continuous integration/continuous delivery (CI/CD) technologies. Container registries allow you to handle container images in a more efficient manner. Kubernetes allows you to coordinate container instances, load balance, and automate other orchestration operations.

One thing that standard container platforms don’t do.however, is set up the host infrastructure for you or scale that infrastructure up and down as your load fluctuates.

You can use Fargate to deploy containers without having to worry about the underlying infrastructure. Fargate executes your container images when you load them into either EKS or ECS. The infrastructure can automatically controlled for you.

Need of Fargate

Fargate is a convenient approach for most users to reduce the amount of effort required to operate containers in the Amazon cloud. However, the control over your host infrastructure is a significant trade-off. Use ECS or EKS in standard mode if you want complete control over how your infrastructure is provisioned and scaled. As an alternative, if you want some help managing infrastructure but don’t want to go as far as Fargate, consider autoscaling or managed node groups instead.

How does the AWS Farget work?

Simple steps to launch containers

  1. Build a container image-In this container image you built in such a way that it’s suitable for application and then you store this container image in a registery either you have docker hub or you can use elastic container registry and from this registery you can download the image whenever you want and run on the cluster.
  2. Choose container orchestration-It should be there Amazon ECS or Amazon EKS for kubernates, you have choosen a proper container orchestration service.you need to create a cluster so that you store all the containers and the resources that you have assigned to your application this is where you have to make a choice between choosing EC2 or fargate so we will be choosing fargate here.
  3. Now launch a container and Fargate runs your container and manages all the handling infrastructures and clusters for you.

Components of AWS fargate

1. Clusters: An Amazon Elastic Container Service cluster is a logical grouping of tasks or services. You can use clusters to isolate your application.

2. Task definitions: One or more containers that make up your application are described in a text file called a task definition. It’s in JSON format. You can use it to describe up to a maximum of 10 containers.

3. Tasks: Within a cluster, a task is the instantiation of a task description.The number of tasks to perform on your cluster may be specified once you establish a task description for your application within Amazon Elastic Container.

4. Services: You can use an Amazon Elastic Container Service services to run and maintain your desired number of tasks simultaneously in an Amazon Elastic Container Service cluster.

5. Container definition: Nothing but container image and container level settings(example: container image,port, registry, Environment variables to pass container etc)

How to creating Task definition, Cluster and Service

Prerequisites

Firstly Complete the following prerequisites:

  • create an AWS account.
  • Login to AWS account.

After above all, go to the search bar and search ECS and click on ECS.

Secondly,

Choose an image for your container to get started quickly and define the container image to use.

i am choosing nginx.

step 3: Configure task definition: first-run-task-definition

now click next button

step 4: Now define your service.

Click on next button.

step 5: Click on create button.

we can view the services

step 6: Now move on to the cluster then we can see the sevices tab and here we will see the nginx-service now move on to nginx-service which is got created so if you will see here in the task you can see, there is one task created,this task will have the nginx latest image running as a container.

At last copy the public ip and paste it in a new tab of your browser.

finally, we can see page is accessable.

Reference

https://blog.knoldus.com/aws-fargate-vs-kubernetes-which-container-orchestration-tool-do-you-need/

https://blog.knoldus.com/how-to-deploy-aws-elastic-container-service-using-fargate/

https://docs.aws.amazon.com/AmazonECS/latest/userguide/what-is-fargate.html

In Conclusion

so, In this blog we have seen AWS Fargate ,need of aws fargate,it’s component, how it’s work and How to create Task definition, Cluster and Service.

Leave a Reply