Updated on 2024-07-16 GMT+08:00

Creating an Agent

Overview

To connect custom execution resources, you can install an agent on a host and register it with CodeArts.

Install only one agent on an agent host. If multiple agents are installed, some of them may go offline during task execution.

Prerequisites

  • Your account must be:
    • A tenant account.
    • Or an IAM user who has the agent pool owner, manager, or user permission.

    If you use the AK/SK of an IAM user to create an agent in the LA-Sao Paulo1 and LA-Santiago regions as an IAM Identity Center user (a user created in the IAM Identity Center), the IAM user must have at least the agent pool user permission.

  • The host where you want to install an agent must meet the following requirements:
    • Specifications: 4 vCPUs | 8 GB or above, disk space > 80 GB
    • Java 8 and Git are installed. If the agent pool type is LINUX_DOCKER, Docker must also be installed on the host.
      • If you use a Linux host, you can choose auto agent installation, or manually install the agent using the root account.
      • If you use a Windows or macOS host, manually install the agent on it.
    • The host can access the public network.

Creating an Agent

  1. After completing the operations described in Creating an Agent Pool, find the target agent pool in the agent pool list and click its name to display the Agents tab page.
  2. Click Create Agent. A dialog box is displayed.
  3. Configure parameters as required.

    1. Configure the network environment for the host.
      Table 1 Configuration 1

      Configuration Item

      Description

      Install a JDK automatically

      The host must have a Java 8 environment.

      After this function is enabled, the JDK is automatically installed in the /usr/local directory of the host.

      If this function is disabled, you need to manually install a JDK. Learn how to install Java 8.

      NOTE:

      This configuration item is displayed only when the agent pool type is LINUX or LINUX_DOCKER.

      Install Git automatically

      The host must have a Git environment.

      After this function is enabled, Git is automatically installed on the host.

      If this function is disabled, you need to manually install Git. Learn how to install Git.

      NOTE:

      This configuration item is displayed only when the agent pool type is LINUX or LINUX_DOCKER.

      Install Docker

      The host must have a Docker environment.

      After this function is enabled, the Docker is automatically installed in the /usr/bin directory of the host. After the installation is complete, the service is automatically registered and the Docker service is started.

      If this function is disabled, you need to manually install Docker. Learn how to install Docker.

      NOTE:

      This configuration item is displayed only when the agent pool type is LINUX or LINUX_DOCKER.

    2. Configure authentication information.
      Table 2 Configuration 2

      Configuration Item

      Description

      AK

      Access key ID.

      Obtain the value from the access key file downloaded by referring to Obtaining an AK/SK.

      SK

      Secret access key.

      Obtain the value from the access key file downloaded by referring to Obtaining an AK/SK.

      Agent Name

      Agents with the same name cannot be installed on the same host.

      Set this parameter based on the site requirements. To facilitate management, it is recommended that the name be clear and associated with the agent IP address, such as 10.10.10.10-agent-01.

      Agent Workspace

      The working directory where the agent runs on the host and the workspace where tasks are executed. Different agents of the same host cannot use the same agent workspace.

      For easy management, specify a data disk. Example:

      • Linux: /opt/cloud/agent01
      • Windows: C:/opt/cloud/agent01
      • macOS: /opt/cloud/agent01
    3. Generate a command.

      Set the parameters, agree to the statements, and click Generate Command. The command for installing the agent is automatically generated in the command box.

      Click Copy Command.

  4. Log in to the host and run the installation command copied in the previous step.

    • Linux host: Log in using the root account and then run the installation command.
    • Windows host: Log in as the administrator, open Git Bash, and then run the installation command.
    • macOS host: Log in using the root account and then run the installation command.
    If the following message is displayed, the installation is complete.
    Figure 1 Successful installation

  5. Return to the Agents tab page and close the dialog box.

    After 10 to 30 seconds, check the status of the installed agent instance on the Agents tab page. If the status is Idle, the installation is successful.

Follow-up Procedure

  • View the agent list.

    In the agent pool list, find the target agent pool and click its name to display the Agents tab page.

    The agent list displays the agent status, memory usage, and available hard disk space.

    An agent can be in any of the following states:

    Table 3 Agent states

    Agent Status

    Description

    Running

    The agent is performing tasks.

    Idle

    The agent is connected, and no tasks are running.

    Disabled

    The agent is connected, but is disabled to perform tasks.

    Offline

    The agent is disconnected. If you want it to go online, log in to the agent to re-register. Otherwise, you can delete the agent.

    Deleting

    The agent is being deleted.

  • Delete an agent.
    On the Agents page, click in the Operation column to delete a specified agent.

    Agents in the Running state cannot be deleted.

  • Start or stop the agent.

    On the Agents tab page, click in the Operation column to disable the agent. After the agent is disabled, the status changes to Disabled. Click to enable the agent again and the status changes to Idle.

  • View pool details.

    On the Agents tab page, click the Pool Details tab to view information including the owner, pool type, creation time, and description.