Kubernetes cluster automatic migration method and system

Through the combination of CRD and Operator management components, it solves the problem of insufficient automated implementation of Kubernetes cluster migration tools in private clouds and hybrid environments, realizes automatic migration across platforms and different host architectures, improves migration efficiency and flexibility, and is suitable for Various environments.

CN118689651APending Publication Date: 2024-09-24CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410863295.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-29
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

Existing Kubernetes cluster migration tools are not highly automated in private clouds or hybrid environments, require manual intervention, have low integration, and cannot meet migration needs across platforms and different host architectures.

Method used

By creating Custom Resource Definition (CRD) instances, including backup tasks, recovery tasks, migration tasks and K8S cluster CRD, combined with Operator management components, the automated migration process is realized, and external or self-built object storage is supported, and backup and recovery tools are automatically installed and supervised. , suitable for public cloud, private cloud and hybrid environments.

Benefits of technology

It realizes automatic Kubernetes cluster migration without manual intervention, cross-platform migration capability, supports different host architectures, improves migration efficiency and flexibility, and can migrate to multiple destination clusters in batches, reducing operation and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118689651A
    Figure CN118689651A
Patent Text Reader

Abstract

The invention discloses a Kubernetes cluster automatic migration method and system. The Kubernetes cluster automatic migration method comprises the following specific steps that a task CRD is backed up; a task CRD is recovered; migrating a task CRD; a K8S cluster CRD is constructed; and the Operator management component completes a migration task of K8S cluster resources by establishing and maintaining CRD instances corresponding to the CRDs, external object storage can be used in a butt joint manner, object storage can also be self-established, backup and recovery tools can be automatically installed, migration, backup and recovery processes are automatically supervised through an Operator mode, manual operation and maintenance are reduced, and efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of container cloud platforms, and in particular to a Kubernetes cluster automatic migration method and system. Background Art

[0002] With the maturity of K8S (Kubernetes) container technology, user business applications are widely deployed in K8S clusters. As the number of user business applications increases, resource consumption increases, and resources gradually become a bottleneck. Or the new version of K8S has better features and functions, and the outdated version of K8S cannot use these new version features and functions, and the old environment can no longer meet user needs; second, due to business security, it is necessary to back up the resources on the K8S cluster or build a multi-AZ environment; third, due to environment transfer, it is necessary to quickly deploy business applications in other new environments, such as switching from X86 and Centos architecture environments to domestic architecture environments.

[0003] To achieve the migration from the original K8S cluster to the new K8S cluster, it is usually necessary to deploy the K8S cluster in the new environment, use the backup and recovery tools to back up the resources in the original K8S cluster, and then restore the resources in the new K8S cluster. This process requires the preparation of deploying resources and backup and recovery tools. The steps are cumbersome and prone to errors. Although open source tools provide K8S cluster backup and recovery tools, the integration is not high and requires manual implementation; although public clouds also provide automatic migration tools, the applicable environment is limited. In private cloud environments or hybrid environments, the degree of automated implementation is not high. Summary of the invention

[0004] The purpose of this section is to summarize some aspects of embodiments of the present invention and briefly introduce some preferred embodiments. Some simplifications or omissions may be made in this section and the specification abstract and the invention title of this application to avoid blurring the purpose of this section, the specification abstract and the invention title, and such simplifications or omissions cannot be used to limit the scope of the present invention.

[0005] In view of the problems existing in the above-mentioned existing Kubernetes cluster automatic migration method and system, the present invention is proposed.

[0006] Therefore, the purpose of the present invention is to provide a Kubernetes cluster automatic migration method and system, which is to solve the problem that "open source tools provide K8S cluster backup and recovery tools, but the integration is not high and requires manual implementation; although the public cloud also provides automatic migration tools, the applicable environment is limited, and the degree of automation implementation is not high in private cloud environments or hybrid environments."

[0007] To solve the above technical problems, the present invention provides the following technical solutions: a Kubernetes cluster automatic migration method, comprising the following specific steps:

