Server Migration Center (SMC) allows you to migrate servers as images to Container Registry. Then, you can use the images to deploy the servers. This way, you can migrate containerized applications at low costs. Containerized applications are distributed applications that are managed automatically and deployed with high agility and low-security risks. Application containerization improves resource usage and reduces computing costs. This topic describes how to migrate a server to Container Registry.

Prerequisites

Container Registry is activated, and an image repository is created. For more information, see Create a repository and build images.

Background information

Important SMC does not allow you to migrate Windows servers to Container Registry.
  • For information about Docker container images, see Terms.
  • During migration, SMC creates an intermediate instance. The intermediate instance incurs a small fee. For more information, see Pay-as-you-go.
  • SMC releases the intermediate instance after the migration job enters the Finished or Expired state, or when the job is deleted.

Step 1: Prepare for the migration

  1. Create a RAM role to be used by the intermediate instance that is created by SMC for migration.
    Set the following key parameters for the RAM role. For more information, see Create a RAM role for a trusted Alibaba Cloud service.
    • Select Trusted Entity: Select Alibaba Cloud Service.
    • Role Type: Select Normal Service Role.
    • Select Trusted Service: Select Elastic Compute Service.
  2. Create a custom policy 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"
    }

Step 2: Migrate a source server to Container Registry

  1. Import the information of a migration source.
    Import the information of a Linux server to the SMC console by using one of the following methods:
  2. Create and start a migration job.
    1. Log on to the SMC console.
    2. In the left-side navigation pane, click Migration Sources.
    3. Find the migration source from which you want to migrate data. Click Create Migration Job in the Actions column.
    4. On the Create Migration Job page, set the parameters related to the container image.
      SiteSet the following parameters to configure the container image. For more information about other parameters, see Create a server migration task.
      • Destination Type: the type of the container image. Select Container Image.
      • Namespace: the namespace of the container image. For more information about how to create a namespace, see Manage namespaces and resource quotas.
      • Repository Name: the name of the repository in which the container image is stored. For more information about how to create an image repository, see Create a repository and build images.
      • Version: the version of the container image.
      • RAM Role: the RAM role that is attached to the intermediate instance. For more information about how to create a RAM role, see Create a RAM role for a trusted Alibaba Cloud service.
    The migration job immediately starts after it is created. Then, the migration job enters the Finished or InError state.
    • If the migration job enters the Finished state, the job is complete, and a container image is generated. ada56
    • If the migration job enters the InError state, the job fails. You can check the logs to troubleshoot the failure. Then, restart the migration job. 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. You can use the container image to deploy a containerized application. The following example shows you how to verify a container image. A container image of NGINX is used in the example.

  1. Create a Kubernetes cluster in the Container Service for Kubernetes (ACK) console. For more information, see Create an ACK dedicated cluster.
  2. Create a containerized application.
    1. Log on to the SMC console.
    2. In the left-side navigation pane, click Migration Jobs.
    3. Find the migration job that you want to manage. In the Actions column, click Deploy Application. adad56
    4. In the CreateApplication wizard, configure the application by following the on-screen instructions.
      In the following example, a Deployment is created. The following example shows you how to set the key parameters for the Deployment. For more information about other parameters, see Create a stateless application by using a Deployment.
      1. In the Basic Information step, set the following parameters. Then, click Next. adadada
        • 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 Deployment.
      2. In the Container step, set the following parameters. Then, click Next.
        • 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 key. For more information, see Use the aliyun-acr-credential-helper component to pull images without a password.
        • Port: Add port 80. Post
        • Start: Enter the /sbin/init command. CMD
      3. In the Advanced step, create a Service to expose the application. Click Create after you set the parameters in the dialog box.
        Use the example values shown in the following figure when you set the parameters. Server
      4. After the Service is created, click Details to view the application status.
      5. In the left-side navigation pane, choose Network > Services.
      6. On the Services page, obtain the external endpoint of the Service.sdada
  3. Verify that the NGINX welcome page is displayed when you access the external endpoint in a browser.
    nginx