Lightweight container cloud and virtual machine coexistence management method, system and device
Through Kubevirt components, the virtual machine life cycle is managed, and combined with K3s technology, the coexistence and management of containers and virtual machines is realized, which solves the problem of coexistence and co-management of containers and virtual machines in the existing technology, realizes rapid deployment and startup of applications, and improves resource utilization and elastic architecture.
Patent Information
- Application Number
- CN202411941482.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-05-09
AI Technical Summary
It is difficult to realize efficient coexistence and co-management of containers and virtual machines in the prior art, especially in scenarios with limited hardware resources, and it is difficult to quickly deploy and start applications.
By creating Kubevirt components, using Kubevirt components to manage the virtual machine life cycle, combining K3s and Kubevirt technologies to achieve coexistence management of containers and virtual machines, and support rapid deployment and startup of applications.
It realizes rapid deployment and startup of containers and virtual machines, improves resource utilization and elastic architecture, is compatible with most Kubernetes APIs, and supports multi-cluster management.
Smart Images

Figure CN119960903A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of containers and virtual machines, and in particular to a method, system and device for coexistence management of lightweight container cloud and virtual machines. Background Art
[0002] Currently, Kubernetes is the most popular orchestration tool for managing containers. Since many applications have not yet been adapted for containerization, the transformation is difficult. In addition, the hardware and bandwidth configurations of edge devices are low. Developers and enterprises have the need to run virtualization and container clouds at the same time.
[0003] For the above scenarios, a lightweight virtual machine management method is needed to achieve coexistence and co-management of containers and virtual machines, and polymorphic coexistence while occupying minimal physical resources. Summary of the invention
[0004] The present invention provides a lightweight container cloud and virtual machine coexistence management method, system and device for quickly realizing virtualization of hardware resources and container orchestration.
[0005] To achieve the above object, the present invention adopts the following technical solution:
[0006] The present invention provides a lightweight container cloud and virtual machine coexistence management method, comprising:
[0007] Create a Kubevirt component, where the Kubevirt component is used for virtual machine lifecycle management;
[0008] Parse the configuration in yaml through kubectl and create a new VirtualMachine object;
[0009] When the Kubevirt component detects the existence of the new VirtualMachine object, it calls k3s to create a VirtualMachineInstance resource object;
[0010] Starting a virtual machine based on the VirtualMachineInstance resource object;
[0011] The life cycle of the virtual machine is managed through the Kubevirt component.
[0012] Optionally, the creating a Kubevirt component includes:
[0013] Create virt-api, which includes a cluster and two replicas for receiving kubectl requests;
[0014] Create a virt-controller, wherein the virt-controller includes one cluster and two replicas;
[0015] Create a virt-operator, wherein the virt-operator includes one copy per cluster, and the virt-operator is globally unique;
[0016] Create a virt-handle, the virt-handle
[0017] A virt-launcher is created, where the virt-launcher is used to provide virtual machine lifecycle management and corresponds one-to-one with the virtual machine.
[0018] Optionally, the parsing of the configuration in yaml by kubectl and creating a new VirtualMachine object specifically includes:
[0019] Run the kubectl apply-f vm.yaml command to start kubectl.
[0020] Parse the configuration in yaml through kubectl and construct the HTTP request parameters of the corresponding object according to the content of yaml;
[0021] Parse HTTP request parameters through k3s api-server and create a new VirtualMachine object.
[0022] Optionally, parse the HTTP request parameters through the k3s api-server and create a new VirtualMachine object, including:
[0023] When virt-controller monitors a new VirtualMachine object, it calls the k3s api-server to create a new VirtualMachineInstance resource object.
[0024] Optional,
[0025] Starting the virtual machine based on the VirtualMachineInstance resource object includes:
[0026] Send the configuration information of the VirtualMachineInstance to the virt-launcher process through gRPC messages;
[0027] Convert the received VirtualMachineInstance configuration information into a virtual machine's XML file through virt-launcher;
[0028] Libvirt starts the virtual machine according to the XML file.
[0029] Optional,
[0030] Before sending the configuration information of the VirtualMachineInstance to the virt-launcher process through gRPC messages, the following steps are also included:
[0031] When virt-controller monitors a new VirtualMachineInstance object, it calls k3s api-server to create the corresponding virt-launcher-xxx Pod object;
[0032] Select a suitable Node through the kube-scheduler Pod scheduling process of the k3s cluster, and the Node is used for Pod scheduling;
[0033] Create a VirtualMachine Pod and start the virt-launcher process to listen for messages from virt-handler;
[0034] Update the nodeName field of VirtualMachineInstance;
[0035] Monitor updates to the nodeName field of VirtualMachineInstanc through Informer, and synchronize updates to the virt-launcher node.
[0036] Optional,
[0037] The lifecycle management of the virtual machine is performed through the Kubevirt component, including:
[0038] Initialize virtHandlerApp and logger;
[0039] Instantiate a VirtualMachineController object through the Kubevirt component, and the VirtualMachineController object is used to execute the lifecycle management logic of the virtual machine;
[0040] Passing an Informer object to the VirtualMachineController object, the Informer object includes adding a new virtual machine, migrating a virtual machine, destroying a virtual machine, and updating a virtual machine;
[0041] Check VirtualMachineController.Queue for pending VirtualMachineInstance instances. If there are no pending instances, exit and wait for the next cycle. If there are pending instances, execute the lifecycle management logic corresponding to the instance through c.execut.
[0042] Optional,
[0043] Specifically, the Informer includes:
[0044] vmiSourceInformer, used to add new virtual machines;
[0045] vmiTargetInformer, used to migrate virtual machines;
[0046] domainSharedInformer, used to monitor instances in virt-launcher.
[0047] The present invention also provides a lightweight container cloud and virtual machine coexistence management method system, including:
[0048] Kubevirt component module. Used to create Kubevirt components, which are used for virtual machine lifecycle management;
[0049] VirtualMachine object module, used to parse the configuration in yaml through kubectl and create a new VirtualMachine object;
[0050] The VirtualMachineInstance resource object module is used to call k3s to create a VirtualMachineInstance resource object when the Kubevirt component monitors the existence of the new VirtualMachine object;
[0051] A startup module, used for starting the virtual machine based on the VirtualMachineInstance resource object;
[0052] The lifecycle management module is used to perform lifecycle management on the virtual machine through the Kubevirt component.
[0053] The present invention also provides a lightweight container cloud and virtual machine coexistence management device, comprising:
[0054] processor, and
[0055] A memory arranged to store computer executable instructions which, when executed, cause the processor to perform the steps of the above method.
[0056] At least one of the above technical solutions adopted in this specification can achieve the following beneficial effects:
[0057] Through the ASV platform, which is based on K3s and Kubevirt technologies, applications can be deployed faster than Kubernetes. Clusters can also be started faster. At the same time, it is compatible with most of the Kubernetes APIs, and can manage edge ASV clusters through K3s multi-cluster management, and containers and virtual machines coexist and co-manage, and coexist in multiple states. It supports integrated deployment to achieve higher resource utilization and elastic architecture. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 A schematic diagram of a lightweight container cloud and virtual machine coexistence management method provided in an embodiment of this specification;
[0059] Figure 2 This is a flow chart of a lightweight container cloud and virtual machine coexistence management system in this specification;
[0060] Figure 3 This is a schematic diagram of a lightweight container cloud and virtual machine coexistence management device in this specification. DETAILED DESCRIPTION
[0061] In order to make the purpose, technical solutions and advantages of this specification clearer, the technical solutions of this specification are clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.
[0062] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.
[0063] Figure 1 A schematic flow chart of a lightweight container cloud and virtual machine coexistence management method provided in an embodiment of this specification, wherein the method may specifically include the following steps:
[0064] Step 102: Create a Kubevirt component, where the Kubevirt component is used for virtual machine lifecycle management.
[0065] It should be noted that one implementation of step 102 may be:
[0066] Creating Kubevirt components involves:
[0067] Create virt-api, which includes a cluster and two replicas for receiving kubectl requests;
[0068] Create a virt-controller, wherein the virt-controller includes one cluster and two replicas;
[0069] Create a virt-operator, wherein the virt-operator includes one copy per cluster, and the virt-operator is globally unique;
[0070] Create a virt-handle, each physical node corresponds to a virt-handle;
[0071] A virt-launcher is created, where the virt-launcher is used to provide virtual machine lifecycle management and corresponds one-to-one with the virtual machine.
[0072] In a specific embodiment,
[0073] Virt-api includes one cluster and two replicas, which are responsible for receiving requests related to kubectl virt and communicating with k3sapi server to complete resource creation such as vmi and virtual machine lifecycle management;
[0074] The virt-controller includes one cluster and two replicas;
[0075] virt-operator includes one copy per cluster and is globally unique within the entire cluster;
[0076] Each node has a virt-handle, which is responsible for communicating with the k8s api server and virt-lanucher to complete the life cycle management of the virtual machine.
[0077] virt-launcher includes one for each virtual machine and is responsible for communicating with the libvirt API to provide virtual machine lifecycle management.
[0078] Step 104: Use kubectl to parse the configuration in yaml and create a new VirtualMachine object;
[0079] It should be noted that one implementation of step 104 may be
[0080] Run the kubectl apply-f vm.yaml command to start kubectl.
[0081] Parse the configuration in yaml through kubectl and construct the HTTP request parameters of the corresponding object according to the content of yaml;
[0082] Parse HTTP request parameters through k3s api-server and create a new VirtualMachine object.
[0083] In a specific embodiment,
[0084] After the processor executes the command kubectl apply-f vm.yaml, kubectl will parse the configuration in yaml, construct the HTTP request parameters of the corresponding object according to its content, and send it to the k3s api-server;
[0085] After receiving the request, k3s api-server will authenticate, authorize, and control access, and create a VirtualMachine object after passing;
[0086] virt-controller detects a new VirtualMachine object.
[0087] Step 106: When the Kubevirt component detects the existence of the new VirtualMachine object, it calls k3s to create a VirtualMachineInstance resource object;
[0088] It should be noted that one implementation of step 106 may be:
[0089] When the Kubevirt component detects the existence of the new VirtualMachine object, it sends a request to the k3s api-server;
[0090] The k3s api-server creates a VirtualMachineInstance resource object based on the request.
[0091] In a specific embodiment,
[0092] When virt-controller detects a new VirtualMachine object, it sends a request to the k3s api-server;
[0093] When the k3s api-server interface receives the request, it creates the corresponding VirtualMachineInstance object in the k3s cluster.
[0094] Step 108: Start the virtual machine based on the VirtualMachineInstance resource object;
[0095] It should be noted that one implementation of step 108 may be
[0096] Send the configuration information of the VirtualMachineInstance to the virt-launcher process through gRPC messages;
[0097] Convert the received VirtualMachineInstance configuration information into a virtual machine's XML file through virt-launcher;
[0098] Libvirt starts the virtual machine according to the XML file.
[0099] In one embodiment,
[0100] When virt-controller monitors a new VirtualMachineInstance object, it calls k3s api-server to create the corresponding virt-launcher-xxx Pod object;
[0101] Select a suitable Node through the kube-scheduler Pod scheduling process of the k3s cluster, and the Node is used for Pod scheduling;
[0102] Create a VirtualMachine Pod and start the virt-launcher process to listen for messages from virt-handler;
[0103] Update the nodeName field of VirtualMachineInstance;
[0104] Monitor updates to the nodeName field of VirtualMachineInstanc through Informer, and synchronize updates to the virt-launcher node.
[0105] In a specific embodiment,
[0106] When virt-controller monitors the creation of a VirtualMachineInstance object, it calls k3s api-server to create the corresponding virt-launcher-xxx Pod object;
[0107] The k3s cluster selects a suitable Node through the kube-scheduler Pod scheduling process to prepare for Pod scheduling;
[0108] Create a VirtualMachine Pod and start the virt-launcher process to listen for messages from virt-handler;
[0109] Update the nodeName field of VirtualMachineInstance;
[0110] The virt-handler on the node listens to the creation of VirtualMachineInstanc on its own node through Informer;
[0111] Send a gRPC message to send the configuration of the VirtualMachineInstance to the virt-launcher process to start the virtual machine;
[0112] virt-launcher receives the configuration of VirtualMachineInstance and converts it into the XML file of the virtual machine;
[0113] Libvirt starts the virtual machine according to the XML file.
[0114] Step 110: Perform lifecycle management on the virtual machine through the Kubevirt component;
[0115] It should be noted that one implementation of step 110 may be
[0116] Initialize virtHandlerApp and logger;
[0117] Instantiate a VirtualMachineController object through the Kubevirt component, and the VirtualMachineController object is used to execute the lifecycle management logic of the virtual machine;
[0118] Passing an Informer object to the VirtualMachineController object, the Informer object includes adding a new virtual machine, migrating a virtual machine, and monitoring virt-launcher;
[0119] Check VirtualMachineController.Queue for pending VirtualMachineInstance instances. If there are no pending instances, exit and wait for the next cycle. If there are pending instances, execute the lifecycle management logic corresponding to the instance through c.execut.
[0120] In one embodiment,
[0121] Informer specifically includes:
[0122] vmiSourceInformer, used to add new virtual machines;
[0123] vmiTargetInformer, used to migrate virtual machines;
[0124] domainSharedInformer, used to monitor instances in virt-launcher.
[0125] In a specific embodiment,
[0126] Initialize virtHandlerApp and register the flag parameter so that the virt-handler executable file can receive parameter input;
[0127] Initialize the logger with the log level set to INFO;
[0128] Instantiate a VirtualMachineController object;
[0129] Check VirtualMachineController.Queue for pending VirtualMachineInstance instances. If there are no pending instances, it will exit and wait for the next cycle. If there are pending instances, it will execute c.execut to execute the corresponding logic, including network preparation of virt-launcherPod and startup of the virtual machine.
[0130] When instantiating a VirtualMachineController object, pass in an Informer object, including:
[0131] A) vmiSourceInformer: A virtual machine has been added to the node
[0132] B) vmiTargetInformer: There are virtual machines migrated to this node
[0133] C)domainSharedInformer: monitors the domain instance in the virt-launcher on this node.
[0134] In a specific embodiment,
[0135] In NewController, callback functions are registered for these Informer objects. When the vmi object of the Host is added, destroyed, or updated on K3s, the corresponding functions are triggered.
[0136] It can be seen that the ASV platform, which is based on K3s and Kubevirt technologies, can deploy applications faster than Kubernetes. It can also start clusters faster. At the same time, it is compatible with most of the Kubernetes APIs, and can manage edge ASV clusters through K3s multi-cluster management, and containers and virtual machines coexist and co-manage, and coexist in multiple states. It supports integrated deployment, which can help enterprises create modern application development and achieve higher resource utilization and elastic architecture.
[0137] Figure 2 This is a flow chart of a lightweight container cloud and virtual machine coexistence management system for this specification, including:
[0138] Step 202: Kubevirt component module, used to create Kubevirt component, where the Kubevirt component is used for virtual machine lifecycle management;
[0139] Step 204, VirtualMachine object module, used to parse the configuration in yaml through kubectl and create a new VirtualMachine object;
[0140] Step 206, the VirtualMachineInstance resource object module is used to call k3s to create a VirtualMachineInstance resource object when the Kubevirt component monitors the existence of the new VirtualMachine object;
[0141] Step 208: a startup module, used to start the virtual machine based on the VirtualMachineInstance resource object;
[0142] Step 210: A lifecycle management module is used to perform lifecycle management on the virtual machine through the Kubevirt component.
[0143] Optionally, the Kubevirt component module is specifically used to:
[0144] Creating Kubevirt components involves:
[0145] Create virt-api, which includes a cluster and two replicas for receiving kubectl requests;
[0146] Create a virt-controller, wherein the virt-controller includes one cluster and two replicas;
[0147] Create a virt-operator, wherein the virt-operator includes one copy per cluster, and the virt-operator is globally unique;
[0148] Create a virt-handle, each physical node corresponds to a virt-handle;
[0149] A virt-launcher is created, where the virt-launcher is used to provide virtual machine lifecycle management and corresponds one-to-one with the virtual machine.
[0150] Optionally, the VirtualMachine object module is specifically used to:
[0151] Run the kubectl apply-f vm.yaml command to start kubectl.
[0152] Parse the configuration in yaml through kubectl and construct the HTTP request parameters of the corresponding object according to the content of yaml;
[0153] Parse HTTP request parameters through k3s api-server and create a new VirtualMachine object.
[0154] Optionally, the VirtualMachineInstance resource object module is specifically used to:
[0155] When the Kubevirt component detects the existence of the new VirtualMachine object, it sends a request to the k3s api-server;
[0156] The k3s api-server creates a VirtualMachineInstance resource object based on the request.
[0157] Optionally, the startup module is specifically used to:
[0158] Send the configuration information of the VirtualMachineInstance to the virt-launcher process through gRPC messages;
[0159] Convert the received VirtualMachineInstance configuration information into a virtual machine's XML file through virt-launcher;
[0160] Libvirt starts the virtual machine according to the XML file.
[0161] Optionally, the lifecycle management module is specifically used to:
[0162] Initialize virtHandlerApp and logger;
[0163] Instantiate a VirtualMachineController object through the Kubevirt component, and the VirtualMachineController object is used to execute the lifecycle management logic of the virtual machine;
[0164] Passing an Informer object to the VirtualMachineController object, the Informer object includes adding a new virtual machine, migrating a virtual machine, and monitoring virt-launcher;
[0165] Check VirtualMachineController.Queue for pending VirtualMachineInstance instances. If there are no pending instances, exit and wait for the next cycle. If there are pending instances, execute the lifecycle management logic corresponding to the instance through c.execut.
[0166] It can be seen that the ASV platform, which is based on K3s and Kubevirt technologies, can deploy applications faster than Kubernetes. It can also start clusters faster. At the same time, it is compatible with most of the Kubernetes APIs, and can manage edge ASV clusters through K3s multi-cluster management, and containers and virtual machines coexist and co-manage, and coexist in multiple states. It supports integrated deployment, which can help enterprises create modern application development and achieve higher resource utilization and elastic architecture.
[0167] Figure 3 This is a schematic diagram of a lightweight container cloud and virtual machine coexistence management device for this specification, including:
[0168] processor, and
[0169] A memory arranged to store computer executable instructions which, when executed, cause the processor to perform the following steps:
[0170] Step 1: Create a Kubevirt component, which is used for virtual machine lifecycle management.
[0171] Step 2: Use kubectl to parse the configuration in yaml and create a new VirtualMachine object;
[0172] Step 3: When the Kubevirt component detects the existence of the new VirtualMachine object, it calls k3s to create a VirtualMachineInstance resource object;
[0173] Step 4: Start the virtual machine based on the VirtualMachineInstance resource object;
[0174] Step 5: Perform lifecycle management on the virtual machine through the Kubevirt component.
[0175] It can be seen that the ASV platform, which is based on K3s and Kubevirt technologies, can deploy applications faster than Kubernetes. It can also start clusters faster. At the same time, it is compatible with most of the Kubernetes APIs, and can manage edge ASV clusters through K3s multi-cluster management, and containers and virtual machines coexist and co-manage, and coexist in multiple states. It supports integrated deployment, which can help enterprises create modern application development and achieve higher resource utilization and elastic architecture.
[0176] The above is only an embodiment of the present application and is 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 in the scope of the claims of the present application.
Claims
1. A lightweight container cloud and virtual machine coexistence management method, characterized in that: include: Create a Kubevirt component, where the Kubevirt component is used for virtual machine lifecycle management; Parse the configuration in yaml through kubectl and create a new VirtualMachine object; When the Kubevirt component detects the existence of the new VirtualMachine object, it calls k3s to create a VirtualMachineInstance resource object; Starting a virtual machine based on the VirtualMachineInstance resource object; The life cycle of the virtual machine is managed through the Kubevirt component.
2. The method according to claim 1, characterized in that Creating a Kubevirt component includes: Create virt-api, which includes a cluster and two replicas for receiving kubectl requests; Create a virt-controller, wherein the virt-controller includes one cluster and two replicas; Create a virt-operator, wherein the virt-operator includes one copy per cluster, and the virt-operator is globally unique; Create a virt-handle, each physical node corresponds to a virt-handle; A virt-launcher is created, where the virt-launcher is used to provide virtual machine lifecycle management and corresponds one-to-one with the virtual machine.
3. The method according to claim 2, characterized in that The process of parsing the configuration in yaml and creating a new VirtualMachine object through kubectl specifically includes: Run the kubectl apply-f vm.yaml command to start kubectl. Parse the configuration in yaml through kubectl and construct the HTTP request parameters of the corresponding object according to the content of yaml; Parse HTTP request parameters through k3s api-server and create a new VirtualMachine object.
4. The method according to claim 2, characterized in that: When the Kubevirt component monitors the existence of the new VirtualMachine object, calling k3s to create a VirtualMachineInstance resource object specifically includes: When the Kubevirt component detects the existence of the new VirtualMachine object, it sends a request to the k3s api-server; The k3s api-server creates a VirtualMachineInstance resource object based on the request.
5. The method according to claim 2, characterized in that: The starting the virtual machine based on the VirtualMachineInstance resource object includes: Send the configuration information of the VirtualMachineInstance to the virt-launcher process through gRPC messages; Convert the received VirtualMachineInstance configuration information into a virtual machine's XML file through virt-launcher; Libvirt starts the virtual machine according to the XML file.
6. The method according to claim 5, characterized in that Before sending the configuration information of the VirtualMachineInstance to the virt-launcher process through the gRPC message, the following steps are also included: When virt-controller monitors a new VirtualMachineInstance object, it calls k3s api-server to create the corresponding virt-launcher-xxx Pod object; Select a suitable Node through the kube-scheduler Pod scheduling process of the k3s cluster, and the Node is used for Pod scheduling; Create a VirtualMachine Pod and start the virt-launcher process to listen for messages from virt-handler; Update the nodeName field of VirtualMachineInstance; Monitor updates to the nodeName field of VirtualMachineInstanc through Informer, and synchronize updates to the virt-launcher node.
7. The method according to claim 2, characterized in that The performing lifecycle management on the virtual machine by using the Kubevirt component includes: Initialize virtHandlerApp and logger; Instantiate a VirtualMachineController object through the Kubevirt component, and the VirtualMachineController object is used to execute the lifecycle management logic of the virtual machine; Passing an Informer object to the VirtualMachineController object, the Informer object includes adding a new virtual machine, migrating a virtual machine, and monitoring virt-launcher; Check VirtualMachineController.Queue for pending VirtualMachineInstance instances. If there are no pending instances, exit and wait for the next cycle. If there are pending instances, execute the lifecycle management logic corresponding to the instance through c.execut.
8. The method according to claim 7, characterized in that The Informer specifically includes: vmiSourceInformer, used to add new virtual machines; vmiTargetInformer, used to migrate virtual machines; domainSharedInformer, used to monitor instances in virt-launcher.
9. A lightweight container cloud and virtual machine coexistence management method system, characterized in that: include: Kubevirt component module, used to create Kubevirt component, which is used for virtual machine lifecycle management; VirtualMachine object module, used to parse the configuration in yaml through kubectl and create a new VirtualMachine object; The VirtualMachineInstance resource object module is used to call k3s to create a VirtualMachineInstance resource object when the Kubevirt component monitors the existence of the new VirtualMachine object; A startup module, used for starting the virtual machine based on the VirtualMachineInstance resource object; The lifecycle management module is used to perform lifecycle management on the virtual machine through the Kubevirt component.
10. A lightweight container cloud and virtual machine coexistence management device, characterized in that: include: processor, and A memory arranged to store computer executable instructions which, when executed, cause the processor to perform the steps of the method as claimed in any one of claims 1 to 8.
Citation Information
Cited By
Container and virtual machine hybrid scheduling method and device based on domestic AI server
CN121166282A