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.
- Log on to the SLB console. In the left-side navigation pane, choose .
- On the Instances page, find the attached SLB instance and check its backend server type.
- If the backend server type is default server, go to the next step.
- If the backend server type is VServer group, go to the Configure the listener and switch traffic to the VServer group step.
Create a VServer group
- On the Instances page, click the attached SLB instance. Click the Listener tab. Then, click the VServer Groups tab.
- Click Create VServer Group to go to the Create VServer Group page.
- Click Add to open the My Servers dialog box.
- Set the parameters and click Create to create a VServer group. For more information, see Add ECS instances to a VServer group.
- 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.
- 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.
- On the Configure Listener page, modify the configurations in the Protocol and Listener step and click Next.
- 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.
- Modify the configurations in the Health Check step based on your requirements and click Next.
- Check whether all configurations are modified based on your requirements in the Confirm step and click Submit.
- 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, , 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.
- 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.
- 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.
- 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.