Once the Cluster is created, we now go to create the Task definition, as we already discussed a Task definition is a blueprint describing which docker containers to run and represent your application. This task definition contains details about
1.What containers to run
2.From where the images need to download to start the container
3.Cpu and memory details
4.Volume details
5.Launch type
6.Networking mode backed up by VPC
7.Logging configuration of containers
8.Command to run as Entrypoint
9.Iam roles
The task definition contains 1 or more containers defined. So let's say we have a frontend web application and a Database with which the front end connects, it is logical to create both containers at one time. So for this use case, we can have both containers defined in one task definition. Similarly we will have 1 or more containers defined based on your application architecture. A task definition can contain 1 container also.
Creating a Task Definition :
In the first screen Choose the Launch type - Select which launch type you want your task definition to be compatible with based on where you want to launch your task.
In the second screen, Give a name to the Task Definition.
Choose the Task Role : This IAM role is very important that tasks use to make Api requests to authorized aws Services
Choose the Network mode : There are 4 options to choose, bridge, Host, Awsvpc and none. Ecs Will start your container using the Docker default networking mode which is bridge on Linux and NAT for windows. The awsvpc is only a different type of networking provided by aws in which a separate ENI card is provided to access the container. Other networking modes are provided by docker itself
Choose the Task execution IAM role : This role is required by tasks to pull container images and publish container logs to Amazon CloudWatch on your behalf
Provide the Task Size which is memory and Cpu requirements.
Add the Container definition : Click on the “Add Container” to configure your container details. When you click on this, there will be a popup shown to fill the container details. The most important for now are the Container name and Container image. We will not touch the other details for now. Other details that we can provide in Container definition include Health Check, Environment variables,Network settings, Container timeouts, storage, security , resource limits and labels.
At the end of the Second Page, we have the Volume where we can mount volumes from Host or Ebs to the Container path. For the demo , i have provided the following details,
Here are the few details that i provided for my Container definition along with the port details as below,
Port Mappings :
Save the Details and save the Task Definition.
By this we have creating the TaskDefinition to create our Task ( Container workloads). In the next article we will see how we can run the Task from this task definition.
No comments :
Post a Comment