After an SLB instance receives a request, the request is forwarded to its backend servers. To mount a server to the backend 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 the Swarm cluster use port 9080 to receive traffic from the SLB instance. The previously created NodePort service can only use a port from 30000 to 32767 to receive traffic from the SLB instance. In this case, you can only add the server that hosts the NodePort service to a VServer group to route traffic to this service.

Check the backend servers of the SLB instance

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

  1. Log on to the Server Load Balancer console. In the left-side navigation pane, choose Instances > Server Load Balancers.
  2. On the Server Load Balancers page that appears, find the target SLB instance and check its backend server type.

Create a VServer group

  1. On the Server Load Balancers page, click the ID of the target SLB instance. On the instance details page that appears, click the VServer Groups tab.
  2. Click Create VServer Group to open the Create VServer Group page.
  3. Set the parameters and click Create to create a VServer group. For more information, see Create 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 Kubernetes 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 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 need to configure the listener to switch traffic from the default server group or primary/secondary server group to the VServer group.

  1. On the Server Load Balancers page, click the ID of the target SLB instance to go to the instance details page. On the Listener tab, select the target port and click Configure in the Actions column.
  2. On the Configure Listener page, modify the configurations and click Next.
  3. In the Backend Servers section, click VServer Group and select swarm&K8s as the target VServer group. Verify that the public and internal IP and port settings of servers from the Swarm cluster are correct. Then click Next to save the change.
  4. Go to the Listener tab. The server group of the target port 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 incoming traffic is handled.

Add servers in the Kubernetes cluster to the VServer group

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

  1. On the Server Load Balancers page, click the ID of the target SLB instance to go to the instance details page. On the Listener tab, click the VServer group in the Server Group column.
  2. On the Edit VServer Group page that appears, click Add More to add servers in the Kubernetes cluster to the VServer group.
    Note
    • You can add one or more servers in the Kubernetes cluster to the VServer group. This allows you to implement canary releases based on your needs.
    • The port settings of the servers from the Kubernetes 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 on Kubernetes.

    • You can also set weights to specify the percent of traffic sent to the Kubernetes cluster.

Check whether traffic is routed to the Kubernetes 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 Kubernetes cluster based on the weight settings of servers in the VServer group.
Note This topic configures the SLB instance attached to the Swarm cluster to route a percentage of traffic to the Kubernetes cluster. The aim is to validate the functions of the Kubernetes cluster. Meanwhile, the Swarm cluster still handles incoming traffic. For more information about deleting the Swarm cluster, see Delete a Swarm cluster.