Updated on 2024-05-10 GMT+08:00

Adding and Editing a Host Cluster

The Basic Resources page displays host clusters and Kubernetes clusters (available soon), to be deployed. You can create basic resources and import them to an application for deployment. A target host is the final deployment object. CodeArts Deploy deploys your resources such as artifacts to the target host in the environment. A proxy server is a computer used to provide access channels for other target hosts without public IP addresses. In CodeArts Deploy, proxy hosts are usually referred to as ECSs bound to public IP addresses unless otherwise specified.

Prerequisites

Creating a Cluster

  1. Go to the Basic Resources page.

    In the target project, choose Settings > General > Basic Resources. The Host Cluster page is displayed.

  2. Create a host cluster.

    Click Create Host Cluster, enter the following information, and click Save.

    Parameter

    Mandatory

    Description

    Cluster Name

    Yes

    Enter a user-defined host cluster name.

    OS

    Yes

    Choose Linux or Windows as the operating system for the host.

    Host Connection Mode

    Yes

    If the target host cannot connect to the public network, select a host bound with an EIP as the proxy host to connect CodeArts to the target host.

    Execution Resource Pool

    Yes

    A resource pool is a collection of physical environments where commands are executed during software package deployment. You can use an official resource pool hosted by Huawei Cloud or host your own servers as a self-hosted resource pool on Huawei Cloud. For details about hosting your own servers, see Self-hosted Resource Pool.

    Description

    No

    Description of the host cluster.

    To use a Self-hosted resource pool, perform the following operations:

    • Configure a Self-hosted resource pool by referring to Self-hosted Resource Pool.
    • On the Basic Information tab page of the target application, select Self-hosted for Execution Host.

  3. (Optional) If you want to use proxy, create a proxy host and a target host.

    1. Create a proxy host.
      Click Add Proxy Host, enter the following information, and click OK.
      Table 1 Parameters of the proxy host (Linux)

      Parameter

      Mandatory

      Description

      Host Name

      Yes

      Enter a user-defined proxy host name.

      IP

      Yes

      Enter a public IP address bound to the proxy host.

      OS

      Yes

      The default value is the OS of the current host cluster and cannot be changed.

      Authorization

      Yes

      Select a password or key for authentication as required.

      • If you select Password, the Username and Password are displayed. Take ECS as an example. You need to enter the ECS username and password.
      • If you select Key, the Username and Key are displayed. For details about how to generate and obtain a key, see Obtaining the Linux key.

      SSH Port

      Yes

      Port 22 is recommended. You may customize the port number.

      Table 2 Parameters of the proxy host (Windows)

      Parameter

      Mandatory

      Description

      Host Name

      Yes

      Enter a user-defined proxy host name.

      IP

      Yes

      Enter a public IP address bound to the proxy host.

      OS

      Yes

      The default value is the OS of the current host cluster and cannot be changed.

      Authorization

      Yes

      Windows proxies support only password authentication. Take ECS as an example. You need to enter the ECS username and password.

      Winrm Port

      Yes

      Port 5986 is recommended. You may customize the port number.

    2. Add a target host.

      Click Add Target Host, enter the following information, and click OK.

      Table 3 Parameters of the target host (Linux)

      Parameter

      Mandatory

      Description

      Host Name

      Yes

      Enter a user-defined target host name.

      Proxy Host

      Yes

      Select the target proxy host as the network proxy of the target host that cannot connect to the public network.

      IP

      Yes

      Enter the private or public IP address of the target host.

      OS

      Yes

      The default value is the OS of the current host cluster and cannot be changed.

      Authorization

      Yes

      Select a password or key for authentication as required.

      • If you select Password, the Username and Password are displayed. Take ECS as an example. You need to enter the ECS username and password.
      • If you select Key, the Username and Key are displayed. For details about how to generate and obtain a key, see Obtaining the Linux key.

      SSH Port

      Yes

      Port 22 is recommended. You may customize the port number.

      Installation Check Box

      No

      If this is selected, you can install AOM ICAgent for metric monitoring, log query, and alarm functions. ICAgent applies only to Huawei Cloud Linux hosts. To configure an agency, see Creating and Using an Agency.

      Table 4 Parameters of the target host (Windows)

      Parameter

      Mandatory

      Description

      Host Name

      Yes

      Enter a user-defined target host name.

      Proxy Host

      Yes

      Select the target proxy host as the network proxy of the target host that cannot connect to the public network.

      IP

      Yes

      Enter the private or public IP address of the target host.

      OS

      Yes

      The default value is the OS of the current host cluster and cannot be changed.

      Authorization

      Yes

      Windows proxies support only password authentication. Take ECS as an example. You need to enter the ECS username and password.

      Proxy Forwarding Port

      Yes

      Set this port to the listening port number in the Windows proxy configuration. Port 54 is recommended. User-defined ports are supported.

  4. (Optional) If you do not want to use proxy, create a target host.

    Click Add Target Host, enter the following information, and click OK.

    Table 5 Parameters of the target host (Linux)

    Parameter

    Mandatory

    Description

    Host Name

    Yes

    Enter a user-defined target host name.

    IP

    Yes

    Enter the public IP address bound to the target host.

    OS

    Yes

    The default value is the OS of the current host cluster and cannot be changed.

    Authorization

    Yes

    Select a password or key for authentication as required.

    • If you select Password, the Username and Password are displayed. Take ECS as an example. You need to enter the ECS username and password.
    • If you select Key, the Username and Key are displayed. For details about how to generate and obtain a key, see Obtaining the Linux key.

    SSH Port

    Yes

    Port 22 is recommended. You may customize the port number.

    Table 6 Parameters of the target host (Windows)

    Parameter

    Mandatory

    Description

    Host Name

    Yes

    Enter a user-defined target host name.

    IP

    Yes

    Enter the public IP address bound to the target host.

    OS

    Yes

    The default value is the OS of the current host cluster and cannot be changed.

    Authorization

    Yes

    Windows proxies support only password authentication. Take ECS as an example. You need to enter the ECS username and password.

    Winrm Port

    Yes

    Port 5986 is recommended. You may customize the port number.

  5. (Optional) You can also click Import ECS to use the self-applied Huawei Cloud ECS as the target host or proxy host.
  6. Verify the host connectivity.

    After the host is created, the system automatically verifies the connectivity. If the connectivity verification fails, click Failed and rectify the fault based on the failure cause displayed in the dialog box or click View Solution.