[0008] S1: backup task CRD;

[0009] S2: restore task CRD;

[0010] S3: Migration task CRD;

[0011] S4: K8S cluster CRD;

[0012] S5: Operator management component;

[0013] By establishing and maintaining the CRD instances (Custom Resource custom resource instances) corresponding to these CRDs, the K8S cluster resource migration task is completed.

[0014] As a preferred solution of the Kubernetes cluster automatic migration method described in the present invention, it is installed in the K8S cluster in the form of a plug-in, and external object storage is specified through installation parameters, or self-built object storage is used.

[0015] As a preferred solution of the Kubernetes cluster automatic migration method described in the present invention, the K8S installation process includes the following specific steps:

[0016] A1: Create backup task CRD, recovery task CRD, migration task CRD, K8S cluster CRD, and migration management Operator;

[0017] A2: If no external object storage is specified, create a local object storage system;

[0018] A3: Create a migration capability component load, which includes the K8S cluster backup and recovery tool;

[0019] A4: Create a K8S deployment capability component load, which includes the scripts and cross-host architecture resources required for K8S deployment.

[0020] As a preferred solution of the Kubernetes cluster automatic migration method described in the present invention, the migration task CRD includes the following specific steps:

[0021] S31: Create a CRD instance of the destination K8S cluster for migration: specify the destination K8S cluster, node host list, and whether to automatically create a K8S cluster identifier;

[0022] S32: Create a migration task CRD instance. The key configuration parameters are: namespace Selector, resource type Selector, and target K8S cluster Selector. That is, specify which resources need to be migrated to which K8S clusters. After creation, the migration management operator monitors the migration task CRD instance and completes the migration task through the management component.

[0023] S33: Migration management Operator, responsible for monitoring and managing migration task CRD instances. First, it parses out the necessary resources that need to be migrated, generates backup task CRD instances and recovery task CRD instances; second, it parses out the K8S cluster that needs to be migrated, installs backup and recovery tools, and restores resources in the destination cluster. If the destination cluster is a K8S cluster to be automatically created, the K8S cluster will be created by the K8S deployment capability component.

[0024] As an optimal solution of the Kubernetes cluster automatic migration system described in the present invention, the migration capability component load is responsible for implementing resource backup of the original K8S cluster. According to the resources to be backed up specified in the migration task CRD instance, the K8S cluster resource backup tool is used to back up the cluster resources and save them to the object storage, so that the backup task CRD instance is updated to the completed status and the migration task CRD instance is updated to the backed up status.

[0025] As a preferred solution of the Kubernetes cluster automatic migration system described in the present invention, the K8S deployment capability component load is responsible for completing the creation of a new K8S cluster and automatically completing the following key steps:

[0026] a: Check the host architecture and operating system type;

[0027] b: Install the appropriate Docker according to the detected host type parameters;

[0028] c: Install the K8S program that adapts to the host architecture;

[0029] d: After creating a K8S cluster with a cross-host architecture, update the status of the K8S cluster CRD instance to normal.

[0030] As a preferred solution of the Kubernetes cluster automatic migration system described in the present invention, wherein: the migration capability component load, resource recovery is implemented on the target K8S cluster, and the K8S cluster resource recovery tool is used to restore resources from the object storage to the target K8S cluster, so that the recovery task CRD instance and the migration task CRD instance are updated to the completed status.

[0031] As a preferred solution of the Kubernetes cluster automatic migration system described in the present invention, the namespace Selector is a list of namespace names that can be specified, and all namespaces are defaulted; the resource type Selector is a specified K8S resource type, such as load, Service, Pod, and all resource types are defaulted.

[0032] As a preferred solution of the Kubernetes cluster automatic migration system described in the present invention, the operating system type supports arm64 and x86 architectures, and supports centos, kylin, Tongxin, and Euler operating systems.

[0033] As a preferred solution of the Kubernetes cluster automatic migration system described in the present invention, the CRD is a Custom Resource Definition custom resource.

