This topic describes how to configure the SLB instance attached to the Swarm cluster to redirect a percentage of traffic to the related cluster of Container Service for Kubernetes (ACK).

After a Server Load Balancer (SLB) instance receives requests, the requests are forwarded to the backend servers of the SLB instance. To mount a server to the listener of an SLB instance, you can add the server to one of the following groups: default server group, primary/secondary server group, or VServer group.

The default server group and primary/secondary server group require that servers in the same group use the same listening port. However, servers in a Swarm cluster use port 9080 to receive traffic from the SLB instance. The previously created NodePort Service can use only a port from 30000 to 32767 to receive traffic from the SLB instance. In this case, you can add the server that hosts the NodePort Service to only a VServer group to route traffic to the Service. Perform the following steps:

Check the backend servers of the attached SLB instance

Check whether VServer groups are created to mount servers to the SLB instance that is attached to the Swarm cluster.

  1. Log on to the SLB console. In the left-side navigation pane, choose Instances > Instances.
  2. On the Instances page, find the attached SLB instance and check its backend server type.
    Instances

Create a VServer group

  1. On the Instances page, click the attached SLB instance. Click the Listener tab. Then, click the VServer Groups tab.
  2. Click Create VServer Group to go to the Create VServer Group page.
    Create VServer Group
  3. Click Add to open the My Servers dialog box.
  4. Set the parameters and click Create to create a VServer group. For more information, see Add ECS instances to a VServer group.
    Note
    • When you add servers to the VServer group, select all servers in the Swarm cluster. This ensures that the backend servers can handle all production traffic when you switch traffic to this VServer group. You can add one or more servers in the related ACK cluster to the VServer group.
    • The port and weight settings of the servers from the Swarm cluster must be the same as those of the previously configured default server group or primary/secondary server group.

Configure the listener and switch traffic to the VServer group

After the VServer group is created, you must configure the listener to switch traffic from the default server group or primary/secondary server group to the VServer group.

  1. On the Instances page, click the attached SLB instance to go to the Listener tab. On the Listener tab, find the port that you want to configure and click Modify Listener in the Actions column.
    Instances
  2. On the Configure Listener page, modify the configurations in the Protocol and Listener step and click Next.
    Configure the listener
  3. In the Backend Servers section, click VServer Group and select swarm&K8s as the VServer group. Check whether the public and internal IP addresses and port settings of servers from the Swarm cluster are correct. Then, click Next to save the modifications.
  4. Modify the configurations in the Health Check step based on your requirements and click Next.
  5. Check whether all configurations are modified based on your requirements in the Confirm step and click Submit.
  6. Go to the Listener tab. The server group of the related listener is now changed to [Virtual]swarm&k8s.

Check whether requests are properly handled

Monitor the service performance for a period of time and check whether requests are properly handled. You can use CloudMonitor > Host Monitoring, CloudMonitor > Log Monitoring, or other monitoring services to check how inbound traffic is handled.

Add servers in the ACK cluster to the VServer group

If the backend server type of the SLB instance is VServer group, you need to add servers in the ACK cluster to the VServer group. The routes a percentage of production traffic to the ACL cluster.

  1. On the Instances page, click the attached SLB instance to go to the Listener tab. On the Listener tab, find the port that you want to use and click the related server group in the Server Group column.
  2. On the VServer Groups tab, find the VServer group that you want to use and click Edit in the Actions column. On the Edit VServer Group page, click Add More to add servers of the ACK cluster to the VServer group.
    Edit VServer Group
    Note
    • You can add one or more servers of the ACK cluster to the VServer group. This allows you to implement canary releases based on your requirements.
    • The port settings of the servers from the ACK cluster must be the same as those of the NodePort Service.

      The port range is 30000 to 32767. In this example, port 30080 is used, which points to the gateway-swarm-slb Service in the ACK cluster.

    • You can also set weights to specify the percentage of traffic sent to the ACK cluster.

Check whether traffic is routed to the ACK cluster

Monitor the service performance for a period of time and check whether requests are properly handled. Then, check whether traffic is routed to the ACK cluster based on the weight settings of servers in the VServer group.
Note In this topic, the SLB instance attached to the Swarm cluster is configured to route a percentage of traffic to the related ACK cluster. This way, you can check whether applications run as expected in the ACK cluster. Meanwhile, the Swarm cluster still handles production traffic. For more information about how to delete the Swarm cluster, see Delete a Swarm cluster.