Editing a cluster

  1. Go to the host cluster page.

    1. In the target project, choose Settings > General > Basic Resources. The Host Cluster page is displayed.
    2. Click the target host cluster to enter its details page.

  2. Edit a host cluster.

    • Adding a host: Click in the Operation column of a cluster to add a host to the cluster.
    • Editing a cluster: Click in the Operation column of a cluster to modify the cluster name, execution host, and description.
    • Deleting a cluster: Click in the Operation column of a cluster, click Delete, and click OK.

      If the target cluster contains resources, you need to clear all resources in the cluster and then delete the cluster.

    • Managing Permissions: Click in the Operation column of a cluster, click Manage Permissions, and configure operation permissions for each role. Enable or disable permissions as required.

    Default Permissions of a Host Cluster

    Role/Permission

    View

    Edit

    Delete

    Add Host

    Clone Host

    Manage Permissions

    Host cluster creator

    Yes (cannot be changed)

    Yes (cannot be changed)

    Yes (cannot be changed)

    Yes (cannot be changed)

    Yes (cannot be changed)

    Yes (cannot be changed)

    Project creator

    Yes (cannot be changed)

    Yes (cannot be changed)

    Yes (cannot be changed)

    Yes (cannot be changed)

    Yes (cannot be changed)

    Yes (cannot be changed)

    Project manager

    Yes

    Yes

    Yes

    Yes

    Yes

    Yes

    Product manager

    Yes

    No

    No

    No

    No

    No

    Test manager

    Yes

    No

    No

    No

    Yes

    No

    O&M manager

    Yes

    No

    No

    No

    Yes

    No

    System engineer

    Yes

    No

    No

    No

    No

    No

    Committer

    Yes

    No

    No

    No

    No

    No

    Developer

    Yes

    Yes

    Yes

    Yes

    Yes

    No

    Tester

    Yes

    No

    No

    No

    Yes

    No

    Participant

    Yes

    No

    No

    No

    Yes

    No

    Viewer

    Yes

    No

    No

    No

    Yes

    No

  3. Edit hosts in the host cluster.

    • Verifying host connectivity in batches: Select multiple hosts and click .
    • Cloning a host to another host cluster in batches: Select multiple hosts and choose More > Clone to Another Host Cluster. Then select the target host.

    • Host monitoring: Host monitoring allows you to view the resource usage, trends, and alarms of hosts in real time, so that you can quickly respond to host exceptions and ensure smooth host running.

      To access host monitoring, you need to select Subscribe to AOM for Free when creating a host. AOM provides metric monitoring, log query, and alarm functions. After AOM is selected, the ICAgent is automatically installed. Only Huawei Cloud Linux hosts are supported.

    • Editing a host: Click in the Operation column of a host to modify the configuration.
    • Enabling network connectivity verification: Click in the Operation column of a host.
    • Deleting a host: Click in the Operation column of a host, click Delete, and click OK.
      • If you want to delete a host from an application, select Disassociate and Delete to remove the host information from the environment. Otherwise, the host cannot be deleted.
      • A proxy host cannot be deleted directly. It is deleted only when its last target host is deleted from the environment.
    • Cloning a host to another host cluster: Click in the Operation column of a host, click Clone, and select the target host cluster.

Obtaining the Linux Key

  1. Check whether the key exists on the host.

    Log in to the host and run the following command to switch to user root:

    sudo su root

    Run the following command to view the key file:

    ls  ~/.ssh 
    • If a message is displayed indicating that the directory does not exist or the ~/.ssh directory does not contain the id_rsa file, go to Generate a key.
    • If the id_rsa file exists in the ~/.ssh directory, you can use the existing key file or go to Generate a key to generate a new key file.

  2. Generate a key.

    Perform the following steps:
    1. Generate a key.
      ssh-keygen -t rsa
    2. When the following information is displayed, press Enter.

    3. When the following information is displayed, press Enter. By default, no password is set. (Setting the password will fail the key verification of CodeArts Deploy.)

    4. When the following information is displayed, press Enter.

    5. If the following information is displayed, the key has been generated:

    6. Run the following command: to view the key file generated in the .ssh directory. The id_rsa and id_rsa.pub files store the generated private key and public key, respectively.
      ls  ~/.ssh 

  3. Check information about the key generated.

    Run the following command:
    cat ~/.ssh/id_rsa
    • If the key prefix is -----BEGIN RSA PRIVATE KEY-----, the key is correct. Copy the key and save it to the local PC. Enter the key when adding a host or proxy.
    • If the key prefix is -----BEGIN OPENSSH PRIVATE KEY-----, the key is incorrect. Run the following command to generate a new key:
      ssh-keygen -m PEM -t rsa

  4. Authorize the key.

    Run the following command to add the public key to the authorized_keys file of the host:

    cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
    • To perform operations on the authorized_keys file, you must have the permission to operate the id_rsa and id_rsa.pub files.
    • When the key is used for connectivity verification, the username must be the name of the user who operates the authorized_keys file.
    • Do not copy unnecessary spaces when manually copying the key. Otherwise, the connectivity verification may fail.