[0034] Beneficial effects of the present invention:

[0035] 1. You can connect to external object storage or build your own object storage, automatically install backup and recovery tools, and automatically supervise the migration, backup, and recovery processes through the Operator mode, reducing manual operation and maintenance and improving efficiency.

[0036] 2. Cross-platform features: Applicable to public clouds, private clouds, and hybrid platforms, and can also be used for migration between K8S clusters with different host architectures.

[0037] 3. The migration destination K8S cluster is more flexible and can be migrated to an existing K8S cluster. Another new feature is that it can automatically create a new K8S cluster and then migrate, while also having the ability to deploy in a new environment and migrate services.

[0038] 4. The migration task capability is improved. By specifying a migration task once, you can specify batch migration to multiple destination K8S clusters to complete the deployment of multiple environments. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. Among them:

[0040] Figure 1 is a system architecture diagram of the present invention;

[0041] Figure 2 It is a migration flow chart of the present invention. DETAILED DESCRIPTION

[0042] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings.

[0043] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0044] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.

[0045] Reference Figures 1-2 , as an embodiment of the present invention, provides a Kubernetes cluster automatic migration method, which includes a backup task CRD, a recovery task CRD, a migration task CRD, a K8S cluster CRD, and an Operator management component. By establishing and maintaining CRD instances (Custom Resource custom resource instances) corresponding to these CRDs, the migration task of the K8S cluster resources is completed.

[0046] This solution also provides a Kubernetes cluster automatic migration system for the above system, which is as follows: This system is installed in the K8S cluster as a plug-in. Through the installation parameters, external object storage can be specified, or self-built object storage can be used;

[0047] These mainly include:

[0048] 1. Create backup task CRD, recovery task CRD, migration task CRD, K8S cluster CRD, and migration management Operator; if no external object storage is specified, create a local object storage system; create a migration capability component load, which includes the K8S cluster backup and recovery tool; create a K8S deployment capability component load, which includes the scripts required for K8S deployment and cross-host architecture resources.

[0049] 2. Migrate the capability component load, implement resource recovery for the destination K8S cluster, use the K8S cluster resource recovery tool to restore resources from the object storage to the destination K8S cluster, and update the recovery task CRD instance and migration task CRD instance to the completed status.

[0050] Specific:

[0051] Prepare three virtual machines configured with 8C / 16G, with Linux operating system kernel 4.19 and above. The first host is used to simulate the K8S cluster of the old environment, the second host is used to simulate the existing K8S cluster of the new environment, and the third is used to simulate the K8S cluster to be created in the new environment. The third host is a host with a different architecture to verify the migration of all resources of the K8S cluster of the old environment to the two K8S clusters of the new environment:

[0052] Cluster name node IP host architecture

[0053] cluster-old 192.168.73.34X86, Centos

[0054] cluster-new1 192.168.73.35X86, Centos

[0055] cluster-new2 192.168.73.36arm64, Kylin

[0056] The first step is to install the automatic migration plug-in on the old environment cluster cluster-old and wait for the plug-in to be installed.

[0057] Step 2: In the old environment cluster cluster-old, create a migration destination cluster CRD instance for cluster-new1. This is a pre-created K8S cluster, so the automatic creation of K8S cluster flag is set to false. Create a migration destination cluster CRD instance for cluster-new2. This is a currently non-existent K8S cluster, so the automatic creation of K8S cluster flag is set to true.

[0058] Step 3: Migrate all resources of the old environment cluster cluster-old. In cluster-old, create a migration task CRD instance. By default, select all namespaces for the namespace Selector, select all resource types for the resource type Selector, and fill in cluster-new1 and cluster-new2 for the destination cluster Selector list.

[0059] Then, observe the status of the migration task CRD instance, backup task CRD instance, and K8S cluster CRD instance in the cluster-old cluster; after the backup task CRD instance changes to the completed status, check the object storage generated by the backup in the object storage system;

