Amazon Elastic Container Service (Amazon ECS) is a comprehensive container orchestration service designed to simplify the deployment, administration, and scaling of applications packaged in containers.
By utilizing the Infrastructure Agent (Infra Agent), you can efficiently monitor containers and tasks within ECS, whether they are running on ECS EC2 instances or ECS Fargate, across cloud environments, on-premises setups, and hybrid infrastructures.
EC2 Setup
1. Create and Configure an ECS Task Definition for the Infra Agent
Let's start by crafting a Task Definition tailored specifically for the Infra Agent container.
{
"family": "atatus-agent-task",
"containerDefinitions": [
{
"name": "atatus-agent",
"image": "atatus/atatus-infra-agent:3.2.0",
"cpu": 10,
"memory": 512,
"essential": true,
"command": ["--", "-c", "/etc/atatus-infra-agent/", "-system.hostfs=/hostfs"],
"mountPoints": [
{
"containerPath": "/var/lib/docker/containers",
"sourceVolume": "docker_container",
"readOnly": true
},
{
"containerPath": "/var/run/docker.sock",
"sourceVolume": "docker_sock",
"readOnly": true
},
{
"containerPath": "/host/sys/fs/cgroup",
"sourceVolume": "cgroup",
"readOnly": true
},
{
"containerPath": "/host/proc",
"sourceVolume": "proc",
"readOnly": true
},
{
"containerPath": "/hostfs",
"sourceVolume": "hostfs",
"readOnly": true
}
],
"environment": [
{
"name": "ATATUS_LICENSE_KEY",
"value": "lic_infra_*******"
}
]
}
],
"volumes": [
{
"host": {
"sourcePath": "/var/lib/docker/containers"
},
"name": "docker_container"
},
{
"host": {
"sourcePath": "/var/run/docker.sock"
},
"name": "docker_sock"
},
{
"host": {
"sourcePath": "/proc/"
},
"name": "proc"
},
{
"host": {
"sourcePath": "/"
},
"name": "hostfs"
},
{
"host": {
"sourcePath": "/sys/fs/cgroup/"
},
"name": "cgroup"
}
],
"networkMode": "host",
"requiresCompatibilities": [
"EC2"
],
"pidMode": "host"
}
2. Register Your Task Definition in ECS
You have the option to register your Task Definition file using either the AWS CLI or the Amazon Web Console.
Option1: AWS CLI
Use the following command to register your Task Definition file in AWS. For more information on the Amazon ECS CLI, refer to their documentation.
aws ecs register-task-definition --cli-input-json file://<atatus-infra-agent.json>
Option2: AWS Web UI
1. Sign in to the AWS Management Console and go to the Elastic Container Service (ECS)
section.
2. In the left-hand menu, click on Task Definitions
.
3. Create a new Task Definition by selecting the appropriate option, typically under a Create new Task Definition
button.
4. Choose the JSON
tab to directly input or edit the Task Definition configuration.
5. Paste the configuration details from your Task Definition file into the JSON editor.
6. Save your Task Definition by clicking on the appropriate button or option in the console interface.
7. Finally, click on Create
to complete the registration of your Task Definition in AWS.
Following these steps ensures that your Task Definition file is successfully registered and ready for use within your ECS environment.
3. Deploy the Infra Agent as a Daemon Service
To configure the Infra Agent Task Definition as a Daemon Service, ensuring one instance runs per EC2 instance in your ECS cluster, follow these steps:
Access your AWS Management Console and go to the Elastic Container Service (ECS) section.
Select the ECS cluster where you intend to deploy the Infra Agent.
Create a new service within the selected cluster.
Configure the Environment section:
- Choose the Launch type as EC2.
Configure the Deployment Configuration section:
- Select
Service
as the Application type. - Specify the previously created Task Definition under the Family section.
- Provide a distinctive Service Name.
- Set the Service Type to DAEMON.
- Select
Complete the setup by creating the service.
This setup ensures that only one instance of the Infra Agent container runs on each EC2 instance within your ECS cluster.