This topic describes how to route a percentage of production traffic to a Kubernetes cluster and validate the functions of the cluster. This helps you validate the functions that are not included in regression testing.

Prerequisites

You have completed regression testing. For more information, see Regression testing.

Route traffic to a Kubernetes service

You can use one of the following methods to route traffic to a Kubernetes service:
  • Upgrade client versions or modify DNS records to forward traffic to the endpoint of the SLB instance attached to the Kubernetes cluster.
    • High cost of traffic redirection

      You need to upgrade client versions or modify DNS settings.

    • High cost of rollback
      • If issues are found in the Kubernetes cluster, you must upgrade client versions or modify DNS settings again to route traffic back to the Swarm cluster.
      • It may take a long time to upgrade client versions or update DNS cache, which negatively affects the performance of your workloads.
  • Add your Kubernetes service to the backend of the SLB instance attached to the Swarm cluster and set a weight to specify the percent of traffic that is routed to the service.
    • Low cost of traffic redirection
      • You only need to configure the SLB instance attached to the Swarm cluster in the Server Load Balancer console.
      • You can set weights to specify the percent of traffic that is routed to different services.
    • Low cost of rollback
      • You only need to configure the SLB instance attached to the Swarm cluster in the Server Load Balancer console.
      • The new configurations take effect immediately.
  1. Create a NodePort service in a Kubernetes cluster.
  2. Validate the functions of the NodePort Service.
  3. Configure the SLB instance attached to the Swarm cluster.

How to roll back

After production traffic is routed to the Kubernetes service, you can modify the configurations of VServer groups to roll back when issues are found. You can set the weight of the ECS instance that hosts the service to 0 or remove the ECS instance.

  1. Log on to the Server Load Balancer console. On the Server Load Balancers page, click the target SLB instance.
  2. On the details page that appears, click the VServer Groups tab. Select the target VServer group and click Edit in the Actions column.
  3. On the Edit VServer Group page that appears, select the target ECS instance and click Delete in the Actions column. Then click OK.

Summary

You can configure VServer groups to route a percentage of production traffic to a NodePort service deployed in a Kubernetes cluster and validate the functions of the service.

Compared with traffic redirection by upgrading client versions or updating DNS records, this method only needs you to modify SLB configurations, which take effect without delay and allow you to specify the percent of traffic sent to different services. This reduces the cost of rollback and minimizes the risk of service disruption.