[0060] Secondly, after the K8S cluster CRD instance becomes normal, check whether the K8S cluster exists on the 192.168.73.36 host.

[0061] Finally, after the migration task CRD instance changes to the completed state, check the namespaces and resources in cluster-new1 and cluster-new2 to see if they are consistent with those in cluster-old.

[0062] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.

Claims

1. A Kubernetes cluster automatic migration method, Features: It includes the following specific steps: S1: backup task CRD; S2: restore task CRD; S3: Migration task CRD; S4: K8S cluster CRD; S5: Operator management component; By establishing and maintaining the CRD instances corresponding to these CRDs, the K8S cluster resource migration task is completed.

2. A Kubernetes cluster automatic migration method according to claim 1, Features: Install it into the K8S cluster as a plug-in, specify external object storage through installation parameters, or use self-built object storage.

3. A Kubernetes cluster automatic migration method according to claim 2, Features: The K8S installation process includes the following specific steps: A1: Create backup task CRD, recovery task CRD, migration task CRD, K8S cluster CRD, and migration management Operator; A2: If no external object storage is specified, create a local object storage system; A3: Create a migration capability component load, which includes the K8S cluster backup and recovery tool; A4: Create a K8S deployment capability component load, which includes the scripts and cross-host architecture resources required for K8S deployment.

4. A Kubernetes cluster automatic migration method according to claim 3, Features: The migration task CRD includes the following specific steps: S31: Create a CRD instance of the destination K8S cluster for migration: specify the destination K8S cluster, node host list, and whether to automatically create a K8S cluster identifier; S32: Create a migration task CRD instance. The key configuration parameters are: namespace Selector, resource type Selector, and target K8S cluster Selector. That is, specify which resources need to be migrated to which K8S clusters. After creation, the migration management operator monitors the migration task CRD instance and completes the migration task through the management component. S33: Migration management Operator, responsible for monitoring and managing migration task CRD instances. First, it parses out the necessary resources that need to be migrated, generates backup task CRD instances and recovery task CRD instances; second, it parses out the K8S cluster that needs to be migrated, installs backup and recovery tools, and restores resources in the destination cluster. If the destination cluster is a K8S cluster to be automatically created, the K8S cluster will be created by the K8S deployment capability component.

5. A Kubernetes cluster automatic migration system according to any one of claims 1 to 4, Features: The system includes a migration capability component load, which is responsible for implementing resource backup of the original K8S cluster. According to the resources to be backed up specified in the migration task CRD instance, the K8S cluster resource backup tool is used to back up the cluster resources and save them to object storage, so that the backup task CRD instance is updated to the completed status and the migration task CRD instance is updated to the backed up status.

6. A Kubernetes cluster automatic migration system according to claim 5, Features: The K8S deployment component load is responsible for creating a new K8S cluster and automatically completes the following key steps: a: Check the host architecture and operating system type; b: Install the appropriate Docker according to the detected host type parameters; c: Install the K8S program that adapts to the host architecture; d: After creating a K8S cluster with a cross-host architecture, update the status of the K8S cluster CRD instance to normal.

7. A Kubernetes cluster automatic migration system according to claim 6, Features: Migrate the capability component load, implement resource recovery for the destination K8S cluster, use the K8S cluster resource recovery tool to restore resources from the object storage to the destination K8S cluster, and update the recovery task CRD instance and migration task CRD instance to the completed status.

8. A Kubernetes cluster automatic migration system according to claim 7, Features: The namespace Selector is a list of namespace names that can be specified, and all namespaces are set by default. The resource type Selector is a specified K8S resource type, such as load, service, and pod, and all resource types are set by default.

9. A Kubernetes cluster automatic migration system according to claim 8, Features: The operating system types support arm64 and x86 architectures, and support centos, kylin, Tongxin, and Euler operating systems.

10. A Kubernetes cluster automatic migration system according to claim 9, Features: The CRD is a Custom Resource Definition.