All Products
Search
Document Center

Container Service for Kubernetes:Migrate source servers to Container Registry

Last Updated:Mar 05, 2024

Server Migration Center (SMC) allows you to migrate Linux 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 automatically managed 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 Linux 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 more information about the basic knowledge of Container Registry, see Terms.

  • During migration, SMC creates an intermediate instance. You are charged a small amount of fees for the intermediate instance. For more information, see Pay-as-you-go.

  • SMC releases the intermediate instance after the migration job enters the Completed or Expired state, or when the job is deleted.

Step 1: Preparations

  1. Create a Resource Access Management (RAM) role. The RAM role is to be attached to an intermediate instance that is created by SMC during migration.

    Configure 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 about a source server.

    Import the information about 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. On the Migration Sources page, find the source server from which you want to migrate data and click Create Migration Job in the Actions column.

    4. In the Create Migration Job dialog box, configure the container image parameters.

      Configure the following parameters to configure the container image. For more information about other parameters, see Create a server migration job.

      • 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 Completed or InError state.

    • If the migration job enters the Completed 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 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 this example.

  1. Create a Container Service for Kubernetes (ACK) cluster. 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 and click Deploy Application in the Actions column.adad56

    4. In the CreateApplication wizard, create a containerized application as prompted.

      In this example, a Deployment is created. The following content describes the key parameters. For more information about other parameters, see Create a stateless application by using a Deployment.

      1. In the Basic Information step, configure the following parameters. Then, click Next.adadada

        • Name: the name of the application. Example: nginx.

        • Replicas: the number of application replicas. Example: 1.

        • Type: the type of the application. Set the value to Deployment.

      2. In the Container step, configure the following parameters. Then, click Next.

        • Image Name: the name of the container image. Click Select Image to select the container image that is generated after the migration is complete. If the container image repository and the ACK 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: the version of the container image. 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 using a password.

        • Port: the port of the container image. 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 configure the parameters in the dialog box.

        Use the example values in the following figure when you configure 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