Virtual machine mirror image generation method and device, computer equipment and storage medium
By obtaining a container mirror image and using the elastic container of lightweight virtual machines to generate lightweight virtual mirror images, the problem of low efficiency of traditional GPU virtual mirrors has been solved, and an efficient and simplified virtual mirror image generation process is achieved.
Patent Information
- Application Number
- CN202411644422.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-01-28
AI Technical Summary
The traditional GPU virtual machine image generation method is inefficient. You need to create a virtual machine with GPU, download and install drivers, and verify it after restarting, so that the GPU virtual machine image can be generated.
By obtaining a container image of the target resource carrier -driven version of the target resource, based on the elastic container instance service of lightweight virtual machine, obtain the target -driven version of the corresponding resource driver to generate lightweight virtual mirrors of target resources, and generate according to the image. Reuse standard lightweight virtual mirror image.
It has significantly improved the efficiency of the virtual mirror image, simplifies the operation process, shortens the production time of the image, reduces artificial intervention, can better meet the user's demand for diversified resources, and improve the overall work efficiency and service response to the service response speed.
Smart Images

Figure CN119376861A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud computing technology, and in particular to a method, device, computer equipment and storage medium for generating a virtual machine image. Background Art
[0002] With the development of cloud computing technology, virtual machine image technology has emerged. Virtual machine image technology can meet various application needs such as software development, rapid construction of test environment, deployment of application programs, teaching demonstration, etc.
[0003] Taking the GPU (Graphics Processing Unit) virtual machine image as an example, a GPU virtual machine image refers to supporting GPU accelerated computing by installing different versions of GPU drivers on the basis of a virtual machine image. In this way, the configured virtual machine can be packaged into a standard virtual machine image file, which is convenient for building and distribution, and also allows users to quickly use the latest version of GPU capabilities.
[0004] For the traditional GPU virtual machine image generation method, you first need to create a traditional virtual machine with a GPU, then download and install the GPU driver, then restart the virtual machine to complete the verification, and finally start generating the GPU virtual machine image. However, this generation method is inefficient. Summary of the invention
[0005] Based on this, it is necessary to provide a virtual machine image generation method, device, computer equipment and storage medium that can improve the efficiency of virtual machine image generation in response to the above technical problems.
[0006] In a first aspect, the present application provides a method for generating a virtual machine image, the method comprising:
[0007] Get the container image of the target resource that carries the target driver version;
[0008] An elastic container instance service based on a lightweight virtual machine obtains a resource driver corresponding to the target driver version according to the container image to generate a lightweight virtual machine image of the target resource, wherein the lightweight virtual machine image has the resource driver of the target resource installed;
[0009] A reusable standard lightweight virtual machine image of the target resource is generated according to the lightweight virtual machine image, wherein the resource driver of the target resource is installed in the standard lightweight virtual machine image.
[0010] In one embodiment, obtaining a container image of a target resource carrying a target driver version includes:
[0011] Obtain the base image of the target resource, the image description file template and the target driver version;
[0012] The container image is created according to the base image, the image description file template, and the target driver version.
[0013] In one embodiment, the step of obtaining the base image, the image description file template, and the target driver version of the target resource includes:
[0014] Building the base image, the base image including the operating system, services and library files on which the target resources of multiple driver versions depend;
[0015] Building the image description file template based on the base image;
[0016] Obtain the target resource version of the target resource and start the container image task of the pipeline to execute the step of creating the container image according to the base image, the image description file template and the target driver version.
[0017] In one embodiment, the elastic container instance service based on the lightweight virtual machine obtains the resource driver corresponding to the target driver version according to the container image to generate a lightweight virtual machine image of the target resource, including:
[0018] According to the container image and the target driver version, obtaining an installation task based on the elastic container instance service;
[0019] The resource driver corresponding to the target driver version is obtained according to the installation task, and the lightweight virtual machine image is generated, wherein the resource driver of the target resource is installed in the lightweight virtual machine image.
[0020] In one embodiment, obtaining the resource driver corresponding to the target driver version according to the installation task and generating the lightweight virtual machine image includes:
[0021] The installation task is started based on the elastic container instance service of the lightweight virtual machine;
[0022] By executing the installation task, the resource driver corresponding to the target driver version is obtained, and the resource driver corresponding to the target driver version is installed in the container image to generate the lightweight virtual machine image, and the lightweight virtual machine image is installed with the resource driver of the target resource.
[0023] In one of the embodiments, obtaining the installation task based on the elastic container instance service according to the container image and the target driver version includes:
[0024] Determine, according to the container image and the target driver version, the installation command and the driver installation directory corresponding to the resource driver of the target resource;
[0025] An installation task for the elastic container instance is obtained according to the target driver version, the installation command, and the driver installation directory.
[0026] In a second aspect, the present application provides a virtual machine image generation device, the device comprising:
[0027] The image module is used to obtain the container image of the target resource carrying the target driver version;
[0028] An instance module, for an elastic container instance service based on a lightweight virtual machine, obtains a resource driver corresponding to the target driver version according to the container image to generate a lightweight virtual machine image of the target resource, wherein the lightweight virtual machine image has the resource driver of the target resource installed;
[0029] A generation module is used to generate a reusable standard lightweight virtual machine image of the target resource according to the lightweight virtual machine image, wherein the standard lightweight virtual machine image is installed with a resource driver of the target resource.
[0030] In a third aspect, the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.
[0031] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a processor.
[0032] In a fifth aspect, the present application provides a computer program product, including a computer program, which implements the steps of the above method when executed by a processor.
[0033] The above-mentioned virtual machine image generation method, device, computer equipment, storage medium and computer program product obtain a container image of a target resource carrying a target driver version, obtain a resource driver corresponding to the target driver version according to the container image based on the elastic container instance service of the lightweight virtual machine, so as to generate a lightweight virtual machine image of the target resource, and generate a reusable standard lightweight virtual machine image of the target resource according to the lightweight virtual machine image. Based on this, it is possible to generate multiple copies of the standard lightweight virtual machine image with the resource driver of the target resource installed based on the standard lightweight virtual machine image as a template to provide to different users. Therefore, the user can directly call the target resource corresponding to the target driver version based on the copy of the standard lightweight virtual machine image without installing the resource driver of the target driver version of the target resource, which simplifies the operation process and improves efficiency. In addition, the standard lightweight virtual machine image is built based on the lightweight virtual machine, so it also has the advantage of fast startup speed of the lightweight virtual machine, which significantly improves the efficiency of virtual machine image generation. Compared with the traditional virtual machine image generation method, this solution not only greatly simplifies the operation process and shortens the time cycle of virtual machine image production, but also avoids the problem of relying on a large amount of manual intervention. It can not only better meet users' needs for diversified resource-driven versions, but also greatly reduce the pressure on human resources and improve overall work efficiency and service response speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] FIG1 is a schematic diagram of a flow chart of a method for generating a virtual machine image in one embodiment;
[0035] FIG2 is a second flow chart of a method for generating a virtual machine image in one embodiment;
[0036] FIG3 is a third flow chart of a method for generating a virtual machine image in one embodiment;
[0037] FIG4 is a pipeline diagram of a method for generating a virtual machine image in one embodiment;
[0038] FIG5 is a fourth flow chart of a method for generating a virtual machine image in one embodiment;
[0039] FIG6 is a fifth flow chart of a method for generating a virtual machine image in one embodiment;
[0040] FIG7 is a pipeline diagram of a virtual machine image generation method in another embodiment;
[0041] FIG8 is a sixth flow chart of a method for generating a virtual machine image in one embodiment;
[0042] FIG9 is a pipeline diagram of a virtual machine image generation method in yet another embodiment;
[0043] FIG10 is a flow chart of a method for generating a virtual machine image in one embodiment;
[0044] FIG11 is a pipeline diagram of a virtual machine image generation method in yet another embodiment;
[0045] FIG12 is a block diagram of a virtual machine image generation device according to an embodiment;
[0046] FIG. 13 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0048] In one embodiment, as shown in FIG1 , a method for generating a virtual machine image is provided. This embodiment uses the method applied to a terminal as an example for illustration. It is understandable that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps S102 to S106.
[0049] S102: Obtain a container image of a target resource carrying a target driver version.
[0050] The target resource refers to the resource to be used by the cloud computing system, such as a GPU, a server, etc. For ease of understanding, this application takes the target resource as a GPU as an example for explanation.
[0051] The target driver version is used to indicate the resource driver version of the target resource to be installed in the container image. For example, if the target resource is a GPU, the target driver version is the GPU driver version, such as 535.
[0052] The container image refers to an image of a target resource with a target driver version, and the container image has not yet installed the resource driver corresponding to the target driver version of the target resource.
[0053] S104: Based on the lightweight virtual machine elastic container instance service, obtain the resource driver corresponding to the target driver version according to the container image to generate a lightweight virtual machine image of the target resource.
[0054] A lightweight virtual machine is a standard virtual machine that is based on a minimal virtual machine image with very low startup latency and independent kernel-level security capabilities by trimming the kernel (removing non-essential functions and modules) and user mode (removing non-essential services and dependent library files).
[0055] The Elastic Container Instance (ECI) service is a serverless managed containerization solution that allows users to quickly run containerized applications in the cloud (based on lightweight virtual machines) without having to worry about the underlying IaaS resources. This greatly simplifies the deployment and management of applications, and also facilitates seamless migration between different cloud computing vendors, reducing differentiation costs.
[0056] Serverless is a newly proposed cloud computing model. Users no longer need to worry about the underlying server resources and can focus on developing and deploying applications. In the traditional cloud computing model, users need to purchase cloud servers and then complete basic environment configuration and subsequent maintenance. In the Serverless model, cloud service providers are responsible for managing cloud servers, and users are responsible for uploading business codes and paying fees based on the execution time and resource overhead of the code, just like paying for water and electricity in daily life.
[0057] In the application, the elastic container instance service based on the lightweight virtual machine creates a container instance with automatic download of the target driver version according to the container image, and automatically downloads the resource driver corresponding to the target driver version by starting the container instance, and installs the resource driver in the container image, thereby generating a lightweight virtual machine image. Among them, the lightweight virtual machine image is installed with the resource driver of the target resource.
[0058] S106: Generate a reusable standard lightweight virtual machine image of the target resource according to the lightweight virtual machine image.
[0059] The standard lightweight virtual machine image is installed with a resource driver of a target resource of a target driver version corresponding to the target resource. In addition, the standard lightweight virtual machine image is reusable. Reusable can be understood as being able to be repeatedly produced. The reusable standard lightweight virtual machine image of the target resource can be understood as an image built based on a lightweight virtual machine, and the image is installed with a resource driver of a target resource of a target driver version corresponding to the target resource, and can be repeatedly produced. In an embodiment of the present application, the standard lightweight virtual machine image can be regarded as a templated image.
[0060] The above-mentioned virtual machine image generation method obtains a container image of a target resource carrying a target driver version, obtains a resource driver corresponding to the target driver version according to the container image based on the elastic container instance service of the lightweight virtual machine, so as to generate a lightweight virtual machine image of the target resource, and generates a reusable standard lightweight virtual machine image of the target resource according to the lightweight virtual machine image. Based on this, a plurality of copies of the standard lightweight virtual machine image with the resource driver of the target resource installed can be generated with the standard lightweight virtual machine image as a template to provide to different users. Therefore, the user can directly call the target resource corresponding to the target driver version based on the copy of the standard lightweight virtual machine image without installing the resource driver of the target driver version of the target resource, which simplifies the operation process and improves efficiency. In addition, the standard lightweight virtual machine image is built based on the lightweight virtual machine, so it also has the advantage of fast startup speed of the lightweight virtual machine, which significantly improves the efficiency of virtual machine image generation. Compared with the traditional virtual machine image generation method, this solution not only greatly simplifies the operation process and shortens the time cycle of virtual machine image production, but also avoids the problem of relying on a large amount of manual intervention. It can not only better meet users' needs for diversified resource-driven versions, but also greatly reduce the pressure on human resources and improve overall work efficiency and service response speed.
[0061] In one embodiment, as shown in FIG. 2 , step S102 , obtaining a container image of a target resource carrying a target driver version, includes the following steps S202 and S204 .
[0062] S202: Obtain a base image, an image description file template, and a target driver version of a target resource.
[0063] The base image refers to all dependent services, library files, and operating systems that run the resource driver files of the target resource. The base image is a minimized container base image that cuts out all irrelevant content except for all dependent services, library files, and operating systems that run the resource driver files of the target resource.
[0064] The image description file template is used to create a container image with a target resource that has a specified driver version. The driver version of the target resource is used as a variable parameter of the image description file template. The image description file template can be understood as a templated image description file that can be reused, i.e., it has the feature of being reusable. For example, the image description file template includes a dockerfile file template, and the variable parameter of the dockerfile file template is the driver version of the target resource.
[0065] S204: Create a container image according to the base image, the image description file template and the target driver version.
[0066] In the application, based on the base image, according to the image description file template and the target driver version, a container image of the target resource carrying the target driver version is generated.
[0067] The above-mentioned virtual machine image generation method obtains the base image, image description file template and target driver version of the target resource, and creates a container image according to the base image, image description file template and target driver version. The entire image creation process can achieve a high degree of standardization and automation, which not only ensures that the generated image has consistent quality and format, but also greatly simplifies the management and maintenance of the image. In addition, since specific container images can be created according to different target driver versions, it provides extremely high flexibility and can quickly respond to changes in requirements of different application scenarios. At the same time, this also makes the system easier to expand and support more hardware configurations and driver versions. When the driver version or other components need to be updated, only the variable parameters in the image description file template, that is, the driver version of the target resource, need to be modified to build the container image corresponding to the driver version, without manually adjusting each individual virtual machine instance, which not only simplifies maintenance work, but also ensures the consistency and security of all instances.
[0068] In one embodiment, as shown in FIG. 3 , step S202 , obtaining the base image of the target resource, the image description file template and the target driver version, includes the following steps S302 to S306 .
[0069] S302: Build a basic image.
[0070] The base image includes the operating system, services and library files that the target resources of multiple driver versions depend on. Among them, the multiple driver versions include the target driver version.
[0071] S304: Construct an image description file template based on the basic image.
[0072] In the application, the base image is used as the base, and the driver version of the target resource is used as a variable parameter to build a reusable image description file template. For example, if the target resource is a GPU, the base image is used as the base, and the driver version of the GPU is used as a variable parameter to build a reusable Dockerfile file template.
[0073] S306: Obtain the target resource version of the target resource and start the container image task of the pipeline to execute the step of creating a container image according to the base image, the image description file template and the target driver version.
[0074] Pipeline refers to the Continuous Integration Continuous Delivery / Deployment (CICD) pipeline. Among them, continuous integration (CI) means that developers frequently integrate code into the main branch, and each integration verifies the quality of the code through automated building and testing. Continuous delivery (CD) means that developers can deploy code to the production environment at any time to ensure that the code is in a releasable state at any time. The pipeline is a collection of a series of automated steps that covers the entire process from code submission to production deployment. Each step is part of the pipeline and can run independently or be connected in series to form a complete process. The virtual machine image generation method provided in the embodiment of the present application is implemented based on the CICD pipeline.
[0075] As shown in Figure 4, in the application, after obtaining the target resource version corresponding to the target resource, the container image task in the virtual machine image pipeline of the target resource is started, thereby executing the step of creating a container image according to the basic image, image description file template and target driver version to obtain the container image of the target resource carrying the target driver version.
[0076] The above-mentioned virtual machine image generation method builds a basic image, builds an image description file template based on the basic image, obtains the target resource version and starts the container image task of the pipeline to execute the steps of creating a container image according to the basic image, the image description file template and the target driver version. This method realizes the efficient and standardized creation of container images by building a basic image, creating an image description file template, and automatically starting the pipeline task in combination with the target resource version. It not only greatly improves the automation and flexibility of image construction, shortens the development and deployment cycle, but also optimizes resource utilization, simplifies maintenance work, and significantly improves the overall efficiency and response speed of the system.
[0077] In one embodiment, as shown in FIG. 5 , step S104 , based on the elastic container instance service of the lightweight virtual machine, obtains the resource driver corresponding to the target driver version according to the container image to generate a lightweight virtual machine image of the target resource, including the following steps S502 and S504 .
[0078] S502: Obtain an installation task based on the elastic container instance service according to the container image and the target driver version.
[0079] The installation task is created based on the elastic container instance, and is used to obtain the resource driver corresponding to the target driver version and install the resource driver corresponding to the target driver version in the container image to generate a lightweight virtual machine image of the target resource. Exemplarily, the installation task includes a Job task.
[0080] S504: Obtain a resource driver corresponding to the target driver version according to the installation task, and generate a lightweight virtual machine image, wherein the resource driver of the target resource is installed in the lightweight virtual machine image.
[0081] In the application, by starting the installation task based on the elastic container instance service, the resource driver corresponding to the target driver version is obtained, and the resource driver corresponding to the target driver version of the target resource is installed in the container image, thereby generating a lightweight virtual machine image with the resource driver corresponding to the target driver version of the target resource installed.
[0082] The above-mentioned virtual machine image generation method obtains the installation task based on the elastic container instance service according to the container image and the target driver version, obtains the resource driver corresponding to the target driver version according to the installation task, and generates a lightweight virtual machine image. The lightweight virtual machine image is installed with the resource driver of the target resource. This method not only realizes the automation and standardization of the installation process, significantly shortens the image production time, but also utilizes the fast startup characteristics of the elastic container instance to improve the flexibility and response speed of the system, reduce the complexity and cost of operation and maintenance, and ensure the consistency and reliability of the image.
[0083] In one embodiment, as shown in FIG. 6 , step S504 , obtaining a resource driver corresponding to the target driver version according to the installation task, and generating a lightweight virtual machine image, includes the following steps S602 and S604 .
[0084] S602: The elastic container instance service based on the lightweight virtual machine starts the installation task.
[0085] S604: Obtain a resource driver corresponding to the target driver version by executing the installation task, and install the resource driver corresponding to the target driver version in the container image to generate a lightweight virtual machine image, in which the resource driver of the target resource is installed.
[0086] Exemplarily, a new container instance is started based on the elastic container instance service, and the installation task is executed in the started container instance to automatically download, decompress, compile and install the resource driver of the target driver version. In another exemplary embodiment, after the resource driver is installed, necessary verification can be performed to ensure that the driver is correctly installed and can be used normally.
[0087] As shown in Figure 7, in the application, the elastic container instance task of the CICD pipeline can be started to start the installation task based on the elastic container instance service of the lightweight virtual machine, and the resource driver corresponding to the target driver version can be obtained by executing the installation task, and the resource driver corresponding to the target driver version can be installed in the container image to generate a lightweight virtual machine image with the resource driver of the target resource installed.
[0088] The above-mentioned virtual machine image generation method starts the installation task based on the elastic container instance service of the lightweight virtual machine. By executing the installation task, the resource driver corresponding to the target driver version is obtained, and the resource driver corresponding to the target driver version is installed in the container image to generate a lightweight virtual machine image. The lightweight virtual machine image is installed with the resource driver of the target resource. This method not only greatly simplifies the image building process and improves the automation level, but also significantly shortens the image production time and ensures the consistency and reliability of the image. At the same time, by utilizing the fast startup characteristics of the lightweight virtual machine, it can quickly respond to the needs of different resource driver versions, greatly improving the flexibility and efficiency of the system and reducing the complexity and cost of operation and maintenance.
[0089] In one embodiment, as shown in FIG8 , step S502 , obtaining an installation task based on an elastic container instance service according to a container image and a target driver version, includes the following steps S802 and S804 .
[0090] S802: According to the container image and the target driver version, respectively determine the installation command and the driver installation directory corresponding to the resource driver of the target resource.
[0091] The installation command is a command line instruction for installing the resource driver of the target resource in the container image. Exemplarily, the installation command includes steps such as downloading the driver package, decompressing, compiling, and installing. For example, taking the target resource as GPU and the target driver version as 535, the installation command corresponding to the GPU 535 version driver is NVIDIA-Linux-x86_64-535.129.03.run --slient –accept-license.
[0092] The driver installation directory refers to the specific path where the resource driver of the target resource version corresponding to the target resource is installed in the container image to ensure that the resource driver can be loaded and used correctly. For example, the driver installation directory corresponding to the GPU 535 version driver is / usr / bin / .
[0093] S804: Obtain an installation task for the elastic container instance according to the target driver version, the installation command, and the driver installation directory.
[0094] The above-mentioned virtual machine image generation method determines the installation command and driver installation directory corresponding to the resource driver of the target resource according to the container image and the target driver version, and obtains the installation task of the elastic container instance according to the target driver version, installation command and driver installation directory, thereby realizing the automation and standardization of driver installation. This method not only greatly simplifies the image building process and improves the accuracy and consistency of the installation, but also utilizes the fast startup characteristics of the elastic container instance to significantly shorten the image production time, improve the flexibility and response speed of the system, and reduce the complexity and cost of operation and maintenance.
[0095] In one embodiment, step S106, generating a reusable standard lightweight virtual machine image of the target resource according to the lightweight virtual machine image, may include: generating a reusable standard lightweight virtual machine image of the target resource according to the lightweight virtual machine image based on the standard lightweight virtual machine image task of the pipeline. Exemplarily, as shown in FIG9 , based on the image making capability of the OpenStack service, using the standard lightweight virtual machine image as a template, multiple copies of the standard lightweight virtual machine image are generated, and the copies are distributed to different users, so that the user can directly call the target resource of the target driver version based on the copy of the standard lightweight virtual machine image.
[0096] In one embodiment, as shown in FIG. 10 and FIG. 11 , a method for generating a virtual machine image is provided, and the method includes the following steps S1002 to S1010 .
[0097] S1002: Build a minimized container base image, which has all dependent services, library files and operating systems for running GPU driver files.
[0098] S1004: Using the minimized container base image as the base and the GPU driver version as a variable parameter, a reusable Dockerfile file template is constructed.
[0099] S1006: Based on the Dockerfile file template and the GPU target driver version to be built, obtain a container image of the GPU that carries the GPU target driver version.
[0100] Among them, the GPU target driver version can be specified by the image maker when the pipeline is executed.
[0101] S1008: Start a job based on an elastic container instance, install a GPU target driver of the GPU target driver version in the container image, and generate a GPU lightweight virtual machine image.
[0102] For example, the specific content of the job is as follows:
[0103] Kind:Job
[0104] Spec:
[0105] Containers:
[0106] -name:gpu
[0107] Image:xxx / eci / gpu-driver:535
[0108] Conmmad: / bin / sh
[0109] Args
[0110] --c
[0111] -NVIDIA-Linux-x86_64-535-129.03.run –silent –acept-license
[0112] VolumeMounts:
[0113] -name:usrbin
[0114] mountPath: / usr / bin
[0115] volumes:
[0116] -Name:usrbin
[0117] hostPath:
[0118] path: / usr / bin /
[0119] type:Directory
[0120] The container name is gpu, the gpu driver version is 535, the installation command corresponding to the gpu 535 driver version is -NVIDIA-Linux-x86_64-535-129.03.run –silent –acept-license, and the driver installation directory is / usr / bin.
[0121] The container image is the one built in the previous step that carries a specific GPU driver version. The container startup parameter specifies the command to silently install the GPU driver, and mounts the driver installation directory for the container instance.
[0122] S1010: Based on the OpenStack service, a reusable standard GPU lightweight virtual machine image is created with the GPU target driver version installed as the prototype.
[0123] Based on the standard GPU lightweight VM image produced above, the elastic container instance service can quickly iterate different versions of GPU lightweight VM images to meet the diverse needs of users.
[0124] The above-mentioned virtual machine image generation method, by building a set of CICD Pipelines, first starts a job through a Serverless container instance, specifies the container image as a container image carrying different versions of GPU drivers, specifies the container startup parameters as the command for silently installing the GPU driver, and mounts the driver installation directory for the container instance, so that a container instance with automatic GPU driver installation can be quickly created. Finally, through the image production capability of the underlying virtual machine, the lightweight virtual machine image production of different GPU driver versions can be quickly completed. This method has the advantages of low lightweight virtual machine startup delay, and can quickly produce container instances of different GPU driver versions, which greatly solves the shortcomings of cumbersome and time-consuming early image production. In addition, by combining Pipeline with elastic container instance services, taking advantage of the fast startup of ECI lightweight virtual machines and the CICD capabilities of pipelines, the production of GPU lightweight virtual machine images can be quickly completed, which can not only meet the diverse needs of users, but also solve the shortcomings of relying on manpower to produce virtual machine images in the traditional way. On the basis of simplifying the complexity of image production, the cycle of image production is greatly reduced, and human resources are released.
[0125] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0126] Based on the same inventive concept, the embodiment of the present application also provides a virtual machine image generation device for implementing the virtual machine image generation method involved above. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in one or more virtual machine image generation device embodiments provided below can refer to the limitations of the virtual machine image generation method above, and will not be repeated here.
[0127] In one embodiment, as shown in FIG. 12 , a virtual machine image generation device 1200 is provided, including: an image module 1201, used to obtain a container image of a target resource carrying a target driver version; an instance module 1202, used for an elastic container instance service based on a lightweight virtual machine, obtaining a resource driver corresponding to the target driver version according to the container image to generate a lightweight virtual machine image of the target resource, wherein the lightweight virtual machine image is installed with a resource driver of the target resource; a generation module 1203, used to generate a reusable standard lightweight virtual machine image of the target resource according to the lightweight virtual machine image, wherein the standard lightweight virtual machine image is installed with a resource driver of the target resource.
[0128] In one embodiment, the image module 1201 is also used to obtain the base image, image description file template and target driver version of the target resource; and create the container image according to the base image, the image description file template and the target driver version.
[0129] In one embodiment, the image module 1201 is also used to build the basic image, which includes the operating system, services and library files on which the target resources of multiple driver versions depend; build the image description file template based on the basic image; obtain the target resource version and start the container image task of the pipeline to execute the step of creating the container image based on the basic image, the image description file template and the target driver version.
[0130] In one embodiment, the instance module 1202 is also used to obtain an installation task based on the elastic container instance service according to the container image and the target driver version; obtain the resource driver corresponding to the target driver version according to the installation task, and generate the lightweight virtual machine image, wherein the lightweight virtual machine image is installed with the resource driver of the target resource.
[0131] In one embodiment, the instance module 1202 is also used to start the installation task based on the elastic container instance service of the lightweight virtual machine; by executing the installation task, the resource driver corresponding to the target driver version is obtained, and the resource driver corresponding to the target driver version is installed in the container image to generate the lightweight virtual machine image, and the lightweight virtual machine image is installed with the resource driver of the target resource.
[0132] In one embodiment, the instance module 1202 is also used to determine the installation command and driver installation directory corresponding to the resource driver of the target resource according to the container image and the target driver version; and obtain the installation task of the elastic container instance according to the target driver version, the installation command and the driver installation directory.
[0133] Each module in the above-mentioned virtual machine image generation device can be implemented in whole or in part by software, hardware and their combination. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0134] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in FIG13. The computer device includes a processor, a memory, and a network interface connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a method for generating a virtual machine image is implemented.
[0135] Those skilled in the art will understand that the structure shown in FIG. 13 is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0136] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of the aforementioned virtual machine image generation method when executing the computer program.
[0137] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the aforementioned virtual machine image generation method are implemented.
[0138] In one embodiment, a computer program product is provided, including a computer program, which implements the steps of the aforementioned virtual machine image generation method when executed by a processor.
[0139] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0140] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0141] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0142] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for generating a virtual machine image, characterized in that: The method comprises: Get the container image of the target resource that carries the target driver version; An elastic container instance service based on a lightweight virtual machine obtains a resource driver corresponding to the target driver version according to the container image to generate a lightweight virtual machine image of the target resource, wherein the lightweight virtual machine image has the resource driver of the target resource installed; A reusable standard lightweight virtual machine image of the target resource is generated according to the lightweight virtual machine image, wherein the resource driver of the target resource is installed in the standard lightweight virtual machine image.
2. The method according to claim 1, characterized in that The step of obtaining a container image of a target resource carrying a target driver version includes: Obtain the base image of the target resource, the image description file template and the target driver version; The container image is created according to the base image, the image description file template, and the target driver version.
3. The method according to claim 2, characterized in that The step of obtaining the base image, the image description file template, and the target driver version of the target resource includes: Building the base image, the base image including the operating system, services and library files on which the target resources of multiple driver versions depend; Building the image description file template based on the base image; Obtain the target resource version of the target resource and start the container image task of the pipeline to execute the step of creating the container image according to the base image, the image description file template and the target driver version.
4. The method according to any one of claims 1 to 3, characterized in that: The elastic container instance service based on the lightweight virtual machine obtains the resource driver corresponding to the target driver version according to the container image to generate a lightweight virtual machine image of the target resource, including: According to the container image and the target driver version, obtaining an installation task based on the elastic container instance service; The resource driver corresponding to the target driver version is obtained according to the installation task, and the lightweight virtual machine image is generated, wherein the resource driver of the target resource is installed in the lightweight virtual machine image.
5. The method according to claim 4, characterized in that The step of obtaining the resource driver corresponding to the target driver version according to the installation task and generating the lightweight virtual machine image includes: The installation task is started based on the elastic container instance service of the lightweight virtual machine; By executing the installation task, the resource driver corresponding to the target driver version is obtained, and the resource driver corresponding to the target driver version is installed in the container image to generate the lightweight virtual machine image, and the lightweight virtual machine image is installed with the resource driver of the target resource.
6. The method according to claim 4, characterized in that The obtaining, according to the container image and the target driver version, an installation task based on the elastic container instance service includes: Determine, according to the container image and the target driver version, the installation command and the driver installation directory corresponding to the resource driver of the target resource; An installation task for the elastic container instance is obtained according to the target driver version, the installation command, and the driver installation directory.
7. A virtual machine image generation device, characterized in that: The device comprises: The image module is used to obtain the container image of the target resource carrying the target driver version; An instance module, for an elastic container instance service based on a lightweight virtual machine, obtains a resource driver corresponding to the target driver version according to the container image to generate a lightweight virtual machine image of the target resource, wherein the lightweight virtual machine image has the resource driver of the target resource installed; A generation module is used to generate a reusable standard lightweight virtual machine image of the target resource according to the lightweight virtual machine image, wherein the standard lightweight virtual machine image is installed with a resource driver of the target resource.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.