Updated on 2025-04-09 GMT+08:00

Method 1: Opening a CCE Workload by Creating a Load Balance Channel

  1. Create a load balance channel.

    1. Go to the APIG console, and choose Gateways in the navigation pane.
    2. Choose API Management > API Policies.
    3. On the Load Balance Channels tab, click Create Load Balance Channel.
      1. Set the basic information.
        Table 1 Basic information parameters

        Parameter

        Description

        Name

        Enter a load balance channel name. Example: VPC_demo.

        Port

        Container port of a workload for opening services. Set this parameter to 80, which is the default HTTP port.

        Routing Algorithm

        Select WRR. This algorithm will be used to forward requests to each of the cloud servers you select in the order of server weight.

        Type

        Select Microservice.

      2. Configure microservice information.
        Table 2 Microservice configuration

        Parameter

        Description

        Microservice Type

        Cloud Container Engine (CCE) is always selected.

        Cluster

        Select the created cluster.

        Namespace

        Select a namespace in the cluster. In this example, select default.

        Workload Type

        Select Deployment. This parameter must be the same as the type of the created workload.

        Service Label Key

        Select the pod label app and its value deployment-demo of the created workload.

        Service Label Value

      3. Configure a server group.
        Table 3 Server group configuration

        Parameter

        Description

        Server Group Name

        Enter server_group_v1.

        Weight

        Enter 1.

        Backend Service Port

        Enter 80. This must be the same as the container port in the workload.

        Description

        Enter "Server group with version v1".

        Tag

        Select the pod label version=v1 of the created workload.

      4. Configure health check.
        Table 4 Health check configuration

        Parameter

        Description

        Protocol

        Default: TCP.

        Check Port

        Backend server port in the channel.

        Healthy Threshold

        Default: 2. This is the number of consecutive successful checks required for a cloud server to be considered healthy.

        Unhealthy Threshold

        Default: 5. This is the number of consecutive failed checks required for a cloud server to be considered unhealthy.

        Timeout (s)

        Default: 5. This is the timeout used to determine whether a health check has failed.

        Interval (s)

        Default: 10. This is the interval between consecutive checks.

      5. Click Finish.

        In the load balance channel list, click a channel name to view details.

  2. Open an API.

    1. Create an API group.
      1. Choose API Management > API Groups.
      2. Click Create API Group, and choose Create Directly.
      3. Configure group information and click OK.
    2. Create an API and bind the preceding load balance channel to it.
      1. Click the group name to go to the details page. On the APIs tab, choose Create API > Create API.
      2. Configure frontend information and click Next.
        Table 5 Frontend configuration

        Parameter

        Description

        API Name

        Enter an API name.

        Group

        The group the API belongs to. Select the preceding API group.

        URL

        • Method: Request method of the API. Set this parameter to ANY.
        • Protocol: Request protocol of the API. Set this parameter to HTTPS.
        • Subdomain Name: The system automatically allocates a subdomain name to each API group for internal testing. The subdomain name can be accessed 1,000 times a day.
        • Path: Path for requesting the API.

        Gateway Response

        Select a response to be displayed if the gateway fails to process an API request. Default: default.

        Matching

        Select Prefix match.

        Authentication Mode

        API authentication mode. Select None. (None: Not recommended for actual services. All users will be granted access to the API.)

      3. Configure the backend information and click Next.
        Table 6 Parameters for defining an HTTP/HTTPS backend service

        Parameter

        Description

        Load Balance Channel

        Determine whether the backend service will be accessed using a load balance channel. For this example, select Configure.

        URL

        • Method: Request method of the API. Set this parameter to ANY.
        • Protocol: Set this parameter to HTTP.
        • Load Balance Channel: Select the created channel.
        • Path: Path of the backend service.
      4. Define the response and click Finish.
    3. Debug the API.

      On the APIs tab, click Debug. Click the Debug button in red background. If the status code 200 is returned in the response result, the debugging is successful. Then go to the next step. Otherwise, rectify the fault by following the instructions provided in Error Codes.

    4. Publish the API.

      On the APIs tab, click Publish Latest Version, retain the default option RELEASE, and click OK. When the exclamation mark in the upper left of the Publish button disappears, the publishing is successful. Then go to the next step. Otherwise, rectify the error indicated in the error message.

  3. Call the API.

    1. Bind independent domain names to the group of this API.

      On the group details page, click the Group Information tab. The debugging domain name is only used for development and testing and can be accessed 1,000 times a day. Bind independent domain names to expose APIs in the group.

      Click Bind Independent Domain Name to bind registered public domain names. For details about how to bind a domain name, see Binding a Domain Name.

    2. Copy the URL of the API.

      On the APIs tab, copy the API URL. Open a browser and enter the URL. When the defined success response is displayed, the invocation is successful.

      Figure 1 Copying the URL

      Now, the CCE workload is opened by creating a load balance channel.