Server Migration Center (SMC) allows you to migrate servers to Container Registry. You can migrate containerized applications to Container Registry at low costs. Application containerization achieves automatic management and distribution of computing resources and ensures fast and secure deployment of applications. This improves resource usage and reduces computing costs. This topic describes how to migrate a server to Container Registry.

Prerequisites

  • The server is not based on a Windows operating system.
  • Container Registry is activated and a container image repository is created. For more information, see Activate an account and Create a repository.
  • A RAM role is created for the intermediate instance that is generated by SMC for migration. Set the following parameters to configure the RAM role. For more information, see Create a RAM role for a trusted Alibaba Cloud service.
    • Select Alibaba Cloud Service as the trusted entity type.
    • Select Normal Service Role as the role type.
    • Select Elastic Compute Service as the trusted service.
  • A custom policy is created for the RAM role of the intermediate instance. The policy grants the minimum permissions that are required to migrate a server to Container registry. The following example shows a sample policy. This policy is attached to the RAM role. For more information, see Create a custom policy and Grant permissions to a RAM role.
    {
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "cr:GetAuthorizationToken",
                    "cr:PushRepository",
                    "cr:PullRepository",
                    "cr:CreateRepository"
                ],
                "Resource": [
                    "*"
                ]
            }
        ],
        "Version": "1"
    }
  • The information of the source server is imported to the SMC console. For more information, see Step 1: Import the information of a migration source.
    Notice The SMC client V2.3.0 and later support server migration to Container Registry. You can use these SMC versions to import the information of the source server. Click here to download the latest version of the SMC client.

Background information

  • For information about Docker container images, see Concepts.
  • During migration, SMC creates an intermediate instance. You are charged a small fee for the intermediate instance. For more information, see Pay-as-you-go.
  • SMC releases the intermediate instance after the migration task enters the Finished or Expired state, or when the task is deleted.

Procedure

  1. (Optional) Step 1: Exclude dynamic data directories
  2. Step 2: Create and start a migration task
  3. Step 3: Verify the container image

(Optional) Step 1: Exclude dynamic data directories

To ensure stable migration, we recommend that you exclude dynamic data directories, such as data directories of large databases. Then, you can pause the services on the source server and start the migration task. Skip this step if you do not need to exclude dynamic data directories.

You do not need to stop services on the source server to exclude dynamic data directories. To exclude dynamic data directories, perform the following steps.

  1. Log on to the source server.
  2. Configure the SMC client and exclude dynamic data directories.

Step 2: Create and start a migration task

You can perform the following steps to exclude dynamic data directories. You do not need to stop your services that are running on the source server.

  1. Log on to the SMC console.
  2. In the left-side navigation pane, click Migration Sources.
  3. Find the source server from which you want to migrate data.
  4. Click Create Migration Task in the Actions column.
  5. On the Create Migration Task page, set the container image parameters.
    Set the following parameters to configure the container image. For information about other parameters, see Step 2: Create and start a migration task.
    • Target Image Type: the type of the destination image. Select Container Image.
    • Namespace: the namespace of the destination image.
    • Repository Name: the name of the repository that stores the destination image.
    • Version: the version of the destination image.
    • RAM Role: the RAM role that is attached to the intermediate instance.
    site
    The migration task starts immediately after it is created. Then, the migration task enters the Finished or InError state.
    • If the migration task enters the Finished state, the task is completed and a container image is generated.
    • If the migration task enters the InError state, the task fails. You can check the logs to troubleshoot the failure. Then, restart the migration task. For information about common errors and solutions, see SMC FAQ.

Step 3: Verify the container image

After you migrate the source server to Container Registry, a container image is created. Perform the following steps to verify the container image. A container image on which NGINX is deployed is used as an example.

  1. Create a Kubernetes cluster in the Container Service for Kubernetes console. For more information, see Create an ACK cluster.
  2. Log on to the Container Service for Kubernetes console.
  3. In the left-side navigation pane, click Clusters to view the created Kubernetes cluster.
  4. In the Actions column, click Applications.
  5. On the Deployments tab, click Create from Image to create a deployment.
    Set the following parameters. For information about other parameters and operations, see Create deployments by using images.
    • In the Basic Information step, set the following parameters:
      • Name: the name of the application. Set the value to nginx.
      • Replicas: the number of application replicas. Set the value to 1.
      • Type: the type of the application. Set the value to Deployments.
      k8s
    • In the Container step, set the following parameters:
      • Image Name: Click Select Image to select the container image that is generated after the migration is complete. If the container image repository and the Kubernetes cluster are deployed in the same region, you can use the Virtual Private Cloud (VPC) endpoint of the container image to pull the image.
      • Image Version: Click Select Image Version to select the version of the container image that is generated after the migration is complete.
      • Set Image Pull Secret: This parameter is required if the container image is a private image. You can also use a plug-in to pull the image. This method does not require a secret. For more information, see Use aliyun-acr-credential-helper to pull images without a password.
      • Port: Add port 80.post
      • Start: Enter the /sbin/init command.cmd
    • In the Advanced step, create a service to access the application.

      Use the example values in the following figure when you set the required parameters.

      server
  6. After the service is created, click Details to view the application status.
  7. In the left-side navigation pane, click Services. On the Services page, view the External Endpoint of the service.
  8. You can use a browser to access the external endpoint.
    nginx