Container thermal transfer method and container thermal transfer device
By creating a one-to-one correspondence between a micro-lightweight virtual machine and a container through a custom virtual machine manager, the problem of kernel-mode migration and interference during container hot migration is solved, and the complete migration of the container kernel-mode and runtime mode is achieved, ensuring a fast and seamless migration process.
Patent Information
- Application Number
- CN202210425633.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-21
- Publication Date
- 2026-02-17
- Estimated Expiration
- 2042-04-21
AI Technical Summary
Existing technologies based on Docker container hot migration processes suffer from problems such as mutual interference between containers and the inability to simultaneously handle user-mode and kernel-mode migrations.
A custom virtual machine manager creates a one-to-one correspondence between a miniature, lightweight virtual machine and the container to be migrated. It then obtains and sends memory data and runtime status to the target physical machine. KVM virtualization technology is used to achieve a complete migration of the container's kernel and runtime states, avoiding mutual interference between containers.
It achieves complete migration between container kernel mode and runtime mode, avoids inter-container interference during hot migration, and ensures a fast migration process and a seamless user experience.
Smart Images

Figure CN114968477B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of virtualization, and in particular, to a container live migration method, a container live migration apparatus, a computer readable storage medium and an electronic device. BACKGROUND
[0002] Virtualization is an important basis for cloud computing, and live migration is an important means to improve the utilization rate of physical resources. Docker, an open source application container engine, defines a standardized system for containers from construction to execution, changing the traditional virtualization technology, so the live migration process in the related art is mostly based on Docker containers.
[0003] In the related art, the live migration process based on Docker containers causes mutual interference between containers due to the sharing of hardware resources of the shared physical machine. In addition, there is a problem that the user mode and the kernel mode cannot be considered.
[0004] It should be noted that the information disclosed in the foregoing BACKGROUND section is only used to strengthen the understanding of the background of the present disclosure, and therefore can include information that does not constitute prior art known to those of ordinary skill in the art. SUMMARY
[0005] The purpose of the embodiments of the present disclosure is to provide a container live migration method, a public network IP network state detection system, a computer readable storage medium and an electronic device, thereby solving the problems of the related art that the kernel state cannot be restored and the containers interfere with each other during the live migration of the containers.
[0006] According to a first aspect of the present disclosure, a container live migration method is provided, comprising:
[0007] In response to a container live migration command, determining a first virtual machine on a source physical machine where a to-be-migrated container is located; creating the first virtual machine and the to-be-migrated container through a self-defined virtual machine manager, so that the first virtual machine and the to-be-migrated container correspond one-to-one;
[0008] Obtaining memory data and a running state of the first virtual machine and saving them to a local;
[0009] Sending the memory data and the running state of the first virtual machine to a destination physical machine, so that a second virtual machine on the destination physical machine restores a running process of the to-be-migrated container on the destination physical machine according to the received memory data and running state.
[0010] In an exemplary embodiment of the present disclosure, based on the foregoing scheme, the method further comprises:
[0011] A container live migration sub-command facing the k8s cluster is formed by adding the container live migration command to a container active triggering interface in kubectl, so that the container live migration process is triggered by calling the container live migration sub-command of the container active triggering interface.
[0012] In an exemplary embodiment of the present disclosure, based on the foregoing scheme, the container live migration command contains application information of a container to be migrated, and the first virtual machine on a source physical machine where the container to be migrated is located is determined in response to the container live migration command, including:
[0013] When the source physical machine contains multiple container processes of the application information of the container to be migrated, the container to be migrated is specified among the multiple container processes of the application information through container IP address information or container identification information;
[0014] Based on the one-to-one correspondence between the container to be migrated and the first virtual machine, the first virtual machine corresponding to the container to be migrated is determined.
[0015] In an exemplary embodiment of the present disclosure, based on the foregoing scheme, the method further includes:
[0016] Determining the running environment requirement of the container to be migrated;
[0017] Based on the running environment requirement of the container to be migrated, it is determined whether the destination physical machine meets the running environment requirement of the container to be migrated;
[0018] When the destination physical machine meets the running environment requirement of the container to be migrated, the container live migration command is executed.
[0019] In an exemplary embodiment of the present disclosure, based on the foregoing scheme, the method further includes:
[0020] Pausing the running process of the first virtual machine, reading the current memory data and running state of the first virtual machine and saving them to the local.
[0021] In an exemplary embodiment of the present disclosure, based on the foregoing scheme, the method further includes:
[0022] Pausing the running process of the first virtual machine, sending dirty page data generated in the process of sending the memory data and running state to the destination physical machine, so that the second virtual machine on the destination physical machine runs the container to be migrated according to the dirty page data; the dirty page data includes data changed in the process of running the container to be migrated in the first virtual machine.
[0023] In an exemplary embodiment of the present disclosure, based on the foregoing scheme, the method further includes:
[0024] in response to the container hot migration command, determining whether application information of the container to be migrated exists on the source physical machine;
[0025] when the application information of the container to be migrated exists on the source physical machine, starting a second virtual machine on the destination physical machine, so that the second virtual machine receives memory data and a running state of the first virtual machine, and configures corresponding parameters of the second virtual machine by using the memory data and the running state of the first virtual machine.
[0026] According to a second aspect of the present disclosure, a container hot migration device is provided, comprising:
[0027] a determining module, configured to, in response to a container hot migration command, determine a first virtual machine on a source physical machine where a container to be migrated is located; and create the first virtual machine and the container to be migrated by using a self-defined virtual machine manager, so that the first virtual machine and the container to be migrated are in one-to-one correspondence;
[0028] a obtaining module, configured to obtain memory data and a running state of the first virtual machine and save them to a local;
[0029] a migration module, configured to send the memory data and the running state of the first virtual machine to a destination physical machine, so that a second virtual machine on the destination physical machine recovers a running process of the container to be migrated on the destination physical machine according to the received memory data and running state.
[0030] According to a third aspect of the present disclosure, a computer readable storage medium is provided, which stores a computer program, and the computer program is executed by a processor to implement the method of any one of the above.
[0031] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the method of any one of the above by executing the executable instructions.
[0032] The exemplary embodiments of the present disclosure can have the following partial or all beneficial effects:
[0033] In the container hot migration method provided in the disclosed example embodiment, on the one hand, a first virtual machine and a to-be-migrated container can be created by a self-defined virtual machine manager, so that the first virtual machine and the to-be-migrated container are in one-to-one correspondence; and then the memory data and the running state of the first virtual machine are hot migrated to a destination physical machine, so as to realize the hot migration of the to-be-migrated container, solve the problem that the container kernel state cannot be migrated in the related art, and realize the complete migration of the kernel state and the running state of the to-be-migrated container; on the other hand, the mutual interference between containers in the hot migration process is avoided. In addition, the first virtual machine created by the rust-based virtual machine manager is a micro and lightweight virtual machine, which can ensure the rapid progress of the hot migration process and does not affect the container hot migration rate.
[0034] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0035] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present disclosure and, together with the specification, serve to explain the principles of the present disclosure. Obviously, the drawings in the following description are only some embodiments of the present disclosure, and other drawings can be obtained from these drawings without creative labor for those skilled in the art.
[0036] Figure 1 A schematic diagram of an exemplary system architecture of a container hot migration method and device to which embodiments of the present disclosure can be applied is shown.
[0037] Figure 2 A flowchart of a container hot migration method according to an embodiment of the present disclosure is schematically shown.
[0038] Figure 3 A basic principle block diagram of creating a secure container by rust-vmm according to an embodiment of the present disclosure is schematically shown.
[0039] Figure 4 A flowchart of creating a one-to-one corresponding first virtual machine and to-be-migrated container by a self-defined VMM according to an embodiment of the present disclosure is schematically shown.
[0040] Figure 5 An implementation process flowchart of a container hot migration method according to an embodiment of the present disclosure is schematically shown.
[0041] Figure 6 A structure block diagram of a container hot migration device according to an embodiment of the present disclosure is schematically shown.
[0042] Figure 7A structural diagram of a computer system of an electronic device suitable for implementing embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0043] Example implementations are now described with reference to the drawings; however, these descriptions are not intended to limit the scope of the present disclosure, but are intended to provide example examples, of the present disclosure as well as describe the principles and applications of the implementations. Accordingly, it is to be understood that adaptations and modifications can be employed without departing from the scope or spirit of the present disclosure. Other implementations can be made by those of ordinary skill in the art upon reading the following description of example implementations. Additionally, it should be understood that features described in the context of one example implementation can be common to other implementations, and vice versa, unless otherwise indicated or apparent from the present disclosure.
[0044] Furthermore, the drawings are not intended to be to scale. Identical reference numbers in different drawings identify identical or similar elements.
[0045] For the convenience of understanding the embodiments of the present application, first, several elements introduced in the description of the embodiments of the present disclosure are described herein:
[0046] Container generally refers to Linux Container, which is a lightweight operating system layer virtualization technology, implemented through the Namespace and Cgroup mechanisms of the Linux kernel. Among them, the Namespace realizes the isolation of resources, and the Cgroup realizes the limitation of the behavior of the process. By packaging the binary, configuration file and related dependent library required by the application into an image file, the container technology greatly facilitates the development and deployment of the application.
[0047] Docker is the most common set of implementation software in the container technology, including the running and management components of the container. Docker is responsible for the creation of the container, the management of the image and the running of the application program in the container.
[0048] Kubernetes (i.e. k8s) is a container scheduling and orchestration platform that can facilitate configuration and management of a large number of containers in a cluster. A computing host in the cluster is referred to as a node, and Docker runs on each node to manage the container instances running in the node.
[0049] Figure 1 A schematic diagram of a system architecture 100 illustrating an exemplary application environment of a container live migration method and device according to an embodiment of the present disclosure is shown. As shown in the figure, the system architecture 100 can include a source physical machine 101, a destination physical machine 102 and a network 103. The source physical machine 101 and the destination physical machine 102 are communicatively connected through the network 103. The network 103 includes, but is not limited to, a wide area network, a metropolitan area network or a local area network; and the source physical machine 101 and the destination physical machine 102 include, but are not limited to, a mainframe, a large machine, a medium machine, a small machine, a micro machine or other various physical devices capable of running a virtual machine. In the case that the container process is not interrupted, the user-perception-free container live migration process is realized by migrating the to-be-migrated container from the source physical machine 101 to the destination physical machine 102. Figure 1
[0050] The container live migration method provided by the embodiment of the present disclosure can be executed in the source physical machine 101, and accordingly, the container live migration device is generally provided in the source physical machine 101.
[0051] The technical solutions of the embodiments of the present disclosure are described in detail as follows:
[0052] Referring to Figure 2 As shown in the figure, the container live migration method of an example embodiment provided by the present disclosure can include the following steps:
[0053] In step S210, in response to a container live migration command, a first virtual machine on a source physical machine where a to-be-migrated container is located is determined; and the first virtual machine and the to-be-migrated container are created by a self-defined virtual machine manager, so that the first virtual machine and the to-be-migrated container correspond to each other.
[0054] In the example embodiment, the container live migration command can include application information, such as an application name, source physical machine information where the to-be-migrated container is located and live migration destination physical machine information. The container live migration command can be issued by a management module of a cluster, for example, issued through a Kubernetes (k8s) platform. The container live migration command can also be triggered by a user, for example, triggered and configured by a software developer.
[0055] In the example embodiment, the first virtual machine can be created by rust-vmm, which is a set of lightweight vmm (virtual machine manager) basic components developed in the rust programming language. The first virtual machine is created by customizing the vmm, and then a container is created on the first virtual machine, so that the first virtual machine corresponds to the container one-to-one. The first virtual machine created in the example is a micro lightweight virtual machine, which can have memory resources, CPU, input and output resources, and network resources. The size of the first virtual machine is in the order of MB, generally tens of MB to more than 100 MB.
[0056] For example, the rust-vmm of the example is more secure and efficient than the traditional qemu (virtualization emulator), and users can build a custom vmm according to their needs on the basis of rust-vmm. For reference Figure 3 In the user space, multiple first virtual machines can be created, and containers can be set in each first virtual machine according to user configuration parameters, so as to run corresponding container processes. In the kernel space, multiple virtual machines are constructed by KVM (Kernel-based Vritual Machine), which is a full virtualization mechanism of the Linux kernel. Using KVM, users can virtualize multiple virtual machines on a physical machine, and the resources of each virtual machine are relatively isolated and can run different operating systems and software independently without affecting each other. Virtual machines can improve the resource utilization of the entire physical machine, and are more convenient to manage and deploy than physical machines.
[0057] For example, for reference Figure 4 The creation process of the first virtual machine and the container to be migrated of the present disclosure can include:
[0058] Step S410, a lightweight first virtual machine is created according to the command line parameters input by the user. In the example, the first virtual machine only has basic resources required for running, such as CPU resources, network resources, memory resources, and input and output resources. The image file is tens of MB, and the startup and transmission speed is fast.
[0059] Step S420, the first virtual machine is started, the Linux kernel file is loaded, and the kernel initialization process is started.
[0060] Step S430, after the kernel initialization is completed, the ramdisk file input by the user is loaded.
[0061] In the ramdisk file of the example, the binary file and related scripts of the application program interface service API server for creating a container are stored.
[0062] Step S440, the kernel executes the first user process (equivalent to the init process in the traditional Linux system). In this example, executing the first user process starts the API server and creates a corresponding socket.
[0063] Step S450, the user connects the socket of the API server, issues a container creation command, and transmits relevant parameters of container creation, such as CPU, memory space, etc.
[0064] Step S460, the vmm sets the container according to the relevant parameters of container creation, creates a Namespace, sets a Cgroup, and sets other necessary running environments, so that the first virtual machine corresponds to the container.
[0065] In this example, through the above process, a container corresponding to the first virtual machine can be created in the first virtual machine, and the container can be used as the to-be-migrated container of the present disclosure.
[0066] Step S220, the memory data and running state of the first virtual machine are acquired and saved locally.
[0067] In this example embodiment, the memory data and running state of the first virtual machine can be converted into a data stream and saved in the local disk or memory, for example, the memory data and running state of the first virtual machine are dumped into an image file and stored in the local disk or memory. The acquisition method of the memory data and running state of the first virtual machine in this example is not specially limited.
[0068] Step S230, the memory data and running state of the first virtual machine are sent to the destination physical machine, so that the second virtual machine on the destination physical machine recovers the running process of the to-be-migrated container on the destination physical machine according to the received memory data and running state.
[0069] In this example embodiment, the destination physical machine can include multiple virtual machines, and the second virtual machine can be one of the virtual machines on the destination physical machine. By setting the corresponding data of the second virtual machine through the received memory data and running state, the running of the to-be-migrated container on the destination physical machine is recovered.
[0070] In the container hot migration method provided in the example embodiment, on the one hand, a first virtual machine and a container to be migrated can be created by a self-defined virtual machine manager, so that the first virtual machine corresponds to the container to be migrated one by one; and then the memory data and the running state of the first virtual machine are hot migrated to a target physical machine, so as to realize the hot migration of the container to be migrated, solve the problem that the container kernel state cannot be migrated in the related art, and realize the complete migration of the kernel state and the running state of the container to be migrated; on the other hand, the mutual interference between containers in the hot migration process is avoided. In addition, the first virtual machine created by the self-defined virtual machine manager based on rust is a micro lightweight virtual machine, which can ensure the rapid progress of the hot migration process and does not affect the container hot migration rate.
[0071] In some embodiments, the method further comprises:
[0072] The container hot migration command is added to a container active triggering interface in kubectl to form a container hot migration subcommand facing a k8s cluster, so that the container hot migration process is triggered by calling the container hot migration subcommand of the container active triggering interface.
[0073] In the example embodiment, at the k8s level, the OCI (Open Container Initiative) container active triggering interface is expanded to add a container hot migration subcommand, so as to trigger the container hot migration process by calling the container active triggering interface in the user interface. In the example, the interface of the k8s container orchestration tool is expanded, so that the hot migration becomes an independent subcommand, simplifying the entire migration operation. By extending the kubectl command to add a live-migrate subcommand, the container can be initiated for hot migration in a cloud-native manner.
[0074] In some embodiments, the first virtual machine on the source physical machine where the container to be migrated is located comprises:
[0075] When the source physical machine contains a plurality of container processes of application information of the container to be migrated, the container to be migrated is specified in the plurality of container processes of the application information through container IP address information or container identification information.
[0076] In the example embodiment, the container hot migration command can include application information corresponding to the container to be migrated, such as an application name or an application identifier. The container hot migration command can also include physical machine information of the container migration-out end (such as a physical machine identifier of the container migration-out end) and physical machine information of the container migration-in end (such as a physical machine identifier of the container migration-in end), and the present disclosure is not limited thereto. When the source physical machine contains multiple container instances of an application (corresponding to the container to be migrated), all container instances of the application on the source physical machine can be listed, for example, IP addresses and container IDs of all container instances corresponding to the application can be listed; and one container can be specified as the container to be migrated through the container IP address information or the container identifier information.
[0077] Based on the one-to-one correspondence between the container to be migrated and the first virtual machine, the first virtual machine corresponding to the container to be migrated is determined.
[0078] In the example embodiment, when the first virtual machine and the container to be migrated are created, the first virtual machine and the container to be migrated are in a one-to-one correspondence, that is, one container is set in one first virtual machine, and when the container to be migrated is determined, the first virtual machine corresponding thereto is determined.
[0079] In some embodiments, the method further includes:
[0080] The running environment requirement of the container to be migrated is determined.
[0081] In the example embodiment, the running environment requirement can include one or more of CPU resources, memory resources, disk space, IP resources, and the like.
[0082] Based on the running environment requirement of the container to be migrated, it is determined whether the destination physical machine meets the running environment requirement of the container to be migrated. For example, whether the destination physical machine can support the running of the container to be migrated is determined according to the remaining memory resources of the destination physical machine.
[0083] When the destination physical machine meets the running environment requirement of the container to be migrated, the container hot migration command is executed, otherwise, an error is reported and the process is exited.
[0084] In some embodiments, the obtaining of the memory data and the running state of the first virtual machine and the saving thereof to the local includes:
[0085] The running process of the first virtual machine is paused, and the current memory data and the running state of the first virtual machine are read and saved to the local.
[0086] In the example embodiment, after receiving the container hot migration command, the running process of the first virtual machine can be paused, and the current memory data and running state of the first virtual machine can be read. The read information can be saved in the disk of the first virtual machine, or in the memory data of the first virtual machine, or in other storage modules, which are not specially limited in the example.
[0087] In some embodiments, the method further comprises:
[0088] Pausing the running process of the first virtual machine, and sending dirty page data generated in the process of sending the memory data and running state to the second virtual machine on the target physical machine, so that the second virtual machine runs the to-be-migrated container according to the dirty page data; the dirty page data includes data changed during the running of the to-be-migrated container on the first virtual machine.
[0089] In the example embodiment, the first virtual machine has resumed running when sending the saved memory data and running state, so that the running of the first virtual machine causes some memory data pages to change during the process of sending data by the first virtual machine. The memory page data that changes is marked as dirty page data. Pausing the running process of the first virtual machine, and sending the dirty page data generated in the process of sending data by the first virtual machine to the target physical machine, so that the second virtual machine has the same running process as the first virtual machine, realizing complete container hot migration and user-perception-free.
[0090] In some embodiments, the method further comprises:
[0091] In response to the container hot migration command, determining whether the application information of the to-be-migrated container exists on the source physical machine.
[0092] In the example embodiment, the container hot migration command contains the application information corresponding to the to-be-migrated container, based on which it is determined whether the application information exists on the source physical machine. If yes, the container hot migration can be performed, otherwise, an error can be reported and the process can be exited.
[0093] When the application information of the to-be-migrated container exists on the source physical machine, a second virtual machine on the target physical machine is started, so that the second virtual machine receives the memory data and running state of the first virtual machine, and configures corresponding parameters of the second virtual machine by using the memory data and running state of the first virtual machine.
[0094] In the example embodiment, after receiving the container live migration command, the destination physical machine starts a virtual machine, which is the second virtual machine. The second virtual machine can be a micro lightweight virtual machine (the size of the image file is MB level) similar to the first virtual machine of the present disclosure. The second virtual machine is configured with the received memory data and running state of the first virtual machine, so that the running process of the container to be migrated can be restored in the second virtual machine of the destination physical machine.
[0095] The corresponding processes involved in the above embodiments can be set in the container live migration sub-command, and the corresponding processes of the above embodiments can be realized by calling the container live migration sub-command of the corresponding interface.
[0096] The present disclosure realizes a cloud-oriented secure container live migration. With the KVM virtualization technology, the safety isolation of the container is first ensured. Secondly, the running state of the entire container, including the kernel state and the user state, can be completely saved and restored. The running environment of the container process is restored to the greatest extent, ensuring the consistency of the application state before and after migration. In addition, the interface of the k8s container orchestration tool is expanded, so that the live migration becomes an independent sub-command, simplifying the container live migration operation.
[0097] The following illustrates the container live migration method of the present disclosure with a specific example. Referring to FIG. 5, the container live migration method provided in the example includes the following steps. Figure 5
[0098] Step S501, the source physical machine creates a first virtual machine based on rust-vmm.
[0099] In the example, rust-vmm is a set of lightweight vmm basic components developed by the rust programming language. Users can build a custom vmm based on their needs. Then create the first virtual machine according to the custom vmm. The first virtual machine is a micro lightweight virtual machine, and the size of its image file is dozens of MB to more than 100 MB, which ensures the migration speed.
[0100] Step S502, the source physical machine configures the kernel state of the first virtual machine based on KVM.
[0101] In the example, the multiple first virtual machines created in the source physical machine based on KVM are relatively isolated in terms of resources. Different operating systems and software can be run independently without affecting each other, which is convenient for management and maintenance.
[0102] Step S503, the source physical machine creates and runs a container in the first virtual machine, so that the container corresponds to the first virtual machine one-to-one.
[0103] In the example embodiment, the first virtual machine can create a container according to the file API server binary file and the related script file input by the user, and run the container according to the user instruction. One first virtual machine configures one container process, so that the container live migration process can be converted into a virtual machine live migration process.
[0104] In step S504, the source physical machine suspends the running of the first virtual machine in which the container to be migrated is located, based on the container live migration command.
[0105] In the example, the container live migration command contains source physical machine information, destination physical machine information, and application name to be migrated. Based on the application name to be migrated, the container to be migrated and the first virtual machine in which the container is located are determined. In the example, before executing the container live migration command, it can be determined whether the source physical machine and the destination physical machine meet the following two conditions: first, the source physical machine has an instance of the application name to be migrated; second, the destination physical machine meets the running environment requirements of the container to be migrated. When the source physical machine and the destination physical machine meet the above two conditions, the container live migration command is executed, otherwise the subsequent live migration process is not executed, and an error message can be output.
[0106] In step S505, the destination physical machine starts a second virtual machine based on the container live migration command.
[0107] In step S506, the source physical machine obtains and saves the memory data and running state of the first virtual machine.
[0108] In the example, the memory data and running state of the first virtual machine can be generated into corresponding migration data streams.
[0109] In step S507, the source physical machine resumes the running of the first virtual machine, and sends the memory data and running state of the first virtual machine to the destination physical machine.
[0110] In the example, the source physical machine and the destination physical machine transmit information through a local socket or a network (TCP protocol).
[0111] In step S508, the second virtual machine of the destination physical machine receives the memory data and running state of the first virtual machine, and sets the memory data and running state of the second virtual machine accordingly.
[0112] In step S509, the source physical machine determines whether the amount of data sent reaches a preset threshold, and if so, proceeds to step S510.
[0113] In the example, the preset threshold can be determined according to the specific configuration of the container, for example, it can be set to 80%-90% or more.
[0114] Step S510, the first virtual machine is paused again, and dirty page data in the process of sending memory data and running state of the first virtual machine to the target physical machine is sent.
[0115] In the present example, when the amount of data to be sent reaches a preset threshold, for example, 90% of the amount of data to be sent, the first virtual machine is paused, and the dirty page data is sent, so that the amount of dirty page data is small, the downtime of the first virtual machine is short, and the user experience is improved.
[0116] Step S511, the target physical machine receives the dirty page data and sends a migration end notification to the source physical machine.
[0117] Step S512, the source physical machine destroys the IP resource corresponding to the first virtual machine according to the received migration end notification.
[0118] Step S513, the target physical machine configures the second virtual machine according to the received data, so that the second virtual machine resumes running in the migration container.
[0119] The container live migration command in the above embodiment can be realized by extending the kubectl command and adding a live-migrate subcommand to it, which realizes the container live migration at the cloud native level. The container live migration is integrated with the k8s container orchestration system, which efficiently manages the migration process and facilitates user operation.
[0120] The container live migration method provided by the present disclosure first uses rust-vmm to build a custom vmm specially designed for containers. Compared with the traditional container which only relies on linux cgroup and namespace for resource isolation, the present disclosure uses KVM virtualization technology to achieve better resource isolation between containers. At the same time, the vmm developed by the rust language is more lightweight and has better security, so that the size of the virtual machine is in the order of MB. On this basis, the one-to-one correspondence between the first virtual machine and the container to be migrated is further used, so that the container live migration process is completed through the first virtual machine instance where the container to be migrated is located. The memory and device running state of the entire first virtual machine are saved to an image file before migration, and are transmitted to the target physical machine through the network, and then the container is restored to run on the target physical machine, completing the container live migration and avoiding the problem that the kernel state cannot be completely restored in the traditional container live migration process. In addition, by extending the kubectl command and adding a live-migrate subcommand, the container live migration at the cloud native level is realized, which is convenient for user operation.
[0121] In addition, the method can create a checkpoint for a container with an external terminal, and avoid the problem that a container with an external terminal cannot be created in the prior art (for example, docker-t). The secure container created by the method can avoid container escape (a container that escapes from the limitation of Namespace or Cgroup), and avoid the security threat caused by the direct access of an escaped container to a physical machine resource.
[0122] Further, in the example embodiment, a container live migration device 600 is also provided. The container live migration device 600 can be applied to a physical machine. Referring to FIG. 6, the container live migration device 600 can include: Figure 6
[0123] The determining module 610 can be configured to determine a first virtual machine on a source physical machine where a container to be migrated is located in response to a container live migration command, and create the first virtual machine and the container to be migrated through a self-defined virtual machine manager, so that the first virtual machine corresponds to the container to be migrated one by one.
[0124] The obtaining module 620 can be configured to obtain memory data and a running state of the first virtual machine and save the memory data and the running state to a local.
[0125] The migration module 630 can be configured to send the memory data and the running state of the first virtual machine to a destination physical machine, so that a second virtual machine on the destination physical machine recovers a running process of the container to be migrated on the destination physical machine according to the received memory data and running state.
[0126] In an example embodiment of the present disclosure, the device 600 further includes:
[0127] The triggering module can be configured to add the container live migration command to a container active triggering interface in kubectl to form a container live migration sub-command facing a k8s cluster, so that the container live migration process is triggered by calling the container live migration sub-command of the container active triggering interface.
[0128] In an example embodiment of the present disclosure, the container live migration command contains application information of the container to be migrated, and the determining module 610 can be further configured to:
[0129] When the source physical machine contains multiple container processes of the application information of the container to be migrated, the container to be migrated is specified in the multiple container processes of the application information through container IP address information or container identification information.
[0130] Based on the one-to-one correspondence between the container to be migrated and the first virtual machine, the first virtual machine corresponding to the container to be migrated is determined.
[0131] In an example embodiment of the present disclosure, the apparatus 600 can further comprise a checking module, which can be configured to:
[0132] determine the running environment requirement of the container to be migrated.
[0133] determine whether the destination physical machine meets the running environment requirement of the container to be migrated based on the running environment requirement of the container to be migrated.
[0134] execute the container live migration command when the destination physical machine meets the running environment requirement of the container to be migrated.
[0135] In an example embodiment of the present disclosure, the obtaining module 620 can be further configured to:
[0136] suspend the running process of the first virtual machine, read the current memory data and running state of the first virtual machine and save them to the local.
[0137] In an example embodiment of the present disclosure, the apparatus 600 can further comprise a migration sub-module, which can be configured to:
[0138] suspend the running process of the first virtual machine, send the dirty page data generated in the process of sending the memory data and running state to the destination physical machine, so that the second virtual machine on the destination physical machine runs the container to be migrated according to the dirty page data; the dirty page data comprises data changed in the process of running the container to be migrated in the first virtual machine.
[0139] In an example embodiment of the present disclosure, the checking module can be further configured to:
[0140] determine whether the application information of the container to be migrated exists on the source physical machine in response to the container live migration command.
[0141] when the application information of the container to be migrated exists on the source physical machine, start the second virtual machine on the destination physical machine, so that the second virtual machine receives the memory data and running state of the first virtual machine, and configures the corresponding parameters of the second virtual machine by using the memory data and running state of the first virtual machine.
[0142] The specific details of the above-mentioned modules or units of the container live migration apparatus have been described in detail in the corresponding container live migration method, and therefore will not be described here again.
[0143] As another aspect, the present application also provides a computer readable storage medium, which can be included in the electronic device described in the above embodiments, or can exist separately without being assembled into the electronic device. The computer readable storage medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to implement the method described in the above embodiments. For example, the electronic device can implement the various steps shown in the above embodiments. Figures 2-5
[0144] It should be noted that the computer readable storage medium shown in the present disclosure can be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, the computer readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or apparatus. In the present disclosure, the computer readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer readable program code. Such a propagated data signal can take various forms, including but not limited to an electromagnetic signal, an optical signal or any suitable combination of the above. The computer readable signal medium can also be any computer readable storage medium other than the computer readable storage medium, which can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or apparatus. The program code contained on the computer readable storage medium can be transmitted by any suitable medium, including but not limited to wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0145] Figure 7 The structural schematic diagram of the computer system of the electronic device suitable for implementing the embodiments of the present disclosure is shown.
[0146] It should be noted that, Figure 7 The computer system 700 of the electronic device shown is only an example and should not limit the functions and use range of the embodiments of the present disclosure.
[0147] As Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701 which can perform various appropriate actions and processes in accordance with programs stored in a read only memory (ROM) 702 or loaded from the storage section 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other through a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0148] Connected to the I / O interface 705 are an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a display device such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as necessary. A removable recording medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 710 as necessary, so that a computer program read therefrom is installed into the storage section 708 as necessary.
[0149] In particular, according to embodiments of the present disclosure, the processes described below with reference to the flowcharts can be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a computer-readable storage medium, the computer program containing program code for executing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network by the communication section 709, and / or installed from the removable recording medium 711. When the computer program is executed by the central processing unit (CPU) 701, various functions defined in the methods and apparatuses of the present application are performed.
[0150] The computer program product of the first aspect can include a computer readable storage medium. The computer readable storage medium can include instructions. The instructions can include one or both of: instructions for causing a computer to implement a method as described above; and instructions for causing a computer to operate as a system as described above. The computer readable storage medium can be tangible. The computer readable storage medium can include at least one of: a magnetic storage medium; an optical storage medium; and a solid state storage medium. The computer readable storage medium can be non-transitory. The computer readable storage medium can be readable by a computer. The computer readable storage medium can be writeable by a computer. The computer readable storage medium can be readable and writable by a computer. The computer readable storage medium can include instructions for implementing functionality described above. The computer readable storage medium can include instructions for causing a computer to implement elements of a system described above. The computer readable storage medium can include instructions for causing a computer to perform operations described above.
[0151] It should be noted that, although various steps of the methods of the present disclosure are described in a particular order in the figures, this is not required or implied in terms of the order of execution of the steps, nor is it required that all of the steps be performed in order to achieve the desired result. Additional or alternative steps can be omitted, multiple steps can be combined into a single step, a single step can be broken into multiple steps, and the like, all of which are considered part of the present disclosure.
[0152] It is to be understood that the present disclosure broadly extends to all combinable combinations of two or more individual features mentioned in the text and / or shown in the drawings. All these different combinations constitute alternative aspects of the present disclosure. The embodiments of the present disclosure illustrate the best ways of implementing the present disclosure that are currently known and will enable a person skilled in the art to make use of the present disclosure.
Claims
1. A method of hot migration of a container, characterized in that, The method comprises the following steps: By adding a container hot migration command to a container active triggering interface in kubectl, a container hot migration sub-command for a k8s cluster is formed to trigger a container hot migration process by calling the container hot migration sub-command of the container active triggering interface; In response to the container hot migration command, a first virtual machine on a source physical machine where the container to be migrated is located is determined, and the first virtual machine and the container to be migrated are created through a self-defined virtual machine manager, so that the first virtual machine corresponds to the container to be migrated one by one; The running process of the first virtual machine is paused, and the current memory data and running state of the first virtual machine are read and saved locally; The memory data and running state of the first virtual machine are sent to a destination physical machine, so that a second virtual machine on the destination physical machine restores the running process of the container to be migrated on the destination physical machine according to the received memory data and running state; After pausing the running process of the first virtual machine, the method further comprises: Dirty page data generated during the sending of the memory data and running state is sent to the destination physical machine, so that the second virtual machine on the destination physical machine runs the container to be migrated according to the dirty page data; the dirty page data includes data changed during the running of the container to be migrated in the first virtual machine.
2. The container thermal migration method of claim 1, wherein, The container hot migration command contains application information of the container to be migrated, and the first virtual machine on the source physical machine where the container to be migrated is located is determined in response to the container hot migration command, which comprises: When the source physical machine contains multiple container processes of the application information of the container to be migrated, the container to be migrated is specified in the multiple container processes of the application information through container IP address information or container identification information; Based on the one-to-one correspondence between the container to be migrated and the first virtual machine, the first virtual machine corresponding to the container to be migrated is determined.
3. The container thermal migration method of claim 1, wherein, The method further comprises: Determining the running environment requirements of the container to be migrated; Based on the running environment requirements of the container to be migrated, it is determined whether the destination physical machine meets the running environment requirements of the container to be migrated; When the destination physical machine meets the running environment requirements of the container to be migrated, the container hot migration command is executed.
4. The container thermal migration method of claim 3, wherein, The method further comprises: In response to the container hot migration command, it is determined whether the application information of the container to be migrated exists on the source physical machine; When the application information of the container to be migrated exists on the source physical machine, a second virtual machine on the destination physical machine is started, so that the second virtual machine receives the memory data and running state of the first virtual machine, and configures the corresponding parameters of the second virtual machine by using the memory data and running state of the first virtual machine.
5. A container thermal transfer apparatus, characterized by, The method comprises the following steps: The determining module is configured to add a container hot migration command to a container active triggering interface in kubectl to form a container hot migration sub-command facing a k8s cluster, so that the container hot migration sub-command triggers a container hot migration process by calling the container active triggering interface; in response to the container hot migration command, a first virtual machine on a source physical machine where a container to be migrated is located is determined; the first virtual machine and the container to be migrated are created by a self-defined virtual machine manager, so that the first virtual machine and the container to be migrated correspond to each other; The obtaining module is configured to pause a running process of the first virtual machine, read current memory data and a running state of the first virtual machine, and save the memory data and the running state to a local; The migration module is configured to send the memory data and the running state of the first virtual machine to a destination physical machine, so that a second virtual machine on the destination physical machine resumes a running process of the container to be migrated on the destination physical machine according to the received memory data and running state; The migration module is configured to send dirty page data generated in the process of sending the memory data and the running state to the destination physical machine after pausing the running process of the first virtual machine, so that the second virtual machine on the destination physical machine runs the container to be migrated according to the dirty page data; the dirty page data includes data changed in the running process of the container to be migrated in the first virtual machine.
6. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the method of any one of claims 1-4.
7. An electronic device, comprising: Comprise: One or more processors; Storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, so that the one or more processors implement the method of any one of claims 1-4.
Citation Information
Patent Citations
Load dynamic migration method in container and virtual machine hybrid cloud environment
CN110347498A
Pod migration method in Kubernetes cluster
CN110377395A