Updated on 2023-04-12 GMT+08:00

Creating a Traffic Policy

UCS intelligently distributes application requests and supports functions such as traffic splitting, grayscale release, and failover.

Prerequisites

  • You have connected a Kubernetes cluster to UCS and enabled network access for the cluster. For details, see Quickly Connecting an Attached Cluster.
  • A LoadBalancer Service has been created for the cluster.
  • An approved public domain name has been added to Huawei Cloud DNS record set. For details, see Creating a DNS Record Set.

Procedure

Assume that your services are deployed in multiple regions. By default, users in China access your services in the CN North-Beijing4 region, and users in Asia Pacific will be served in the AP-Singapore region to reduce the latency. In this case, you can create a traffic policy to split traffic for applications by region.

  1. Log in to the UCS console.
  2. In the navigation pane, choose Traffic Distribution.
  3. Click Create Traffic Policy in the upper right corner.
  4. Select the domain name added to the record set and enter the domain name prefix as prompted. If there is no subdomain name, the domain name prefix can be left blank.
  5. Add a scheduling policy. In this example, set only key parameters listed in Table 1 and retain the default values for other parameters. To create traffic policies for users in different regions, repeat this step and select different clusters and line types.

    Table 1 Key parameters of a scheduling policy

    Parameter

    Description

    Cluster

    Select a cluster in Running state. All clusters taken over by UCS are displayed.

    Namespace

    Namespace to which the Service belongs. Defaults to default.

    Service

    Select a Service. Only LoadBalancer Services can be selected.

    Line Type

    • ISP line: routes visitors to the optimal address based on the carrier networks they use. Defaults to China Telecom/Default regions. You can specify a carrier and region down to province.
    • Region line: routes visitors to the optimal address based on their geographic locations. Defaults to Chinese Mainland/Default regions. You can select a global region. For Chinese Mainland, the region granularity is province. For Global, the region granularity is country/region.
    Figure 1 Adding a scheduling policy

  6. Click OK. Under this traffic policy, users in Asia Pacific will preferentially access the specified line.
  7. Check whether the scheduling policy takes effect. For details, see How Do I Check Whether Record Sets Have Taken Effect?

    You can use a device that has connected to the Internet at Asia Pacific and run the following command to check whether the scheduling policy takes effect:

    nslookup demo.***.com

    If the device OS does not support the nslookup command, manually install it first. For example, if you are using a CentOS device, run the yum install bind-utils command first.

    If the following information is displayed and the IP address of Address is the load balancer IP of the target cluster, the scheduling policy takes effect.

    Server: ***
    Address: *.*.*.*
    
    Non-authoritative answer: 
    Name: demo.***.com
    Address:  124.*.*.*