Resource migration method, device, processor and electronic device
By detecting the service capabilities of the target cluster and using grayscale migration strategies, the k8s cluster resources are gradually migrated, which solves the problems of low migration automation and long service interruption time in the existing technology, and realizes the hot migration of k8s cluster resources.
Patent Information
- Application Number
- CN202210591057.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-27
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2042-05-27
AI Technical Summary
The existing k8s cluster migration technology has low automation and poor versatility, and cannot achieve hot migration of cluster resources, resulting in long service interruption time.
By obtaining migration requests, we can detect whether the target cluster can provide services, determine the migration progress, use grayscale migration strategies and cloud storage devices to copy and restore resources, and gradually migrate request traffic.
It improves the automation and universality of k8s cluster migration, reduces service interruption time, and realizes the hot migration of cluster resources.
Smart Images

Figure CN114816764B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to a field, and in particular, to a resource migration method, device, processor and electronic device. Background Art
[0002] K8s cluster migration is a common demand scenario in PaaS cloud operation and maintenance. In scenarios such as infrastructure changes, K8s upgrades, and technical architecture transformation, there will be a need for K8s cluster migration. Generally, K8s cluster migration mainly refers to recreating K8s resources in the source cluster in the target cluster. In addition to the migration of K8s resources, the migration of cluster traffic is equally important. In actual migration scenarios, applications hope that the service interruption time caused by migration to the business will be as short as possible.
[0003] Most of the existing k8s cluster migration technical solutions are based on the redeployment of cluster resources, that is, redeploying cluster resources in the target cluster according to the original deployment mode of the source cluster k8s resources. This technical solution generally requires sorting out the source cluster k8s resource list and ownership, sorting out the k8s resource creation logic, formulating and integrating the migration plan of each k8s resource, and formulating and integrating the emergency fallback plan of each k8s resource migration.
[0004] The k8s cluster migration technology solution based on cluster resource redeployment has the disadvantages of low automation, long closed loop, and poor versatility. Since the core idea of this solution is to execute the original cluster resource deployment steps in the target cluster as is to achieve the effect of cluster migration, but since the k8s cluster is an infrastructure shared by multiple users, this will result in each user providing their own migration and fallback solutions, and the cloud platform operation and maintenance personnel will integrate them, which increases the uncertainty of migration. In addition, since each cluster deploys different resources and involves different applications, the migration solution varies from cluster to cluster and has poor versatility. Finally, the migration of cluster traffic is not considered, which will lead to the interruption of external service of applications during cluster migration.
[0005] Currently, no effective solution has been proposed to solve the problem that resources in a cluster cannot be hot migrated in related technologies. Summary of the invention
[0006] The main purpose of the present application is to provide a resource migration method, device, processor and electronic device to solve the problem in the related art that resources in a cluster cannot be hot migrated.
[0007] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a resource migration method is provided. The method includes: obtaining a migration request for migrating multiple resources to be migrated in the original cluster; responding to the migration request, performing an operation of migrating the multiple resources to be migrated in the original cluster to the target cluster; in the process of migrating the multiple resources to be migrated in the original cluster to the target cluster, if it is detected that there is a target resource that can provide external services in the target cluster, then determining the migration information of the target resource, wherein the multiple resources to be migrated include the target resource, and the migration information is used to indicate the migration progress of the target resource relative to the multiple resources to be migrated; migrating the request traffic of the original cluster to the target cluster according to the migration information, wherein the request traffic is provided by the target resource.
[0008] Optionally, in response to the migration request, performing the operation of migrating the multiple resources to be migrated in the original cluster to the target cluster includes: copying the multiple resources to be migrated in the original cluster to a cloud storage device; and restoring the multiple resources to be migrated received by the cloud storage device to the target cluster.
[0009] Optionally, in response to the migration request, executing the operation of migrating the multiple resources to be migrated in the original cluster to the target cluster includes: checking whether the calling interfaces of the original cluster and the target cluster are successfully connected to the cloud storage device; in the case where the calling interfaces of the original cluster and the target cluster are successfully connected to the cloud storage device, identifying the task type indicated by the migration request, wherein the task types include: resource copy task and resource recovery task; in the case where the task type is the resource copy task, copying the multiple resources to be migrated in the original cluster to the cloud storage device; in the case where the task type is the resource recovery task, restoring the multiple resources to be migrated received by the cloud storage device to the target cluster.
[0010] Optionally, in response to the migration request, migrating the resources in the original cluster to the target cluster includes: identifying the migration parameters in the migration request, wherein the migration parameters include at least: a migration address, a migration resource namespace, and a migration resource type; configuring the connection between the original cluster and the target cluster according to the migration address; determining a plurality of resources to be migrated that require resource migration from the original cluster according to the migration resource namespace or the migration resource type; and migrating the resources to be migrated to the target cluster.
[0011] Optionally, in response to the migration request, migrating resources in the original cluster to the target cluster includes: responding to the migration request, identifying the dependency relationship between multiple resources to be migrated in the original cluster; determining the migration order of the multiple resources to be migrated based on the dependency relationship; and migrating the multiple resources to be migrated in the original cluster to the target cluster according to the migration order.
[0012] Optionally, migrating the request traffic of the original cluster to the target cluster according to the migration information includes: determining a grayscale ratio according to the migration information, wherein the grayscale ratio is used to represent the ratio of the target resource amount of the target resource to the total migration resource amount, and the total migration resource amount is the resource amount of multiple resources to be migrated in the original cluster before the migration starts; determining the migration ratio of the request traffic according to the grayscale ratio; and migrating the request traffic of the original cluster to the target cluster based on the migration ratio.
[0013] Optionally, migrating the request traffic of the original cluster to the target cluster according to the migration information includes: determining the grayscale time according to the migration information, wherein the grayscale time is used to represent the migration time of migrating multiple resources to be migrated from the original cluster to the target cluster; when the grayscale time exceeds a predetermined time threshold, migrating all request traffic of the original cluster to the target cluster.
[0014] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a resource migration device is provided. The device includes: an acquisition unit, which is used to acquire a migration request for migrating multiple resources to be migrated in the original cluster; an execution unit, which is used to respond to the migration request and execute the operation of migrating the multiple resources to be migrated in the original cluster to the target cluster; a determination unit, which is used to determine the migration information of the target resource if it is detected that there is a target resource that can provide external services in the target cluster during the process of migrating the multiple resources to be migrated in the original cluster to the target cluster, wherein the multiple resources to be migrated include the target resource, and the migration information is used to indicate the migration progress of the target resource relative to the multiple resources to be migrated; a migration unit, which is used to migrate the request traffic of the original cluster to the target cluster according to the migration information, wherein the request traffic is provided by the target resource.
[0015] In order to achieve the above object, according to another aspect of the present application, a processor is provided. The processor is used to run a program, wherein the program executes the above resource migration method when it is run.
[0016] In order to achieve the above-mentioned purpose, according to another aspect of the present application, an electronic device is provided. The electronic device includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the above-mentioned resource migration method.
[0017] Through this application, the following steps are adopted: obtaining a migration request for migrating multiple resources to be migrated in the original cluster; responding to the migration request, executing the operation of migrating multiple resources to be migrated in the original cluster to the target cluster; in the process of migrating multiple resources to be migrated in the original cluster to the target cluster, if it is detected that there is a target resource that can provide external services in the target cluster, then determining the migration information of the target resource, wherein the migration information is used to indicate the migration progress of the target resource relative to the multiple resources to be migrated; migrating the request traffic of the original cluster to the target cluster according to the migration information, wherein the request traffic is provided by the target resource, solving the problem that the resources in the cluster cannot be hot migrated in the related technology. Thus, the effect of hot migration of resources in the cluster is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0019] Figure 1 is a flow chart of a resource migration method provided according to an embodiment of the present application;
[0020] Figure 2 is a schematic diagram of a resource migration solution provided according to an embodiment of the present application;
[0021] Figure 3 It is a schematic diagram of executing resource copy and resource recovery provided according to an embodiment of the present application;
[0022] Figure 4 is a schematic diagram of traffic migration provided according to an embodiment of the present application;
[0023] Figure 5 is a schematic diagram of a resource migration device provided according to an embodiment of the present application;
[0024] Figure 6 It is a schematic diagram of an electronic device provided according to an embodiment of the present application. DETAILED DESCRIPTION
[0025] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0026] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] It should be noted that the relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties. For example, an interface is set between this system and the relevant user or organization. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or organization.
[0029] The present invention is described below in conjunction with preferred implementation steps. Figure 1 is a flow chart of a resource migration method provided according to an embodiment of the present application, such as Figure 1 As shown, the method comprises the following steps:
[0030] Step S102, obtaining a migration request for migrating a plurality of resources to be migrated in the original cluster;
[0031] Step S104, responding to the migration request, performing an operation of migrating multiple resources to be migrated in the original cluster to the target cluster;
[0032] Step S106, in the process of migrating the multiple resources to be migrated in the original cluster to the target cluster, if it is detected that there is a target resource that can provide external services in the target cluster, then determine the migration information of the target resource, wherein the multiple resources to be migrated include the target resource, and the migration information is used to indicate the migration progress of the target resource relative to the multiple resources to be migrated;
[0033] Step S108: Migrate the request traffic of the original cluster to the target cluster according to the migration information, wherein the request traffic is served by the target resources.
[0034] Through this application, the following steps are adopted: obtaining a migration request for migrating multiple resources to be migrated in the original cluster; responding to the migration request, executing the operation of migrating multiple resources to be migrated in the original cluster to the target cluster; in the process of migrating multiple resources to be migrated in the original cluster to the target cluster, if it is detected that there is a target resource that can provide external services in the target cluster, then determining the migration information of the target resource, wherein the migration information is used to indicate the migration progress of the target resource relative to the multiple resources to be migrated; migrating the request traffic of the original cluster to the target cluster according to the migration information, wherein the request traffic is provided by the target resource, solving the problem that the resources in the cluster cannot be hot migrated in the related technology. Thus, the effect of hot migration of resources in the cluster is achieved.
[0035] The cluster in the above steps S102 to S108 can be a k8s cluster, that is, the original cluster and the target cluster are both k8s clusters; the above steps are used to migrate resources in the original k8s cluster to the target k8s cluster.
[0036] In the above step S106, the process of migrating multiple resources to be migrated in the original cluster to the target cluster can adopt a grayscale migration strategy, wherein the grayscale migration strategy refers to splitting the multiple services supported by the multiple resources to be migrated and then migrating them one by one. Therefore, during the migration process, as long as the resources to be migrated that support a certain service are migrated, the services supported by the migrated resources can be used, without having to wait for the multiple resources to be migrated to be completely migrated before starting to use the migrated resources.
[0037] For example, when multiple resources to be migrated in the original cluster support service A, service B, and service C, grayscale migration means: first transmit the resources to be migrated corresponding to service A, then transmit the resources to be migrated corresponding to service B, and finally transmit the resources to be migrated corresponding to service C; during the transmission period, if the resources to be migrated of service A complete the migration, the target cluster can immediately use the migrated resources to execute service A; while the traditional migration solution requires that all the resources to be migrated in the original cluster complete the migration before the services in it can be used.
[0038] In the above step S104, in the process of migrating multiple resources to be migrated in the original cluster to the target cluster, a cloud storage device can be used as an intermediate device between the original cluster and the target cluster. The cloud storage device copies the files to be migrated from the original cluster and then restores the files to be migrated in the cloud storage device to the target cluster.
[0039] Optionally, in the resource migration method provided in an embodiment of the present application, in response to a migration request, the operation of migrating multiple resources to be migrated in the original cluster to the target cluster includes: copying the multiple resources to be migrated in the original cluster to a cloud storage device; and restoring the multiple resources to be migrated received by the cloud storage device to the target cluster.
[0040] It should be noted that cloud storage devices are used to store the original files of the resources to be transferred in the original cluster. The migration tool currently supports object storage cloud storage services, including object storage services of mainstream public cloud vendors such as AWS, GCP, and Azure. In addition, it also supports any object storage compatible with the Amazon S3 interface.
[0041] Figure 2 is a schematic diagram of a resource migration solution provided according to an embodiment of the present application, such as Figure 2 As shown, a migration tool is provided in the cluster, and the migration tool executes the copying and recovery functions of resources. In the case where the cluster is a k8s cluster, the original cluster is the original k8s cluster 2022, and the target cluster is the target k8s cluster 2042. The migration tool in the original cluster is the first migration tool 2024 for executing the copy function, and the migration tool in the target cluster is the second migration tool 2044 for executing the recovery function.
[0042] Alternatively, if Figure 2 As shown, the original cluster is connected to the cloud storage device 206 via the first migration tool 2024, which is used to copy multiple resources to be migrated in the original cluster to the cloud storage device, and the target cluster is connected to the cloud storage device 206 via the second migration tool 2044, which is used to copy multiple resources to be migrated in the cloud storage device to the target cluster.
[0043] Alternatively, if Figure 2 As shown, the resource migration solution also includes a migration management module 208 connected to the original cluster and the target cluster, wherein the migration management module is a control module for cluster migration, and mainly provides capabilities such as cluster resource migration 2082, cluster traffic migration 2084, and cluster migration monitoring 2086.
[0044] Optionally, the migration tool mainly provides the copying and recovery functions of k8s resources, that is, during the migration process, the migration tool is first used to complete the copying of k8s resources in the source cluster, and then the k8s resources are restored in the target cluster, thereby completing the migration of k8s resources.
[0045] Optionally, the migration tool needs to be deployed in both the source k8s cluster and the target k8s cluster, and is called by the migration management module to perform operations such as resource copying and resource recovery according to the calling parameters.
[0046] Optionally, in the resource migration method provided in the embodiment of the present application, in response to the migration request, executing the operation of migrating multiple resources to be migrated in the original cluster to the target cluster includes: checking whether the calling interfaces of the original cluster and the target cluster are successfully connected to the cloud storage device; in the case that the calling interfaces of the original cluster and the target cluster are successfully connected to the cloud storage device, identifying the task type indicated by the migration request, wherein the task types include: resource copy task and resource recovery task; in the case that the task type is a resource copy task, copying the multiple resources to be migrated in the original cluster to the cloud storage device; in the case that the task type is a resource recovery task, restoring the multiple resources to be migrated received by the cloud storage device to the target cluster.
[0047] Optionally, the calling interface can be the kube-apiserver interface in the k8s cluster.
[0048] In the above-mentioned embodiment of the present invention, the migration request is used to indicate the task type of the migration task, wherein the task type of the migration request can be divided into a resource copy task and a resource recovery task. The resource copy task is executed by the original cluster, and multiple resources to be migrated in the original cluster are copied to the cloud storage device; the resource recovery task is executed by the target cluster, and multiple resources to be migrated received by the cloud storage device are restored to the target cluster, so that the resource copy task and the resource recovery task can be executed by the original cluster and the target cluster respectively, thereby realizing reasonable allocation of resource migration tasks.
[0049] Figure 3 is a schematic diagram of executing resource copy and resource recovery according to an embodiment of the present application, such as Figure 3 As shown, the following steps are included:
[0050] S301: Receive a migration request sent by a migration management module.
[0051] S302, execute the health check logic of the migration tool, mainly to check whether the cloud storage device is successfully connected and whether the kube-apiserver of the k8s cluster is successfully connected. If any of the cloud storage and kube-apiserver fails to connect, an error is returned and the request processing ends.
[0052] S303, judging whether a resource copy or resource recovery task needs to be executed according to the migration parameters of the migration request, if it is a resource copy task, executing step S304, if it is a resource import task, executing step S314.
[0053] S304: If it is a resource copy task, query the kube-apiserver for all resources in the cluster (ie, resources to be migrated), and upload the original files of all resources (ie, resources to be migrated) to the cloud storage device.
[0054] S305, determining whether the resource copy task is completed, or determining whether the resource copy task has timed out, if so, then the process ends, otherwise, returning to step S304 based on executing the resource copy task.
[0055] S314, if it is a resource recovery task, the original file of the k8s resource is obtained from the cloud storage device, and the kube-apiserver of the target cluster is called to restore all k8s resources (ie, resources to be migrated).
[0056] S315, determine whether the resource recovery task is completed, or determine whether the resource recovery task has timed out. If so, end it; otherwise, return to step S314 based on executing the resource recovery task.
[0057] It should be noted that kube-apiserver is one of the most important cores of k8s. Its main functions include: - providing a rest api interface for cluster management, including authentication and authorization, data verification, and primary cluster status changes; providing data interaction and communication with other modules. Among them, only the api server can directly operate the etcd database.
[0058] Alternatively, if Figure 2 As shown, the migration management module includes: a cluster resource migration module, a cluster traffic migration module, and a cluster migration monitoring module.
[0059] Alternatively, if Figure 2 As shown, the cluster resource migration module provides the management capability of resource migration tasks, mainly including: configuration of resource migration parameters and scheduling of resource migration tasks.
[0060] Optionally, in the resource migration method provided in an embodiment of the present application, responding to a migration request and migrating resources in an original cluster to a target cluster includes: identifying migration parameters in the migration request, wherein the migration parameters include at least: a migration address, a migration resource namespace, and a migration resource type; configuring the original cluster and the target cluster to be connected according to the migration address; determining, from the original cluster according to the migration resource namespace or the migration resource type, a plurality of resources to be migrated that require resource migration; and migrating the resources to be migrated to the target cluster.
[0061] Optionally, the migration parameters also include: a cloud storage address of the cloud storage device.
[0062] In the above-mentioned embodiments of the present invention, the addresses of the original cluster and the target cluster are indicated by migration parameters in the migration request to determine the device cluster that needs to perform resource migration; the resources to be migrated that need to be migrated are indicated by the migration resource namespace or the migration resource type to realize the selection of the resources to be migrated; thus, the resources to be migrated can be specified according to the migration resource namespace or the migration resource type according to the actual scenario requirements, thereby improving the flexibility of cluster migration.
[0063] Optionally, the configuration of resource migration parameters is used to configure migration parameters, where the migration parameters are shown in Table 1. By migrating the resource namespace and migrating the resource type parameters, specific k8s resources can be specified for migration according to actual scenario requirements, thereby improving the flexibility of cluster migration.
[0064] Parameter name Parameter Value illustrate Task Type Copy / Restore / Cloud storage address xx.xx.xx.xx Cloud storage service address kube-apiserver address xx.xx.xx.xx kube-apiserver service address Migrating resource namespaces demo-namespaces Specify the migration of a namespace resource Migrate resource types configmap Specify the migration of a certain type of resources
[0065] Table 1
[0066] Optionally, in the resource migration method provided in an embodiment of the present application, responding to a migration request and migrating resources in an original cluster to a target cluster includes: responding to the migration request and identifying dependencies between multiple resources to be migrated in the original cluster; determining a migration order of multiple resources to be migrated based on the dependencies; and migrating multiple resources to be migrated in the original cluster to the target cluster according to the migration order.
[0067] Optionally, the orchestration of resource migration tasks enables the control of the migration order of resources to be migrated. In a multi-cloud scenario, a service is sometimes provided by applications deployed in multiple different k8s clusters, which are mutually dependent. The orchestration of resource migration tasks can be used to migrate multiple clusters in the required order.
[0068] Optionally, in the resource migration method provided in an embodiment of the present application, migrating the request traffic of the original cluster to the target cluster according to the migration information includes: determining a grayscale ratio according to the migration information, wherein the grayscale ratio is used to represent the ratio of the target resource amount of the target resource to the total migration resource amount, and the total migration resource amount is the resource amount of multiple resources to be migrated in the original cluster before the migration starts; determining the migration ratio of the request traffic according to the grayscale ratio; and migrating the request traffic of the original cluster to the target cluster based on the migration ratio.
[0069] In the above-mentioned embodiments of the present invention, the grayscale ratio refers to the ratio of the target resource amount of the target resource to the total migration resource amount of all resources to be migrated in the original cluster. According to the grayscale ratio, the request traffic can be determined, and part of the request traffic executed in the original cluster can be migrated to the target cluster for execution, thereby achieving the technical effect of hot migration of resources in the cluster.
[0070] Optionally, in the resource migration method provided in an embodiment of the present application, migrating the request traffic of the original cluster to the target cluster according to the migration information includes: determining the grayscale time according to the migration information, wherein the grayscale time is used to represent the migration time of migrating multiple resources to be migrated from the original cluster to the target cluster; when the grayscale time exceeds a predetermined time threshold, all request traffic of the original cluster is migrated to the target cluster.
[0071] In the above-mentioned embodiment of the present invention, the predetermined time threshold is a pre-set total migration time required to migrate all resources to be migrated in the original cluster to the target cluster. Furthermore, when the grayscale time exceeds the predetermined time threshold, it indicates that all resources in the original cluster have been migrated to the target cluster, and all request traffic executed by the original cluster is migrated to the target cluster.
[0072] Alternatively, if Figure 2 As shown, the cluster traffic migration module mainly provides the ability to migrate application traffic (ie, request traffic) during the cluster migration process, and realizes hot migration of the cluster in combination with cluster resource migration.
[0073] Optionally, the parameters involved in the cluster traffic migration task are shown in Table 2. The traffic migration instance can be specified by configuring the service name, and the grayscale strategy of traffic switching can be specified by the grayscale ratio and grayscale time.
[0074] Parameter name Parameter Value illustrate Service Name Mysql-0010 Name of the traffic service instance to be migrated Service domain name http: / / mysql:8080 Domain name for external service access Health Check Probes http: / / healthy:2020 Used to check whether the service is healthy Grayscale ratio 20% Traffic migration grayscale ratio Gray Time 30min Traffic migration grayscale time
[0075] Table 2
[0076] Figure 4 is a schematic diagram of a traffic migration provided according to an embodiment of the present application, such as Figure 4 As shown, the following steps are included:
[0077] S401, receiving a migration management module request.
[0078] S402, query whether the specified service instance (ie, target resource) in the target k8s cluster is ready, that is, whether the recovery is successful. If not, retry; if ready, execute step S403.
[0079] S403, calling the service health check probe to check whether the application of the target resource can provide external services. If the health check fails, retry; if the check succeeds, execute step S404.
[0080] S404, calling DNS to modify the domain name resolution configuration, and migrating a portion of the request traffic to the target cluster application according to the grayscale ratio.
[0081] S405, checking whether the grayscale time has timed out (ie, checking whether the grayscale time has exceeded a predetermined time threshold), if so, executing step S406, if not, returning to step S404.
[0082] S406, calling DNS to modify the domain name resolution configuration, and migrating all request traffic to the target cluster application.
[0083] Alternatively, if Figure 2 As shown in the figure, the cluster migration monitoring module mainly displays the monitoring indicators during the cluster migration process. Among them, the monitoring indicators are divided into two categories. One is the monitoring indicators of cluster resource migration, which mainly include: the total amount of cluster resource migration, the total amount of migrated resources, the migration time, etc.; the other is the monitoring indicators of cluster traffic migration, which mainly include: traffic migration progress, the success rate of requests during traffic migration grayscale, request time, etc.
[0084] Compared with the existing k8s cluster migration technology, the present invention has the advantages of high automation and strong versatility. By connecting to kube-apiserver and cloud storage, highly automated cluster resource copying and recovery capabilities are achieved, the migration logic is coded, and the migration efficiency is improved. And compared with the existing k8s cluster migration technology, the present invention has the advantages of little impact on the business and uninterrupted external services. By adding a cluster traffic migration mechanism, application traffic is migrated while cluster resources are migrated, and the stability of traffic migration is ensured through a grayscale strategy, the ability of cluster hot migration is realized; thereby overcoming the shortcomings of the existing k8s cluster migration technology, such as low automation, poor versatility, and inability to guarantee application business continuity.
[0085] The resource migration method provided in the embodiment of the present application obtains a migration request for migrating multiple resources to be migrated in the original cluster; responds to the migration request, and performs an operation of migrating multiple resources to be migrated in the original cluster to the target cluster; in the process of migrating multiple resources to be migrated in the original cluster to the target cluster, if it is detected that there is a target resource that can provide external services in the target cluster, the migration information of the target resource is determined, wherein the migration information is used to indicate the migration progress of the target resource relative to the multiple resources to be migrated; according to the migration information, the request traffic of the original cluster is migrated to the target cluster, wherein the request traffic is provided by the target resource, thereby solving the problem that the resources in the cluster cannot be hot migrated in the related technology. Thus, the effect of hot migration of resources in the cluster is achieved.
[0086] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0087] The embodiment of the present application also provides a resource migration device. It should be noted that the resource migration device of the embodiment of the present application can be used to execute the resource migration method provided by the embodiment of the present application. The resource migration device provided by the embodiment of the present application is introduced below.
[0088] Figure 5 Schematic diagram of a resource migration device according to an embodiment of the present application. Figure 5 As shown, the device includes: an acquisition unit 52, used to acquire a migration request for migrating multiple resources to be migrated in the original cluster; an execution unit 54, used to respond to the migration request and execute the operation of migrating the multiple resources to be migrated in the original cluster to the target cluster; a determination unit 56, used to determine the migration information of the target resource if it is detected that there is a target resource that can provide external services in the target cluster during the process of migrating the multiple resources to be migrated in the original cluster to the target cluster, wherein the multiple resources to be migrated include the target resource, and the migration information is used to indicate the migration progress of the target resource relative to the multiple resources to be migrated; a migration unit 58, used to migrate the request traffic of the original cluster to the target cluster according to the migration information, wherein the request traffic is provided by the target resource.
[0089] The resource migration method provided in the embodiment of the present application obtains a migration request for migrating multiple resources to be migrated in the original cluster; responds to the migration request, and performs an operation of migrating multiple resources to be migrated in the original cluster to the target cluster; in the process of migrating multiple resources to be migrated in the original cluster to the target cluster, if it is detected that there is a target resource that can provide external services in the target cluster, the migration information of the target resource is determined, wherein the migration information is used to indicate the migration progress of the target resource relative to the multiple resources to be migrated; according to the migration information, the request traffic of the original cluster is migrated to the target cluster, wherein the request traffic is provided by the target resource, thereby solving the problem that the resources in the cluster cannot be hot migrated in the related technology. Thus, the effect of hot migration of resources in the cluster is achieved.
[0090] Optionally, in the resource migration device provided in the embodiment of the present application, the execution unit includes: a copy module for copying multiple resources to be migrated in the original cluster to the cloud storage device; and a recovery module for restoring the multiple resources to be migrated received by the cloud storage device to the target cluster.
[0091] Optionally, in the resource migration device provided in the embodiment of the present application, the execution unit includes: an inspection module, used to check whether the calling interface of the original cluster and the target cluster is successfully connected to the cloud storage device; a first identification module, used to identify the task type indicated by the migration request when the calling interface of the original cluster and the target cluster is successfully connected to the cloud storage device, wherein the task types include: resource copy task and resource recovery task; a first execution module, used to copy multiple resources to be migrated in the original cluster to the cloud storage device when the task type is a resource copy task; and a second execution module, used to restore the multiple resources to be migrated received by the cloud storage device to the target cluster when the task type is a resource recovery task.
[0092] Optionally, in the resource migration device provided in the embodiment of the present application, the execution unit includes: a second identification module, used to identify the migration parameters in the migration request, wherein the migration parameters include at least: a migration address, a migration resource namespace and a migration resource type; a docking module, used to configure the docking of the original cluster and the target cluster according to the migration address; a first determination module, used to determine a plurality of resources to be migrated that need to be migrated from the original cluster according to the migration resource namespace or the migration resource type; and a third execution module, used to migrate the resources to be migrated to the target cluster.
[0093] Optionally, in the resource migration device provided in the embodiment of the present application, the execution unit includes: a third identification module, used to respond to the migration request and identify the dependency relationship between multiple resources to be migrated in the original cluster; a second determination module, used to determine the migration order of multiple resources to be migrated according to the dependency relationship; and a fourth execution module, used to migrate the multiple resources to be migrated in the original cluster to the target cluster according to the migration order.
[0094] Optionally, in the resource migration device provided in the embodiment of the present application, the migration unit includes: a third determination module, used to determine the grayscale ratio based on the migration information, wherein the grayscale ratio is used to represent the ratio of the target resource amount of the target resource to the total migration resource amount, and the total migration resource amount is the resource amount of multiple resources to be migrated in the original cluster before the migration starts; a fourth determination module, used to determine the migration ratio of the request traffic based on the grayscale ratio; and a first migration module, used to migrate the request traffic of the original cluster to the target cluster based on the migration ratio.
[0095] Optionally, in the resource migration device provided in the embodiment of the present application, the migration unit includes: a fifth determination module, used to determine the grayscale time based on the migration information, wherein the grayscale time is used to represent the migration time of migrating multiple resources to be migrated from the original cluster to the target cluster; a second migration module, used to migrate all request traffic of the original cluster to the target cluster when the grayscale time exceeds a predetermined time threshold.
[0096] The resource migration device provided in the embodiment of the present application obtains a migration request for migrating multiple resources to be migrated in the original cluster; responds to the migration request, and executes the operation of migrating the multiple resources to be migrated in the original cluster to the target cluster; in the process of migrating the multiple resources to be migrated in the original cluster to the target cluster, if it is detected that there are target resources that can provide external services in the target cluster, the migration information of the target resource is determined, wherein the migration information is used to indicate the migration progress of the target resource relative to the multiple resources to be migrated; according to the migration information, the request traffic of the original cluster is migrated to the target cluster, wherein the request traffic is served by the target resource, thereby solving the problem in the related technology that the resources in the cluster cannot be hot migrated, thereby achieving the effect of hot migration of the resources in the cluster.
[0097] The resource migration device includes a processor and a memory. The above units are stored in the memory as program units. The processor executes the above program units stored in the memory to realize corresponding functions.
[0098] The processor includes a kernel, which retrieves the corresponding program unit from the memory. The kernel can be set to one or more, and the kernel parameters can be adjusted to achieve the purpose of the present invention.
[0099] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0100] An embodiment of the present invention provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the resource migration method is implemented.
[0101] An embodiment of the present invention provides a processor, which is used to run a program, wherein the resource migration method is executed when the program is running.
[0102] Figure 6 is a schematic diagram of an electronic device provided according to an embodiment of the present application, such as Figure 6As shown, an embodiment of the present invention provides an electronic device 60, the device includes a processor 62, a memory, and a program stored in the memory 64 and executable on the processor, and the processor implements the following steps when executing the program: obtaining a migration request for migrating multiple resources to be migrated in an original cluster; responding to the migration request, performing an operation of migrating the multiple resources to be migrated in the original cluster to a target cluster; in the process of migrating the multiple resources to be migrated in the original cluster to the target cluster, if it is detected that there are target resources in the target cluster that can provide external services, then determining the migration information of the target resource, wherein the multiple resources to be migrated include the target resource, and the migration information is used to indicate the migration progress of the target resource relative to the multiple resources to be migrated; migrating the request traffic of the original cluster to the target cluster according to the migration information, wherein the request traffic is served by the target resource.
[0103] Optionally, when the processor executes the program, the following steps are implemented: copying the multiple resources to be migrated in the original cluster to the cloud storage device; and restoring the multiple resources to be migrated received by the cloud storage device to the target cluster.
[0104] Optionally, the processor implements the following steps when executing the program: identifying migration parameters in the migration request, wherein the migration parameters include at least: a migration address, a migration resource namespace, and a migration resource type; configuring the connection between the original cluster and the target cluster according to the migration address; determining multiple resources to be migrated that require resource migration from the original cluster according to the migration resource namespace or the migration resource type; and migrating the resources to be migrated to the target cluster.
[0105] Optionally, the processor implements the following steps when executing the program: checking whether the calling interfaces of the original cluster and the target cluster are successfully connected to the cloud storage device; if the calling interfaces of the original cluster and the target cluster are successfully connected to the cloud storage device, identifying the task type indicated by the migration request, wherein the task types include: resource copy task and resource recovery task; if the task type is a resource copy task, copying multiple resources to be migrated in the original cluster to the cloud storage device; if the task type is a resource recovery task, restoring multiple resources to be migrated received by the cloud storage device to the target cluster.
[0106] Optionally, when executing the program, the processor implements the following steps: responding to a migration request, identifying dependencies between multiple resources to be migrated in the original cluster; determining a migration order of the multiple resources to be migrated based on the dependencies; and migrating the multiple resources to be migrated in the original cluster to the target cluster according to the migration order.
[0107] Optionally, the processor implements the following steps when executing the program: determining a grayscale ratio based on migration information, wherein the grayscale ratio is used to represent the ratio of the target resource amount of the target resource to the total migration resource amount, and the total migration resource amount is the resource amount of multiple resources to be migrated in the original cluster before the migration starts; determining the migration ratio of the request traffic based on the grayscale ratio; and migrating the request traffic of the original cluster to the target cluster based on the migration ratio.
[0108] Optionally, the processor implements the following steps when executing the program: determining the grayscale time based on the migration information, wherein the grayscale time is used to represent the migration time of migrating multiple resources to be migrated from the original cluster to the target cluster; when the grayscale time exceeds a predetermined time threshold, all request traffic of the original cluster is migrated to the target cluster.
[0109] The electronic devices in this article can be servers, PCs, PADs, mobile phones, etc.
[0110] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that initializes the following method steps: obtaining a migration request for migrating multiple resources to be migrated in an original cluster; responding to the migration request, performing an operation of migrating the multiple resources to be migrated in the original cluster to a target cluster; in the process of migrating the multiple resources to be migrated in the original cluster to the target cluster, if it is detected that there are target resources in the target cluster that can provide external services, then determining the migration information of the target resource, wherein the multiple resources to be migrated include the target resource, and the migration information is used to indicate the migration progress of the target resource relative to the multiple resources to be migrated; migrating the request traffic of the original cluster to the target cluster according to the migration information, wherein the request traffic is provided by the target resource.
[0111] Optionally, when executed on a data processing device, it is suitable for executing a program that initializes the following method steps: copying multiple resources to be migrated in the original cluster to a cloud storage device; and restoring the multiple resources to be migrated received by the cloud storage device to a target cluster.
[0112] Optionally, when executed on a data processing device, the program is suitable for executing initialization having the following method steps: identifying migration parameters in a migration request, wherein the migration parameters include at least: a migration address, a migration resource namespace, and a migration resource type; configuring the connection between the original cluster and the target cluster according to the migration address; determining a plurality of resources to be migrated that require resource migration from the original cluster according to the migration resource namespace or the migration resource type; and migrating the resources to be migrated to the target cluster.
[0113] Optionally, when executed on a data processing device, the program is suitable for executing initialization with the following method steps: checking whether the calling interfaces of the original cluster and the target cluster are successfully connected to the cloud storage device; in the case that the calling interfaces of the original cluster and the target cluster are successfully connected to the cloud storage device, identifying the task type indicated by the migration request, wherein the task types include: resource copy task and resource recovery task; in the case that the task type is a resource copy task, copying multiple resources to be migrated in the original cluster to the cloud storage device; in the case that the task type is a resource recovery task, restoring multiple resources to be migrated received by the cloud storage device to the target cluster.
[0114] Optionally, when executed on a data processing device, the program is suitable for executing initialization having the following method steps: responding to a migration request, identifying dependencies between multiple resources to be migrated in the original cluster; determining a migration order of multiple resources to be migrated based on the dependencies; and migrating multiple resources to be migrated in the original cluster to the target cluster according to the migration order.
[0115] Optionally, when executed on a data processing device, it is suitable for executing an initialization program having the following method steps: determining a grayscale ratio based on migration information, wherein the grayscale ratio is used to represent the ratio of the target resource amount of the target resource to the total migration resource amount, and the total migration resource amount is the resource amount of multiple resources to be migrated in the original cluster before the migration starts; determining the migration ratio of the request traffic based on the grayscale ratio; and migrating the request traffic of the original cluster to the target cluster based on the migration ratio.
[0116] Optionally, when executed on a data processing device, it is suitable for executing an initialization program having the following method steps: determining the grayscale time based on the migration information, wherein the grayscale time is used to represent the migration time of migrating multiple resources to be migrated from an original cluster to a target cluster; when the grayscale time exceeds a predetermined time threshold, all request traffic of the original cluster is migrated to the target cluster.
[0117] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0118] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0119] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0120] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0121] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0122] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0123] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0124] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0125] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0126] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A resource migration method, characterized in that: include: Obtain a migration request for migrating multiple resources to be migrated in the original cluster; In response to the migration request, performing an operation of migrating the plurality of resources to be migrated in the original cluster to the target cluster; In the process of migrating the multiple resources to be migrated in the original cluster to the target cluster, if it is detected that there is a target resource that can provide external services in the target cluster, then determining the migration information of the target resource, wherein the multiple resources to be migrated include the target resource, and the migration information is used to indicate the migration progress of the target resource relative to the multiple resources to be migrated; The request traffic of the original cluster is migrated to the target cluster according to the migration information, wherein the request traffic is served by the target resource.
2. The method according to claim 1, characterized in that In response to the migration request, performing an operation of migrating the plurality of resources to be migrated in the original cluster to the target cluster includes: Copying the plurality of resources to be migrated in the original cluster to a cloud storage device; The plurality of resources to be migrated received by the cloud storage device are restored to the target cluster.
3. The method according to claim 1, characterized in that In response to the migration request, performing an operation of migrating the plurality of resources to be migrated in the original cluster to the target cluster includes: Check whether the calling interfaces of the original cluster and the target cluster are successfully connected to the cloud storage device; In the case that the calling interfaces of the original cluster and the target cluster are successfully connected to the cloud storage device, identifying the task type indicated by the migration request, wherein the task type includes: resource copy task and resource recovery task; When the task type is the resource copy task, copying the plurality of resources to be migrated in the original cluster to the cloud storage device; When the task type is the resource recovery task, the plurality of resources to be migrated received by the cloud storage device are restored to the target cluster.
4. The method according to claim 1, characterized in that: In response to the migration request, migrating resources in the original cluster to the target cluster includes: Identifying migration parameters in the migration request, wherein the migration parameters include at least: a migration address, a migration resource namespace, and a migration resource type; Configure the original cluster and the target cluster to connect according to the migration address; Determining, from the original cluster, a plurality of resources to be migrated that require resource migration according to the migration resource namespace or the migration resource type; Migrate the resources to be migrated to the target cluster.
5. The method according to claim 1, characterized in that In response to the migration request, migrating resources in the original cluster to the target cluster includes: In response to the migration request, identifying dependencies between a plurality of resources to be migrated in the original cluster; Determining a migration order of the plurality of resources to be migrated according to the dependency relationship; Migrate the multiple resources to be migrated in the original cluster to the target cluster according to the migration order.
6. The method according to claim 1, characterized in that Migrating the request traffic of the original cluster to the target cluster according to the migration information includes: Determine a grayscale ratio according to the migration information, wherein the grayscale ratio is used to represent the ratio of the target resource amount of the target resource to the total migration resource amount, and the total migration resource amount is the resource amount of the multiple resources to be migrated in the original cluster before the migration starts; Determining a migration ratio of the request traffic according to the grayscale ratio; The request traffic of the original cluster is migrated to the target cluster according to the migration ratio.
7. The method according to claim 1, characterized in that Migrating the request traffic of the original cluster to the target cluster according to the migration information includes: Determine a grayscale time according to the migration information, wherein the grayscale time is used to represent a migration time for migrating the plurality of resources to be migrated from the original cluster to the target cluster; When the grayscale time exceeds a predetermined time threshold, all request traffic of the original cluster is migrated to the target cluster.
8. A resource migration device, characterized in that: include: An acquisition unit, used for acquiring a migration request for migrating a plurality of resources to be migrated in an original cluster; An execution unit, configured to respond to the migration request and execute an operation of migrating the plurality of resources to be migrated in the original cluster to the target cluster; a determination unit, configured to determine migration information of the target resource if it is detected that there is a target resource that can provide external services in the target cluster during the process of migrating the multiple resources to be migrated in the original cluster to the target cluster, wherein the multiple resources to be migrated include the target resource, and the migration information is used to indicate the migration progress of the target resource relative to the multiple resources to be migrated; A migration unit is used to migrate the request traffic of the original cluster to the target cluster according to the migration information, wherein the request traffic is served by the target resource.
9. A processor, characterized in that: The processor is used to run a program, wherein the program executes the resource migration method described in any one of claims 1 to 7 when running.
10. An electronic device, characterized in that: It includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the resource migration method described in any one of claims 1 to 7.
