Virtual machine management methods, virtual machine systems, storage media, and application products
By deploying a sidecar container in the KubeVirt launcher pod and utilizing the Libvirt client to transform and forward commands, the problem of difficulty in extending virtual machine management functions in KubeVirt was solved, achieving flexible and efficient virtual machine management and reducing costs.
Patent Information
- Application Number
- CN202510627862.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-15
- Publication Date
- 2026-11-17
AI Technical Summary
Extending virtual machine management functionality in the KubeVirt environment requires modifying the core code, resulting in a long development cycle and poor compatibility with version upgrades, making it impossible to directly use libvirt's powerful management features.
Deploy a sidecar container in the KubeVirt launcher pod. The sidecar container integrates the Libvirt client. The sidecar container listens for virtual machine management requests and converts them into Libvirt commands, which are then forwarded directly to the Libvirt server inside the virtual machine container for execution, thereby enabling the management of the virtual machine.
Without modifying the KubeVirt core code, it significantly expands virtual machine management capabilities, supports a variety of management functions, ensures the security of command and data transmission, and reduces costs.
Smart Images

Figure CN123114618A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to virtual machine management methods, virtual machine systems, storage media, and program products. Background Technology
[0002] A Kubernetes cluster is the basic operating environment for Kubernetes (K8s) and consists of a group of nodes (physical machines). In cloud-native virtualization scenarios, KubeVirt serves as a virtual machine management platform for running and managing multiple virtual machines within a Kubernetes cluster.
[0003] However, KubeVirt defines virtual machine objects through custom resources, manages their lifecycles with the controller, and relies on Launcher Pods to start virtual machines. Its management functions are limited by the Kubernetes Declarative Application Programming Interface (API). If the management functions of virtual machines need to be extended, the core code of KubeVirt needs to be modified, which results in a long development cycle, poor version upgrade compatibility, and high costs.
[0004] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention
[0005] The main purpose of this application is to provide a virtual machine management method, virtual machine system, storage medium, and program product, aiming to solve the technical problem of high cost in expanding the management functions of virtual machines.
[0006] To achieve the above objectives, this application proposes a virtual machine management method applied to a Kubernetes cluster. The Kubernetes cluster deploys multiple launcher pods running in a KubeVirt environment. Each launcher pod deploys a virtual machine container and a sidecar container. The virtual machine container deploys a virtual machine, and the virtual machine integrates a Libvirt server. The sidecar container integrates a Libvirt client. The method includes:
[0007] The management interface of the sidecar container listens for virtual machine management requests and converts the virtual machine management requests into Libvirt commands through the Libvirt client; the sidecar container forwards the Libvirt commands to the virtual machine container; the Libvirt server in the virtual machine container executes the Libvirt commands and returns the results.
[0008] In one embodiment, the virtual machine container and the sidecar container communicate through the internal dedicated network interface card of the launcher pod; the forwarding of the Libvirt command to the virtual machine container through the sidecar container includes: forwarding the Libvirt command to the virtual machine container through the internal dedicated network interface card of the launcher pod via the sidecar container.
[0009] In this embodiment, the internal dedicated network interface card is only visible within the pod. Thus, the sidecar container forwards Libvirt commands to the virtual machine container through the launcher pod's internal dedicated network interface card, ensuring the security of command transmission.
[0010] In one embodiment, forwarding the Libvirt command to the virtual machine container via the sidecar container includes: verifying the validity of the Libvirt command; and forwarding the verified Libvirt command to the virtual machine container via the sidecar container.
[0011] This embodiment incorporates a secure communication mechanism, requiring all Libvirt commands to be validated to ensure that only valid Libvirt commands can be forwarded and executed.
[0012] In one embodiment, forwarding the verified Libvirt command to the virtual machine container via the sidecar container includes: encrypting the verified Libvirt command via the sidecar container and then forwarding it to the virtual machine container.
[0013] In this embodiment, the sidecar container encrypts the data using a verified Libvirt command before forwarding it to the virtual machine container, further ensuring the security of data transmission.
[0014] Furthermore, to achieve the above objectives, this application also proposes a virtual machine system deployed on a Kubernetes cluster, comprising:
[0015] Multiple launcher pods running in the KubeVirt environment, each launcher pod deploying a virtual machine container and a sidecar container. The virtual machine container deploys a virtual machine and integrates the Libvirt server, while the sidecar container integrates the Libvirt client.
[0016] The sidecar container includes a management interface exposed inside or outside the Kubernetes cluster network. The sidecar container is used to listen for virtual machine management requests through the management interface, and convert the virtual machine management requests into Libvirt commands through the Libvirt client, and forward the Libvirt commands to the virtual machine container.
[0017] The virtual machine container is used to execute the Libvirt command through the Libvirt server and return the result.
[0018] In addition, to achieve the above objectives, this application also proposes a virtual machine management device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the virtual machine management method in the above embodiments.
[0019] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and which, when executed by a processor, implements the steps of the virtual machine management method described above.
[0020] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the virtual machine management method described above.
[0021] One or more technical solutions proposed in this application have at least the following technical effects:
[0022] By deploying a sidecar container within a launcher pod running in a KubeVirt environment, and integrating a Libvirt client, and since the virtual machine container within the launcher pod integrates a Libvirt server, if you need to extend the functionality of the virtual machine, simply listen for virtual machine management requests through the sidecar container's interface, convert the virtual machine management requests into Libvirt commands, and then forward the Libvirt commands to the virtual machine container. The Libvirt server within the virtual machine container can then execute the Libvirt commands, thereby managing the virtual machines within the virtual machine container. This expands the management capabilities of the virtual machines, supports the addition of various management functions, and does not require modification of the KubeVirt core code. The method is simple and low-cost. Attached Figure Description
[0023] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0024] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0025] Figure 1 This is a schematic diagram of the device structure of the hardware operating environment involved in the virtual machine management method in this application embodiment;
[0026] Figure 2 This is a schematic diagram of the architecture of a worker node in a current Kubernetes cluster;
[0027] Figure 3 This is a schematic diagram of the architecture of a worker node in a Kubernetes cluster in an embodiment of this application;
[0028] Figure 4 This is a flowchart illustrating an embodiment of the virtual machine management method of this application.
[0029] Figure 5 This is a flowchart illustrating Embodiment 2 of the virtual machine management method of this application;
[0030] Figure 6 This is a schematic diagram illustrating the communication between the user or system and the sidecar container and virtual machine container in this application.
[0031] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0032] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0033] First, the terms used in the embodiments of this application will be uniformly explained.
[0034] (1) Kubernetes
[0035] Kubernetes, or K8s for short, is an open-source container orchestration platform. It's an abbreviation of "ubernete" (using "8" to represent the eight characters in the middle of the name). Kubernetes aims to make deploying containerized applications simple and efficient across multiple hosts in a cloud platform.
[0036] In Kubernetes, we can create multiple containers, each running an application instance. Then, through built-in load balancing strategies, we can manage, discover, and access this group of application instances without requiring complex manual configuration and processing by operations personnel.
[0037] (2) Kubernetes cluster
[0038] A Kubernetes cluster is the basic operating environment for Kubernetes, consisting of a group of nodes (physical machines). These nodes include a master node and multiple worker nodes. The master node is responsible for scheduling and managing the resources of the entire cluster, such as scheduling container execution and monitoring node status; the worker nodes are where the containers actually run.
[0039] (3) Kubernetes API
[0040] The Kubernetes Declarative Application Programming Interface (API) is a core component of the Kubernetes cluster, providing an interface for managing and configuring cluster resources.
[0041] Developers can create, update, and delete resources such as Pods, Services, and Deployments through the Kubernetes API.
[0042] (4) pod
[0043] A Pod is the smallest deployable and manageable unit of computation in a Kubernetes cluster, representing an application instance within the cluster. Containers within a Pod share network and storage resources and are typically deployed on the same node. The design of Pods allows containers to communicate efficiently via their local network address (localhost), making them suitable for services that require tight coupling.
[0044] (5) KubeVirt
[0045] KubeVirt is a Kubernetes-based virtual machine management platform, an open-source project used to run and manage virtual machines in Kubernetes clusters. In other words, KubeVirt can manage multiple virtual machines across multiple physical machines. It treats virtual machines as a resource and manages them through the Kubernetes API, enabling automated deployment, monitoring, and scaling of virtual machines.
[0046] (6) libvirt
[0047] libvirt is an open-source virtual machine management platform used to manage virtual machines. libvirt can manage a single virtual machine on a single physical machine. It provides a unified set of APIs and command-line tools for creating, starting, stopping, and monitoring virtual machines, as well as managing virtual machine storage and networking.
[0048] (7) Launcher pod
[0049] A launcher pod, also known as a launcher container group, is a special pod in KubeVirt used to start and manage virtual machines. Each virtual machine corresponds to one launcher pod. This pod runs libvirt-related components to manage the virtual machines. It is responsible for translating virtual machine configurations into libvirt commands, communicating with the libvirt server, and starting virtual machine instances.
[0050] (8) sidecar
[0051] Sidecar containers are typically used to provide additional functionality, such as log collection, monitoring, network proxying, etc.
[0052] (9) Virtual machines and containers
[0053] Virtual machines emulate a hardware layer, running a complete operating system instance on top of the host operating system. Each virtual machine has its own kernel and system libraries, isolated from each other. This provides stronger resource isolation, with each virtual machine having independent CPU, memory, storage, and network resources.
[0054] Containers run on the host operating system and share the host's kernel and system libraries. Containers are isolated from each other through namespaces, but they still run within the same operating system environment. Resource isolation is relatively low; containers share host resources, but their resource usage can be restricted through configuration.
[0055] Example: Virtual machine A runs a Windows operating system, and virtual machine B runs a Linux operating system; container A runs a Java application, and container B runs a Python application, but they both share the same Linux operating system.
[0056] Next, the technical solution of this application will be described.
[0057] Reference Figure 1 , Figure 1 This is a schematic diagram of the hardware operating environment of the virtual machine management device involved in the embodiments of this application.
[0058] like Figure 1As shown, the virtual machine management device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen, and optionally, it may also include a standard wired interface or a wireless interface. In this application, the wired interface of the user interface 1003 may be a USB interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wireless-Fidelity (Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (RAM) or a non-volatile memory (NVM), such as a disk drive. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.
[0059] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on the virtual machine management device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0060] like Figure 1 As shown, the memory 1005, which is identified as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a virtual machine management program.
[0061] exist Figure 1 In the virtual machine management device shown, the network interface 1004 is mainly used to connect to the backend server and communicate data with the backend server; the user interface 1003 is mainly used to connect to the user equipment; the virtual machine management device calls the virtual machine management program stored in the memory 1005 through the processor 1001 and executes the virtual machine management method provided in the embodiments of this application.
[0062] It is possible that the virtual machine management device in this embodiment can be a worker node of a Kubernetes cluster.
[0063] Based on the above hardware structure, an embodiment of the virtual machine management method of this application is proposed.
[0064] In cloud-native virtualization scenarios, KubeVirt serves as a virtual machine management platform for running and managing multiple virtual machines within a Kubernetes cluster. KubeVirt defines virtual machine objects through custom resources, manages their lifecycles with a controller, and relies on Launcher Pods to start virtual machines. Its management capabilities are limited by the Kubernetes declarative API.
[0065] like Figure 2 The diagram shown illustrates the architecture of a single worker node in a Kubernetes cluster. A Kubernetes cluster typically includes multiple such nodes. Figure 2 The worker nodes shown are each responsible for running containerized applications and virtual machines. Figure 2 Each worker node deploys a launcher pod running in a KubeVirt environment. Within the launcher pod's virtual machine container, a corresponding virtual machine is deployed. The launcher pod is responsible for starting and managing the corresponding virtual machine. The virtual machine integrates a Libvirt server (i.e., the Libvirt daemon, also known as the libvirtd service). Libvirt, as a virtualization management tool, is responsible for configuring and managing the virtual machine's lifecycle.
[0066] The Kubernetes API allows for real-time monitoring of virtual machine status, including running status and resource usage. The Kubernetes API also supports receiving specific management commands and forwarding them to the Libvirt server for execution. All management commands sent to the Libvirt server must be pre-declared by the Kubernetes API to ensure their validity and security. For example, when a user or system sends a management command through the Kubernetes API, the API distributes the command to the corresponding launcher pod, which then passes the command to the Libvirt server for execution of specific virtual machine management operations.
[0067] However, in scenarios where additional management capabilities for virtual machines are required, the above architecture has the following problems:
[0068] (1) Virtual machine management capabilities are limited by the APIs provided by KubeVirt, lacking flexibility;
[0069] (2) If the management function of the virtual machine needs to be expanded, the core code of KubeVirt needs to be modified, which has a long development cycle and poor compatibility with version upgrades, resulting in high costs.
[0070] (3) The KubeVirt wrapper shields the native Libvirt interface, making it impossible to directly use all of libvirt's powerful management functions.
[0071] As can be seen from the above, in the KubeVirt environment, providing a solution that allows direct management of virtual machines using libvirt commands without affecting the existing architecture is of great research value.
[0072] To address this, this application proposes a virtual machine management method applied to a Kubernetes cluster. The Kubernetes cluster deploys multiple launcher pods running in a KubeVirt environment. Each launcher pod deploys a virtual machine container and a sidecar container. The virtual machine container deploys a virtual machine, and the virtual machine integrates a Libvirt server; the sidecar container integrates a Libvirt client. The virtual machine management method includes:
[0073] The management interface of the sidecar container listens for virtual machine management requests and converts them into Libvirt commands through the Libvirt client. The sidecar container then forwards the Libvirt commands to the virtual machine container. Finally, the Libvirt server inside the virtual machine container executes the Libvirt commands and returns the results.
[0074] In this embodiment, a sidecar container is deployed in the launcher pod running in the KubeVirt environment. The sidecar container integrates a Libvirt client. Since the virtual machine container in the launcher pod integrates a Libvirt server, if it is necessary to expand the functionality of the virtual machine, it is only necessary to listen for virtual machine management requests through the interface of the sidecar container, convert the virtual machine management requests into Libvirt commands, and then forward the Libvirt commands to the virtual machine container. The Libvirt server in the virtual machine container can execute Libvirt commands, thereby managing the virtual machine in the virtual machine container. This expands the management capabilities of the virtual machine, supports the addition of various management functions, and does not require modification of the KubeVirt core code. The method is simple and low-cost.
[0075] The virtual machine management method provided in the embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0076] First, it is necessary to explain the application environment of the virtual machine management method in the embodiments of this application.
[0077] like Figure 3 The diagram shown is an architectural representation of a worker node in a Kubernetes cluster according to an embodiment of this application. The Kubernetes cluster includes multiple nodes such as... Figure 3The worker nodes shown are each responsible for running containerized applications and virtual machines. Figure 3 Each worker node deploys a launcher pod running in a KubeVirt environment. Within the launcher pod's virtual machine container, a corresponding virtual machine is deployed. The launcher pod is responsible for starting and managing the corresponding virtual machine. The virtual machine integrates a Libvirt server (i.e., the Libvirt daemon, also known as the libvirtd service). Libvirt, as a virtualization management tool, is responsible for configuring and managing the virtual machine's lifecycle.
[0078] In addition to the virtual machine container, the launcher pod also deploys a sidecar container, which integrates the Libvirt client. Each pod is assigned an IP address in the Kubernetes cluster, and containers within the same pod can communicate through this IP address, thus enabling localhost communication between containers.
[0079] Figure 4 This is a flowchart illustrating the first embodiment of the virtual machine management method according to this application. The method in this embodiment is applied to... Figure 3 The nodes shown include steps S201 to S202:
[0080] Step S201: Listen for virtual machine management requests through the management interface of the sidecar container, and convert the virtual machine management requests into Libvirt commands through the Libvirt client.
[0081] The management interface of the sidecar container is exposed both inside the Kubernetes cluster and on the external network, allowing users or systems to send virtual machine management requests. After listening for a virtual machine management request from a user or system, the management interface of the sidecar container converts the virtual machine management request into Libvirt commands through the Libvirt client.
[0082] Step S202: The Libvirt command is forwarded to the virtual machine container through the sidecar container.
[0083] In one implementation, the Libvirt command is forwarded to the virtual machine container via the aforementioned localhost communication method through the sidecar container.
[0084] In another implementation, the virtual machine container and the sidecar container communicate through the launcher pod's internal dedicated network interface card (NIC). This dedicated NIC is only visible within the pod, thus ensuring the security of command transmission as the sidecar container forwards Libvirt commands to the virtual machine container via the launcher pod's dedicated NIC.
[0085] Step S203: Execute Libvirt commands through the Libvirt server inside the virtual machine container and return the results.
[0086] After receiving a Libvirt command, the virtual machine container executes the Libvirt command via the Libvirt server, performing specific virtual machine management operations. Upon completion, the virtual machine container returns the result to the sidecar container, which then returns the result to the user or system.
[0087] In this embodiment, a sidecar container is deployed in the launcher pod running in the KubeVirt environment. The sidecar container integrates a Libvirt client. Since the virtual machine container in the launcher pod integrates a Libvirt server, if it is necessary to expand the functionality of the virtual machine, it is only necessary to listen for virtual machine management requests through the interface of the sidecar container, convert the virtual machine management requests into Libvirt commands, and then forward the Libvirt commands to the virtual machine container. The Libvirt server in the virtual machine container can execute Libvirt commands, thereby managing the virtual machine in the virtual machine container. This expands the management capabilities of the virtual machine, supports the addition of various management functions, and does not require modification of the KubeVirt core code. The method is simple and low-cost.
[0088] Figure 5 This is a flowchart illustrating the second embodiment of the virtual machine management method according to this application. The method in this embodiment is applied to... Figure 3 The nodes shown include steps S301 to S302:
[0089] Step S301: Listen for virtual machine management requests through the management interface of the sidecar container, and convert the virtual machine management requests into Libvirt commands through the Libvirt client.
[0090] Step S301 described above is the same as step S201 in the first embodiment, and will not be repeated here to avoid repetition.
[0091] Step S302: Verify whether the Libvirt command is valid. If it is invalid, return to step S301; if it is valid, proceed to step S303.
[0092] In this embodiment, a proxy service can be deployed in the sidecar container. This proxy service parses external requests and verifies the legitimacy of Libvirt commands. Specifically, it verifies whether the Libvirt command is on a preset whitelist and filters out external requests not on the whitelist, allowing only Libvirt commands on the whitelist to be forwarded. That is, Libvirt commands on the whitelist are legitimate and can be forwarded to the virtual machine container; Libvirt commands not on the whitelist are illegitimate, filtered out, and the request is returned to the sidecar container's management interface for continued listening.
[0093] Step S303: The verified Libvirt command is forwarded to the virtual machine container via the sidecar container.
[0094] Step S303 above is the same as step S202 in the first embodiment. The difference is that in this step, only the verified Libvirt command is forwarded to the virtual machine container. The similarities can be found in step S202 above.
[0095] It is worth noting that, for the sake of communication security and to prevent data leakage, the sidecar container encrypts the verified Libvirt command before forwarding it to the virtual machine container. The virtual machine container can also encrypt the returned result, thus realizing encrypted communication between the sidecar container and the virtual machine container and further ensuring the security of data transmission.
[0096] Step S304: Execute Libvirt commands through the Libvirt server inside the virtual machine container and return the results.
[0097] Step S304 described above is the same as step S203 in the first embodiment, and will not be repeated here to avoid repetition.
[0098] This embodiment employs a secure communication mechanism. All Libvirt commands are validated to ensure that only valid Libvirt commands can be forwarded and executed. Furthermore, the sidecar container encrypts the validated Libvirt commands before forwarding them to the virtual machine container. The virtual machine container also encrypts its returned results, thus achieving encrypted communication between the sidecar container and the virtual machine container and further guaranteeing the security of data transmission.
[0099] In combination with the above Figure 3 A schematic diagram of the architecture of the worker node and an embodiment of the virtual machine management method are shown in this embodiment. Figure 6 A diagram illustrating the communication between a user or system and the sidecar container and virtual machine container, specifically including the following:
[0100] When a user or system sends a virtual machine management request, the sidecar container converts the request into a Libvirt command via the Libvirt client, verifies the command's validity, and forwards the verified command to the virtual machine container via its internal dedicated network interface card. Upon receiving the command, the virtual machine container executes it using the Libvirt server, performing the specific virtual machine management operations. After execution, the virtual machine container returns the result to the sidecar container, which then returns the result to the user or system.
[0101] In summary, the virtual machine management method in this application embodiment has the following advantages:
[0102] (1) By deploying a sidecar container with Libvirt client integrated in the launcher pod, the management capabilities of virtual machines can be significantly enhanced without affecting the original functions of KubeVirt, and no modification to the KubeVirt core code is required, thus reducing costs.
[0103] (2) An internal dedicated network card is added between the sidecar container and the virtual machine container for communication. The network card is only visible inside the pod, which ensures the security of command transmission. In addition, a dedicated content management network card is used to isolate management traffic and does not affect the virtual machine network.
[0104] (3) A secure communication mechanism was designed, requiring all Libvirt commands to be verified for legitimacy, ensuring that only legitimate Libvirt commands can be forwarded and executed;
[0105] (4) The sidecar container will encrypt the verified Libvirt command and forward it to the virtual machine container. When the virtual machine container returns the result, it can also be encrypted, thus realizing encrypted communication between the sidecar container and the virtual machine container, further ensuring the security of data transmission.
[0106] The virtual machine management method in this application significantly improves the flexibility and efficiency of virtual machine management while maintaining good integration with Kubernetes clusters.
[0107] The virtual machine management method in this application embodiment can be applied to the following scenarios, such as: cloud platforms that require fine-grained management of KubeVirt virtual machines, providing standardized API interfaces, such as supporting dynamic restart of network cards without affecting virtual machine operation; virtual machine operation and maintenance automation scenarios; virtual machine monitoring and fault handling scenarios; virtual machine performance optimization scenarios, etc.
[0108] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0109] This application provides a virtual machine system deployed on a Kubernetes cluster, comprising:
[0110] Multiple launcher pods running in the KubeVirt environment are configured. Each launcher pod contains a virtual machine container and a sidecar container. The virtual machine container contains a virtual machine and integrates a Libvirt server. The sidecar container integrates a Libvirt client. The sidecar container includes a management interface exposed to the internal or external network of the Kubernetes cluster. The sidecar container listens for virtual machine management requests through the management interface and converts the virtual machine management requests into Libvirt commands through the Libvirt client. The Libvirt commands are then forwarded to the virtual machine container. The virtual machine container executes Libvirt commands through the Libvirt server and returns the results.
[0111] See Figure 3 The diagram illustrates the deployment of a launcher pod on a Kubernetes node. However, in practice, a Kubernetes node can deploy multiple launcher pods, and each launcher pod corresponds to a virtual machine. In other words, a Kubernetes node can deploy one or more virtual machines.
[0112] This is feasible, as each launcher pod also deploys an internal dedicated network interface card (NIC) connecting the virtual machine container and the sidecar container. This NIC is only visible within the pod, ensuring the security of command transmission, and the use of a dedicated content management NIC isolates management traffic without affecting the virtual machine network.
[0113] This is feasible; the sidecar container also verifies the validity of Libvirt commands and forwards verified Libvirt commands to the virtual machine container. All Libvirt commands need to be verified to ensure that only valid Libvirt commands can be forwarded and executed.
[0114] This is feasible; the sidecar container is also used to encrypt and forward verified Libvirt commands to the virtual machine container. The sidecar container's encryption of verified Libvirt commands before forwarding them further ensures the security of data transmission.
[0115] In this embodiment, a sidecar container is deployed in the launcher pod running in the KubeVirt environment. The sidecar container integrates a Libvirt client. Since the virtual machine container in the launcher pod integrates a Libvirt server, if it is necessary to expand the functionality of the virtual machine, it is only necessary to listen for virtual machine management requests through the interface of the sidecar container, convert the virtual machine management requests into Libvirt commands, and then forward the Libvirt commands to the virtual machine container. The Libvirt server in the virtual machine container can execute Libvirt commands, thereby managing the virtual machine in the virtual machine container. This expands the management capabilities of the virtual machine, supports the addition of various management functions, and does not require modification of the KubeVirt core code. The method is simple and low-cost.
[0116] This application provides a virtual machine management device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the virtual machine management method in the above embodiments.
[0117] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the virtual machine management method in the above embodiments.
[0118] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0119] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0120] This application provides a computer program product, which includes a computer program that, when executed by a processor, implements the virtual machine management method described in the above embodiments.
[0121] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0122] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0123] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0124] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0125] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as a read-only memory image (ROM) / random access memory (RAM), magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0126] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. A virtual machine management method, characterized in that, The method is applied to a Kubernetes cluster, wherein the Kubernetes cluster deploys multiple launcher pods running in a KubeVirt environment, each launcher pod deploys a virtual machine container and a sidecar container, the virtual machine container deploys a virtual machine, and the virtual machine integrates a Libvirt server, and the sidecar container integrates a Libvirt client; the method includes: The management interface of the sidecar container listens for virtual machine management requests and converts the virtual machine management requests into Libvirt commands through the Libvirt client; The Libvirt command is forwarded to the virtual machine container through the sidecar container; The Libvirt command is executed through the Libvirt server within the virtual machine container, and the result is returned.
2. The method as described in claim 1, characterized in that, The virtual machine container and the sidecar container communicate through the launcher pod's internal dedicated network interface card; The step of forwarding the Libvirt command to the virtual machine container through the sidecar container includes: forwarding the Libvirt command to the virtual machine container through the internal dedicated network interface card of the launcher pod via the sidecar container.
3. The method as described in claim 1 or 2, characterized in that, The forwarding of Libvirt commands to the virtual machine container via the sidecar container includes: Verify the validity of the Libvirt command; The sidecar container forwards the verified Libvirt command to the virtual machine container.
4. The method as described in claim 3, characterized in that, The step of forwarding the verified Libvirt command to the virtual machine container via the sidecar container includes: The sidecar container encrypts the verified Libvirt command and forwards it to the virtual machine container.
5. A virtual machine system, characterized in that, The system is deployed on a Kubernetes cluster and includes: Multiple launcher pods running in the KubeVirt environment, each launcher pod deploying a virtual machine container and a sidecar container. The virtual machine container deploys a virtual machine and integrates the Libvirt server, while the sidecar container integrates the Libvirt client. The sidecar container includes a management interface exposed inside or outside the Kubernetes cluster network. The sidecar container is used to listen for virtual machine management requests through the management interface, and convert the virtual machine management requests into Libvirt commands through the Libvirt client, and forward the Libvirt commands to the virtual machine container. The virtual machine container is used to execute the Libvirt command through the Libvirt server and return the result.
6. The system as described in claim 5, characterized in that, Each launcher pod also has an internal dedicated network interface card (NIC) deployed to connect the virtual machine container and the sidecar container.
7. The system as described in claim 5 or 6, characterized in that, The sidecar container is also used to verify the legitimacy of the Libvirt command and forward the verified Libvirt command to the virtual machine container.
8. A virtual machine management device, characterized in that, The virtual machine management device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the steps of the virtual machine management method as described in any one of claims 1 to 4.
9. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the virtual machine management method as described in any one of claims 1 to 4.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the steps of the virtual machine management method as described in any one of claims 1 to 4.
