Help Admin Adding a monitor Bulk Deployment Methods for Docker Agent

Bulk Deployment Methods for Docker Agent

Docker can be monitored with the Site24x7 Linux monitoring agent, that is available in the Docker Hub (called the Docker agent) or from the Site24x7 web client. This can also be installed in multiple machines in one go using one of the following bulk deployment methods:

AWS ECS

This is done by two steps:

  1. Creating a task definition:
    There are two ways to create a task definition:
    1. Using Web UI
    2. Using CLI
  2. Running the instance of task definition:
    To do this, it is first essential to create an IAM role. After that, there are two ways to run the instance:
    1. Creating an instance with site24x7-agent by adding a startup script
    2. Creating an instance with site24x7-agent without adding a startup script

Creating a Task Definition:

Using Web UI:

  1. Log in to your AWS account.
  2. Click on Services > Elastic Container Service
  3. Click on Task Definitions > Create new Task Definition
  4. In the Create a Task Definition page, enter Task Definition Name as site24x7-agent-task
  5. Click on Add Volume (highlighted in green in the above screenshot) and add the following volumes:
    • Name: procfs and Source Path: /proc
    • Name: sysfs and Source Path: /sys
    • Name: dockerfs and Source Path: /var/run/docker.sock
  6. Now click on the Add Container button and enter the following details:
    1. Container name: site24x7-agent 
    2. Image: site24x7/docker-agent:latest
    3. Memory Limits (for both Hard and Soft Limit): 256
    4. Expand the Advanced container configuration, and under Storage and Logging Section > Mount Points 
      • Select Source Volume as dockerfs and enter Container Path as /var/run/docker.sock 
      • Select Source Volume as sysfs and enter Container Path as /host/sys
      • Select Source Volume as procfs and enter Container Path as /host/proc 
      • Check the Read only box for all the above three options.
    5. Under the Environment section, under Env Variables, specify the Key as KEY and Value as your Device Key 
    6. Click Add to add the container.
  7. Click Create to create a task definition 

Using CLI:

  1. Download site24x7-agent-task.json and add your Device Key in the file
  2. Execute the following command
    aws ecs register-task-definition --cli-input-json file://<above_downloaded_file_path>

Running the instance of Task Definition:

Prerequisite: Creating an IAM Role

  1. Log in to the AWS console and then click on Services > IAM
  2. In the left panel, click on Roles > Create Role button
  3. Under AWS Service, click on Elastic Container Service and then Select your use case as EC2 Role for Elastic Container Service. Click on Next: Permission button.
  4. Click on Next: Review and in the next page, enter the Role Name  site24x7-ecs-agent. Click on the Create Role button.
  5. Now click on the above created role and then click on Add Inline Policy 

  6. Paste the below policy in the JSON tab of Create Policy and then click on Review Policy button.

    {
         "Version": "2012-10-17",

         "Statement": [
    {
                 "Effect": "Allow",
                 "Action": [
                     "ecs:RegisterContainerInstance",
                     "ecs:DeregisterContainerInstance",
                     "ecs:DiscoverPollEndpoint",
                     "ecs:Submit*",
                     "ecs:Poll",
                     "ecs:StartTask",
                     "ecs:StartTelemetrySession"
    ],
                 "Resource": [
                     "*"
    ]
    }
    ]
    }

  7. Name the policy as site24x7-ecs-policy and click on Create Policy button. 

Creating an instance with site24x7-agent that has to be added to the ECS cluster by adding a startup script

  1. Log in to the AWS console and click on Services > EC2
  2. Click the Launch Instance button to create a new instance
  3. Click on Community AMIs, search for "ecs optimized" and Select the image as per your requirement
  4. Choose an Instance Type and click Next: Configure Instance Details button.
  5. In the IAM role section, select the above created IAM role or with the default ecsInstance IAM role. Then paste the below content in the User Data text box (Under Advanced Details)

    #!/bin/bash

    # Specify the cluster that the container instance should register into

    cluster=<cluster_name>

    # Write the cluster configuration variable to the ecs.config file
    # (add any other configuration variables here also)
    echo ECS_CLUSTER=$cluster >> /etc/ecs/ecs.config

    # Install the AWS CLI and the jq JSON parser

    yum install -y aws-cli jq

    instance_arn=$(curl -s http://localhost:51678/v1/metadata | jq -r '. | .ContainerInstanceArn' | awk -F/ '{print $NF}' )

    cluster=$(curl -s http://localhost:51678/v1/metadata | jq -r '. | .Cluster' | awk -F/ '{print $NF}' )
    region=$(curl -s http://localhost:51678/v1/metadata | jq -r '. | .ContainerInstanceArn' | awk -F: '{print $4}')

    # Specify the task definition to run at launch

    task_definition=<task_definition_which_has_been_created_in_the_above_step>

    # Run the AWS CLI start-task command to start your task on this container instance

    aws ecs start-task --cluster $cluster --task-definition $task_definition --container-instances $instance_arn --started-by $instance_arn --region $region

  6. Replace the cluster and task_definition variable value as required in the User Data. Then click on Review and Launch button.

Creating an instance with site24x7-agent without adding a startup script

  1. Log in to the AWS console and click on Services > Elastic Container Service
  2. In the left pane, select Clusters and click on the cluster where the agent is deployed
  3. Click on the Tasks tab and select Run New Task
  4. In the Run Task form, enter the number of nodes present in the cluster in the field Number of Tasks. Under Task Placement, select the Placement Template as One Task Per Host
  5. Click Run Task  

Kubernetes

  1. Download the file site24x7-agent.yaml and save it in your Kubernetes master. Replace <device_key> with the device key given in the Site24x7 web client. If you are using proxy, mention the name and port under env section in the YAML file.
    For example,
    - name : KEY
      value: <device key>
    - name: proxy
      value : proxy_host:proxy_port 
  2. Run the below command 
    kubectl create -f site24x7-agent.yaml
  3. This will add the file as a daemonset in the Kubernetes. 

Related Articles

Was this document helpful?
Thanks for taking the time to share your feedback. We’ll use your feedback to improve our online help resources.

Help Admin Adding a monitor Bulk Deployment Methods for Docker Agent