Updated on 2024-11-21 GMT+08:00

Creating and Editing a Host Cluster

Creating a Host Cluster

  1. Go to the Basic Resources page.

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

    Choose CICD > Deploy. Click Basic Resources. The Host Clusters page is displayed by default.

  2. Create a host cluster.

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

    Parameter

    Mandatory

    Description

    Cluster Name

    Yes

    3 to 128 digits, letters, hyphens (-), underscores (_), and periods (.).

    OS

    Yes

    Linux or Windows.

    Host Connection Mode

    Yes

    • Direct connection: Select a host bound with an EIP as the target host to connect to CodeArts.
    • Proxy: Select a host bound with an EIP as the proxy host to connect to CodeArts.

    If the target host cannot connect to the public network, select the proxy mode.

    Execution Host

    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.

    Max. 500 characters.

    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.

    If you select Self-hosted resource pool, you can add an IPv6 address for the target host.

  3. (Optional) If Host Connection Mode is set to Proxy, you need to add a proxy host and a target host.

    1. Create a proxy host.
      Click Add Host, select Adding IP for Add Hosts by, enter the following information, and click OK. The proxy host is created.
      Table 1 Parameters of the proxy host (Linux)

      Parameter

      Mandatory

      Description

      Host Name

      Yes

      Enter a user-defined proxy host name.

      Enter 3 to 128 characters. Use digits, letters, hyphens (-), underscores (_), and periods (.).

      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.

      Enter 3 to 128 characters. Use digits, letters, hyphens (-), underscores (_), and periods (.).

      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 Host, select Adding IP for Add Hosts by, enter the following information, and click OK. The target host is created.

      Table 3 Parameters of the target host (Linux)

      Parameter

      Mandatory

      Description

      Host Name

      Yes

      Enter a user-defined target host name.

      Enter 3 to 128 characters. Use digits, letters, hyphens (-), underscores (_), and periods (.).

      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.

      Table 4 Parameters of the target host (Windows)

      Parameter

      Mandatory

      Description

      Host Name

      Yes

      Enter a user-defined target host name.

      Enter 3 to 128 characters. Use digits, letters, hyphens (-), underscores (_), and periods (.).

      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.

      IPv4 or IPv6 addresses can be added.

  4. (Optional) If Host Connection Mode is set to Direct Connection, you only need to add a target host.

    Click Add Host, select Adding IP for Add Hosts by, enter the following information, and click OK. The target host is created.

    Table 5 Parameters of the target host (Linux)

    Parameter

    Mandatory

    Description

    Host Name

    Yes

    Enter a user-defined target host name.

    Enter 3 to 128 characters. Use digits, letters, hyphens (-), underscores (_), and periods (.).

    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.

    Enter 3 to 128 characters. Use digits, letters, hyphens (-), underscores (_), and periods (.).

    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.

    IPv4 or IPv6 addresses can be added.

  5. (Optional) You can also select Importing ECS for Add Hosts by and add your Huawei Cloud ECS as the target host or proxy host.

    You should meet the following requirements to import purchased ECS:

    • ECS is running.
    • ECS and host cluster have the same OS.
    • Proxy host has a public IP (proxy mode) when using official resource pool.
    • Host is not the imported target host.

    In the proxy mode, you need to configure the proxy host before using the target 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.

Edit a Hosting Cluster

  1. Go to the host cluster page.

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

      Choose CICD > Deploy. Click Basic Resources. The Host Clusters page is displayed by default.

    2. Click the target host cluster to enter its details page.

  2. Edit the 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. For details about the default permissions, see Table 6 Host cluster permission matrix.

  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.

    • 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. A proxy host is deleted, 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.