Updated on 2025-03-13 GMT+08:00

Preparing an Environment

This section uses a Linux host as an example to describe how to set up a function CI/CD environment using KooCLI and DevCloud.

ECS

This server functions as a DevCloud task deployment host to deploy and update FunctionGraph functions.

  • Specifications: 1 vCPU | 1 GiB
  • Image: CentOS 8.2 64 bits
  • Other: Configure an EIP because you will need to install the Python library and DevCloud and configure the ECS as a deployment host.
  • DevCloud uses this server as a deployment host through port 22 over SSH. For high security, add the following IP addresses to the security group of the server. Otherwise, authorization will fail.

    42.202.130.147

    49.4.3.11

    122.112.212.206

    139.159.226.153

    49.4.85.127

    124.70.46.237

Configuring a Security Group for the Deployment Host

  1. Log in to the ECS console. In the navigation pane, choose Security Group to go to the network console.
  2. In the navigation pane of the network console, choose Access Control > IP Address Groups. Click Create IP Address Group, set parameters shown in Figure 1, and click OK.
    Figure 1 Creating an IP address group
    • Name: Enter ipGroup-clouddeploy.
    • IP Address:
      42.202.130.147
      49.4.3.11
      122.112.212.206
      139.159.226.153
      49.4.85.127
      124.70.46.237
  3. In the navigation pane, choose Access Control > Security Groups. Click Create Security Group, set parameters shown in Figure 2, and click OK.
    Figure 2 Configuring a security group
    • Name: Enter functions-deploy.
    • Enterprise Project: Enter default.
    • Template: Select Custom.
  4. Go to the details page of functions-deploy, click the Inbound Rules tab, and click Add Rule to add an inbound rule.
    Figure 3 Adding a rule

    Set Priority to 1, Protocol & Port to 22, and Source to the IP address group ipGroup-clouddeploy. Then click OK.

    Figure 4 Adding an inbound rule
  5. Return to the ECS console, click the ECS name, and change the security group to functions-deploy.

Installing Python Libraries

Run the following commands to install the pyyaml and pycryptodome libraries: The two libraries will respectively parse the cam.yaml configuration file of your function and encrypts and decrypts the function's environment variables.

pip3 install pyyaml
pip3 install pycryptodome

Installing KooCLI

  1. Install KooCLI.

    Remotely log in to the purchased ECS, and run the following command to install KooCLI:

    curl -sSL https://ap-southeast-3-hwcloudcli.obs.ap-southeast-3.myhuaweicloud.com/cli/latest/hcloud_install.sh -o ./hcloud_install.sh && bash ./hcloud_install.sh
    Figure 5 Installing KooCLI
  1. Initialize KooCLI.

    Run the following command to initialize KooCLI:

    hcloud configure init

    Enter an access key ID (AK), secret access key (SK), and region name. For details about how to obtain them, see 3 and 4.

    Figure 6 Initializing KooCLI
  2. Obtain an access key (AK/SK).
    • If you have access to the console, log in, and create an access key on the My Credentials page. For details, see Creating an Access Key. An AK/SK file is downloaded. Generally, it is named credentials.csv. As shown in the following figure, the file contains a username, AK, and SK.
      Figure 7 Content of the credentials.csv file
    • If you do not have access to the console, request the administrator to create an access key for you on the IAM console in case your access key is lost or needs to be reset. For details, see Managing Access Keys for an IAM User.
  3. Obtain a region name.
    For details, see Regions and Endpoints.
    Figure 8 Obtaining region information