Background information

If applications of the Swarm cluster are accessed through <HostIP>:<port> or node IP addresses directly resolved from domain names, resources of the Swarm cluster cannot be migrated without service interruption. In addition, the migration cannot be rolled back in real time. You must standardize the Swarm cluster by configuring a Server Load Balancer (SLB) instance to access applications in the Swarm cluster and installing the CloudMonitor agent on Elastic Compute Service (ECS) instances of the Swarm cluster.

Access the Swarm cluster through an SLB instance

  1. Create an SLB instance.
    • Automatically create an SLB instance

      If you have selected Automatically Create SLB Instances when creating the Swarm cluster, a pay-as-you-go SLB instance has been created automatically.

      You can log on to the SLB console to view the created SLB instance. Make sure that the SLB instance has been configured to listen to TCP port 9080 of backend servers .

    • Manually create an SLB instance
      If you have not selected Automatically Create SLB Instances when creating the Swarm cluster, you must manually create an SLB instance and bind it to the Swarm cluster. The procedure is as follows:
      1. Create an SLB instance. For more information, see Create an SLB instance.
      2. Bind the SLB instance to the Swarm cluster to make sure that the Swarm cluster automatically updates the SLB configuration. For more information, see Bind and unbind a Server Load Balancer instance.
  2. Configure simple routing.
    If applications are accessed through <HostIP>:<port>, clients are bound to the IP addresses of nodes in the Swarm cluster. If nodes of the cluster are replaced or scaled out, you must modify the client configurations to access applications deployed on new nodes. Therefore, we recommend that you configure domain names for applications and enable clients to access applications through domain names.
    Note Alibaba Cloud Container Service allows you to configure an independent domain name for each application or service for free in case that you do not have custom domain names. The domain name provided by Container Service is in the format of XXX.$cluster_id.$region_id.alicontainer.com, where XXX can be customized for each application or service.

    In this way, clients can access an application or a service through a custom domain name or a test domain name provided by Container Service, instead of <HostIP>:<port> of an ECS or SLB instance. For more information, see Simple routing - supports HTTP and HTTPS.

  3. Test access to your application through the SLB instance.

    Use the domain name configured in the previous step to access your application, test the features of the application, and check whether the SLB instance has inbound traffic.

    1. Access the application through the domain name.
    2. Check whether the SLB instance has inbound traffic.
      Note Test the features of the application to verify that domain name-based access to the application through the SLB instance has no impact on the features of the application.
  4. Change the access address for Domain Name System (DNS) resolution or on clients.
    • Change the address for DNS resolution: If clients originally use a domain name to access your application, contact your DNS service provider to change the IP address to be resolved from the domain name from the IP address of a node to that of the SLB instance.
      Note Each DNS service provider caches IP addresses for DNS resolution. You must monitor the traffic on the SLB instance to verify that the change takes effect.
    • Change the address on clients: If clients originally use the IP address of a node to access your application, modify the client configurations to access the application through the domain name.

Optional: Install the CloudMonitor agent on ECS instances of the Swarm cluster

If you have not selected Install the CloudMonitor Agent on ECS Nodes when creating the Swarm cluster, the CloudMonitor agent is not installed on the ECS instances of the Swarm cluster. As a result, you cannot view the monitoring information of the ECS instances in CloudMonitor during cluster migration. For example, when you take the Swarm cluster offline, you cannot use CloudMonitor to check whether the ECS instances still have any traffic. This section describes how to view the monitoring information of the ECS instances and manually install the CloudMonitor agent if it is not installed.

  1. View the monitoring information of the ECS instances in the Swarm cluster.
    1. Log on to the Container Service - Swarm console. In the left-side navigation pane, click Nodes. On the Nodes page, find the target node and click Monitor in the Actions column.
    2. On the page that appears, click Monitoring in the left-side navigation pane. In the Monitoring information section, you can view detailed monitoring information of this node in a specific time range.

    If the CloudMonitor agent is not installed, you cannot view detailed monitoring information of the ECS instances, such as the memory usage, disk usage, and TCP connections. Go to the next step to install the CloudMonitor agent on the ECS instances.

  2. Manually install the CloudMonitor agent on the ECS instances in the Swarm cluster.
    1. Log on to the CloudMonitor console. In the left-side navigation pane, choose Dashboard > Host Monitoring. Click the Instances tab. Select target ECS instances and click Batch Install to install the CloudMonitor agent on the selected ECS instances.
    2. After the CloudMonitor agent is installed, choose Dashboard > Host Monitoring. Click an ECS instance. In the Network Metric section, you can view the curve about Network Inbound and Outbound Rate for the ECS instance.