Published : 6. November 2020. |- Changed: 6. November 2020 | 0 results
Step-by-step instructions for creating job definitions in Amazon ECS and executing jobs in the Amazon ECS cluster
All you need to know about tasks in the Amazon ECS
In this article we guide you in defining ECS tasks and executing them on an ECS cluster. Let’s start with the basics of the ECS tasks.
What is the function of ECS?
The task of the ECS is to install the dockworkers in the ECS or Fargate instances. Tasks are defined using task definitions. Each task consists of a number of parameters such as the docker image to be used, the processor, memory limits, network mode, etc. When a job is executed in an ECS cluster, it reads the job definitions and thus rotates the dock containers.
How do I configure the Amazon ECS job definition?
- Connect to the Amazon ECS console.
- Click on Task definitions in the left navigation panel.
- On the Task Definitions page, click on a new task definition.
The definition of the tasks starts with determining the type of start. Select the startup type and press the Next Step button.
ECS Types of tasks to be launched
The hot water supply offers 2 types of starters –
- Tasks are initiated at the infrared level under the control of the AWS. (no server)
- The tasks are invoiced on the basis of the resources used and the duration of use.
- The TPs shall be performed on ECS bodies registered in the ECS cluster.
- No separate accounts. You pay the copies of the ECS according to the usual EC2 invoices.
For this exercise I will use the ECS startup type because I have an ECS cluster with 2 registered ECS instances.
When you click the Next Step button, the Task Definition and Container screen will appear. There are a lot of things that need to be defined on this screen. Let’s take it one at a time.
- Name of the job description : For identification purposes.
- The target role: If containers are used to access certain AWS services, you can specify here the IAM role the containers will use to access AWS services.
- Network Mode : There are four modes available –
- Bridging mode
- The bridge: Progress between host and container over the bridge (software at kernel level)
- Leader: The container network is displayed directly on the host network.
- awsvpc: The ENI (and thus the SG) is assigned to each container. Therefore, the network of each container can behave like ENI EC2.
- No, no, no, no, no, no, no, no, no, no, no, no: No container networks. Containers are spun with the assigned loopback IP address.
The role of the AIM in carrying out the tasks : Required to extract images from the containers and send the container logs to Cloudwatch.
The scope of the task: Assign resources to a task. Limit the resources consumed by the task container. Must be set correctly when using the start type FARGATE. For the start type EC2, it should be calculated on the basis of the resources of the ECS bodies available for the task. When I ran a small Apache container on EC2, I left it empty.
Container definitions : In this chapter you can define all parameters related to containers. Click the Add container button and the Container Definition screen will appear.
Among the definitions of containers we have 2 sections.
- Advanced configuration: will be covered in a separate article as it is a long list of parameters.
In the standard configuration you define –
- The name of the container: For identification purposes.
- A picture: Container Image. Deposit/Image : Hey, guys. If you want to use a Dockerhub image, just specify image:tag. To do this, you must have access to the Internet on the ECS instances to retrieve images, either via NAT or via the Internet gateway.
- Authentication in a private safe: If you use a private container repo as ECR, use this option.
- The limits of memory: The memory is reserved or authorized for containers at the time of execution.
- Tough break: Maximum allowed memory for containers.
- Lower limit : The memory is reserved for the container.
- Port plans : Assignment of the receiving port to the container port. It is always recommended to use the dynamic display of the host ports and set the host port to zero.
Click on the Add button to add this image to the task definition.
Additional job descriptions
- Elastic closure : Combines cost-effective GPU acceleration with tasks. Conclusion is a prediction process using a trained model. It requires computing power. If your container is used for this kind of thing, it makes sense to use flexible intelligence, which can save you up to 75% in costs.
- Restriction: Helps you make the decision to place the containers on the ECS copies Not applicable for the type of FARGATE departure. Specify the conditions for filtering and selecting water heaters. Once the restriction has been applied and the distribution authorities of the task have been selected, a different distribution strategy is applied (explained in the Tasks section of the Getting Started section below), and finally, the tasks of the last authority are carried out.
- The integration of services : With this AWS function you can easily manage your micro-services. This makes it possible to configure the proxy for communication between the micro-services for better visibility and the AP for the services.
- Proxy Configuration : Must be set automatically after selecting App Mesh and filling in the required data in this section.
- Integration of the protocol router : Allows container logs to be forwarded to other AWS or APN services for storage and analysis. It processes the container in question on the basis of the photograph supplied by AWS.
- Volumes: Volumes to be installed in containers. Supports 3 types
- Assembly: Adds a file or folder to a host in a container. More information.
- Dockworker: Controlled by the docker, it creates /var/lib/docker/volumes on the container where the volume data is stored. The drivers can be selected from local or external manufacturers. Can be saved at the end of the task if it is declared general.
- EFS: Integrate EFS volumes in containers!
- The buzzwords: For identification.
Click on the Create button to create a task definition.
Definition of the created task !
A job description must be drawn up, which is presented as follows: 1. The task definition can be edited with the Create New Revision button and is modified as follows: 2 etc.
How do I perform the Amazon ECS task?
On the same page or on the task definition page, select the newly created task definition and click the Actions button.
Start of ECS position
The Run Task window should appear, where you can provide detailed information on how to perform the tasks.
Start the task screen!
- Type of launch : Farghat or EC2
- Task description : Select the revision you want to use.
- A cluster: For which cluster task
- Number of tasks : How many containers do you have to run? This calculation refers to HA, FT or power.
- The target group: Purpose of identification.
- Mail order and security teams : Only available if the network mode awsvpc is specified in the job description Defines the network details at ENI level for containers.
- Task : Supports 5 models –
- AZ Balanced distribution
- Place the containers so that they are evenly distributed in the AZ.
- Use the available hot water appliances in each AZ
- AZ Balanced BinPack
- Put the containers in and fill one host at a time.
- Do not start with another host if the current host capacity is not full. Allows you to control unused hosts.
- The balance by the AZ. So start with one host in each AZ and keep filling it, and then move on to the next host in that AZ.
- Same as above, except for AZ’s balance sheet.
- One task per host
- Strictly speaking, a task for any media.
- If there are no free hosts, the task will fail.
- Make sure you have enough hosts to perform the tasks.
- Custom made
- User defined by a combination of Spread, BinPack or Random.
- Specify the order in which it is to be assessed.
- AZ Balanced distribution
Introduction of additional options Allocation
Additional options allow you to override the AIM roles defined in the job description.
The role of the task and the role of task execution, the two roles of the AIM can be redefined by the new role in this chapter.
ECS Task labels
Finally, select the settings you want to make. Add the ECS tags that are managed as cluster name and service name ECS tag tasks, which is fairly easy to identify later on.
Click on the Execute Task button.
Performance of tasks in an ECS cluster
The task begins, and in a few minutes you should see it in RUNNING state. In the screenshot above, the list EC2 Delayed tasks 2 EC2 shows how I captured the screen by just updating the Tasks tab. I didn’t update the entire cluster page.
The task is now in a RUNNING state, which means that the containers are deposited at the ECS authorities and port 80 of the container connected to the host port.
Click on a task ID number and you should see the details of the task as shown below –
Search for host port
Detailed information about the containers allows you to reach the main port. In this case the host port 32768 is limited to port 80 of the container. To check the functionality of the Apache container, check the external link.
Since this cluster works with ECS instances located on a private subnet, we need to use the bastion host to open this external connection. Since these are private bodies, you can also see that the external link is a private IP address and not a public address.
I disabled the external link to the Bastion host, and it worked!
[email protected] ~]$ curl http://10.0.0.118:32768/.
If this does not work, make sure the security groups allow sufficient traffic between the hosts.
This completes the establishment and introduction of the lessons on the tasks of the ECS. ECS services are used to manage ECS tasks. We will address this topic in a future article.
terraform ecs scheduled task,aws ecs task vs service,running tasks count,aws create a scheduled task,task lifecycle ecs,ecs task allocation,fargate command not found,fargate existing vpc,ecs run-task cli,ecs fargate launch type,runecsfargatetask cdk,what is an ecs service,aws ecs tutorial,security group for ecs container,ecs vs ec2,ecs vs kubernetes,ecs vpc aws,ecs aws,install fargate cli,run fargate task from lambda,aws fargate task definition,aws cli update task definition,aws fargate cloudformation example,boto3 ecs example,getting started ecs aws,ecs start guide,aws ecs learning,aws quick start ecs,aws ecs vs ec2,task definition example,aws ecs design,using fargate launch type incurs charges,ecs frontend,ecs service json,aws container-based architecture,add ec2 instance to ecs cluster,what is ecs container agent,ecs agent on prem,aws fargate ecs agent,ecs windows ami,aws ecs instance types,ecs run task boto3,start task ecs cli,ecs start_task,aws ecs invalid namespace for group,terraform ecs run task,ecs task definition command,ecs profile name,ecs config file,ecs cli up options,ecs-cli up role,ecs-cli –aws-profile,ecs cli iam role,aws ecs run-task fargate,aws ecs run-task example,aws ecs run-task network-configuration,aws ecs run-task fargate cli,ecs task definition,aws ecs run one-off task,aws fargate