Implementation method for compressing cloud native mirror image
By storing dependent packages in the storage center using PV addresses in the CI and k8s platforms, the problem of excessive cloud-native mirroring affecting the operation of k8s is solved, and the compression and operation efficiency of mirrors are improved.
Patent Information
- Application Number
- CN202411144862.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-20
- Publication Date
- 2024-12-13
AI Technical Summary
The cloud native mirror is too large, resulting in low k8s operation efficiency, affecting the deployment and distribution of other services.
Through the interaction between the CI platform and the k8s platform and the configuration center, obtain the PV address and install the dependency package of the cloud-native mirror to the storage center. Instead of in the mirror, the generated mirror does not contain the dependency package, thereby achieving image compression.
It effectively avoids the impact of huge cloud-native mirrors on the operation of k8s, improves the efficiency of mirror construction and deployment, and reduces the bandwidth usage of intranet.
Smart Images

Figure CN119127283A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method for implementing a compressed cloud native image. Background Art
[0002] Currently, more and more Internet companies are turning to cloud native, which is essentially a software development and deployment method that aims to build highly available, reliable, and scalable application services using technologies such as cloud computing, containerization, and microservices. Kubernetes is currently recognized as the largest open source architecture platform for cloud native services. More and more companies are introducing Kubernetes service clusters to improve the efficiency of server resource usage within the company and reduce costs. The industry abbreviation for Kubernetes is generally k8s.
[0003] The construction of a cloud-native platform is inseparable from containerization. Containerization is to package the business application and all dependent packages in a container. This container is generally a lightweight Linux system. The business application and dependent packages are installed in this lightweight system, and then the system is packaged into a runnable package file, which is called a cloud-native image.
[0004] K8s runs services by running the cloud-native image of the service. The service application and all dependent packages are stored in a cloud-native image. However, for some services, their dependent packages may be very large. If the large dependent packages are packaged into the cloud-native image, the final cloud-native image will also be very large.
[0005] If the cloud native image is too large, it will take a long time for k8s to pull the cloud native image, increase the congestion of k8s intranet bandwidth, and even affect the deployment and distribution of other businesses. Summary of the invention
[0006] The present application provides an implementation method for compressing a cloud native image to compress the cloud native image to prevent an overly large cloud native image from affecting k8s operation.
[0007] In a first aspect, the present application provides a method for implementing a compressed cloud native image, the method being applied to a CI platform, the CI platform being used to build a cloud native image, the method comprising:
[0008] Determine the image name and version number of the cloud native image according to the first build code;
[0009] Sending a first PV address request to a configuration center to obtain a first PV address returned by the configuration center; wherein the first PV address request includes the image name and the version name of the cloud native image, and the configuration center is set outside the CI platform;
[0010] Determine a dependency package of the cloud native image according to the first build code, and install the dependency package in a storage area corresponding to the first PV address in a storage center according to the first PV address; wherein the storage center is set outside the CI platform;
[0011] The first PV address is mounted on the cloud native image, and the cloud native image mounted with the first PV address is stored in a cloud native image center; wherein the cloud native image center is set outside the CI platform.
[0012] In a feasible embodiment of the present application, determining the image name and version number of the cloud native image according to the first build code includes:
[0013] Reading the image name of the cloud native image from the first build code;
[0014] Calculating a hash value of the first build code, and determining the hash value of the first build code as the version name of the cloud native image;
[0015] and / or,
[0016] An acquisition timestamp of the first build code is obtained, and the acquisition timestamp of the first build code is determined as the version name of the cloud native image.
[0017] In a feasible embodiment of the present application, determining the dependency package of the cloud native image according to the construction code, and installing the dependency package in the storage area corresponding to the first PV address in the storage center according to the first PV address, includes:
[0018] Modify the installation path of the dependent package in the first build code to the first PV address to generate a second build code;
[0019] A dependency package installation script is executed according to the second construction code to install the dependency package in the storage area corresponding to the first PV address in the storage center.
[0020] In a feasible embodiment of the present application, before determining the image name and version number of the cloud native image according to the first build code, the method further includes:
[0021] The first build code is automatically pulled from the code repository based on continuous integration.
[0022] In a second aspect, the present application provides a method for implementing a compressed cloud native image, the method being applied to a k8s platform, the k8s platform being used to deploy a cloud native image, the method comprising:
[0023] In response to the first deployment code, determine the image name and version name of the cloud native image to be deployed according to the first deployment code;
[0024] Send a second PV address request to the configuration center to obtain a second PV address returned by the configuration center; wherein the second PV address request includes the image name and the version name of the cloud native image to be deployed, and the configuration center is set outside the k8s platform;
[0025] Mount the second PV address on the first deployment code to generate a second deployment code;
[0026] According to the second deployment code, the cloud native image to be deployed is obtained from the cloud native image center, and when the cloud native image to be deployed is running, the dependency package of the cloud native image to be deployed is run in the storage center according to the second deployment code; wherein, the cloud native image center is arranged outside the k8s platform, the cloud native image center includes multiple cloud native images, the storage center is arranged outside the k8s platform, and multiple dependency packages are installed in the storage center.
[0027] In a feasible embodiment of the present application, in response to the first deployment code, determining the image name and version name of the cloud native image to be deployed according to the first deployment code includes:
[0028] The k8s library of the k8s platform is called to parse the first deployment code, and the image name and the version name of the cloud native image to be deployed corresponding to the first deployment code are obtained.
[0029] In a feasible embodiment of the present application, obtaining the to-be-deployed cloud native image from a cloud native image center according to the second deployment code includes:
[0030] Calling the k8s library of the k8s platform to parse the second deployment code, and obtaining the image name and the version name of the cloud native image to be deployed corresponding to the second deployment code;
[0031] The image name and the version name of the cloud native image to be deployed are sent to the cloud native image center to obtain the cloud native image to be deployed corresponding to the image name and the version name from the cloud native image center.
[0032] In a feasible embodiment of the present application, when the cloud native image to be deployed is running, the dependent package of the cloud native image to be deployed is run in the storage center according to the second deployment code, including:
[0033] Determining the second PV address from the second deployment code when the cloud native image to be deployed is running;
[0034] Send a dependency package execution request to the storage area corresponding to the second PV address in the storage center, so as to execute the dependency package of the cloud native image to be deployed in the storage area corresponding to the second PV address in the storage center.
[0035] In a third aspect, the present application provides a method for implementing a compressed cloud native image, the method being applied to a configuration center, the configuration center interacting with a CI platform and a k8s platform, the configuration center being used to allocate a first PV address to the CI platform and a second PV address to the k8s platform, the method comprising:
[0036] In response to the first PV address request, return the first PV address to the CI platform; wherein the first PV address is used to instruct the CI platform to install the dependency package of the cloud native image in the storage area corresponding to the first PV address in the storage center when creating the cloud native image;
[0037] In response to the second PV address request, the second PV address is returned to the k8s platform; wherein the second PV address is used to instruct the k8s platform to run the dependent package of the cloud native image from the storage area corresponding to the second PV address in the storage center when deploying the cloud native image.
[0038] In a feasible embodiment of the present application, in response to the first PV address request, returning the first PV address to the CI platform includes:
[0039] Obtain an image name and a version number according to the first PV address request; wherein the image name and the version number are used to uniquely identify the cloud native image created by the CI platform;
[0040] Searching in the storage center according to the image name and the version number, determining whether the first PV address corresponding to the image name and the version number exists;
[0041] If the first PV address corresponding to the image name and the version number exists, returning the first PV address to the CI platform;
[0042] If the first PV address corresponding to the image name and the version number does not exist, the PV address corresponding to any storage space where the dependent package is not installed is used as the first PV address, and the first PV address is returned to the CI platform.
[0043] In a fourth aspect, the present application provides a device for implementing a compressed cloud native image, the device being applied to a CI platform, the CI platform being used to build a cloud native image, the device comprising:
[0044] A first determination module, configured to determine an image name and a version number of the cloud native image according to the first build code;
[0045] A first sending module is used to send a first PV address request to a configuration center to obtain a first PV address returned by the configuration center; wherein the first PV address request includes the image name and the version name of the cloud native image, and the configuration center is set outside the CI platform;
[0046] An installation module, used to determine a dependency package of the cloud native image according to the first build code, and install the dependency package in a storage area corresponding to the first PV address in a storage center according to the first PV address; wherein the storage center is set outside the CI platform;
[0047] A storage module is used to mount the first PV address on the cloud native image, and store the cloud native image mounted with the first PV address in a cloud native image center; wherein the cloud native image center is set outside the CI platform.
[0048] In a fifth aspect, the present application provides a device for implementing a compressed cloud native image, the device is applied to a k8s platform, the k8s platform is used to deploy a cloud native image, and the device includes:
[0049] A second determination module, configured to respond to the first deployment code and determine the image name and version name of the cloud native image to be deployed according to the first deployment code;
[0050] A second sending module is used to send a second PV address request to the configuration center to obtain a second PV address returned by the configuration center; wherein the second PV address request includes the image name and the version name of the cloud native image to be deployed, and the configuration center is set outside the k8s platform;
[0051] A generation module, used for mounting the second PV address on the first deployment code to generate a second deployment code;
[0052] A running module is used to obtain the cloud native image to be deployed from the cloud native image center according to the second deployment code, and run the dependency package of the cloud native image to be deployed in the storage center according to the second deployment code when the cloud native image to be deployed is running; wherein the cloud native image center is arranged outside the k8s platform, the cloud native image center includes multiple cloud native images, the storage center is arranged outside the k8s platform, and multiple dependency packages are installed in the storage center.
[0053] In a sixth aspect, the present application provides an implementation device for compressing a cloud native image, the device being applied to a configuration center, the configuration center interacting with a CI platform and a k8s platform, the configuration center being used to allocate a first PV address to the CI platform and a second PV address to the k8s platform, the device comprising:
[0054] A first response module, configured to return a first PV address to the CI platform in response to a first PV address request; wherein the first PV address is used to instruct the CI platform to install the dependency package of the cloud native image in the storage area corresponding to the first PV address in the storage center when creating a cloud native image;
[0055] The second response module is used to return a second PV address to the k8s platform in response to a second PV address request; wherein the second PV address is used to instruct the k8s platform to run the dependent package of the cloud native image from the storage area corresponding to the second PV address in the storage center when deploying the cloud native image.
[0056] In the seventh aspect, the present application provides an electronic device, comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus, wherein the processor is configured to execute a method for implementing a compressed cloud native image as described in any one of the first, second, and third aspects of the present application.
[0057] In an eighth aspect, the present application also provides a computer storage medium storing computer executable instructions, wherein the computer executable instructions are used to execute a method for implementing a compressed cloud native image as described in any one of the first aspect, second aspect, and third aspect of the present application.
[0058] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: In the method provided by the embodiment of the present application, when building a cloud native image, the CI platform obtains the first PV address from the configuration center based on the image name and version number of the cloud native image, and installs the dependency package of the cloud native image in the storage center corresponding to the first PV address, and stores the cloud native image without the dependency package installed and the first PV address in the cloud native image center. In the technical solution provided by the present application, the storage center is only used to install the dependency package, and the generated cloud native image does not contain the dependency package. Through the technical solution provided by the present application, the generated cloud native image is freed from the relatively large dependency package, and the cloud native image is compressed to avoid the overly large cloud native image affecting the k8s operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0060] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0061] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0062] Figure 1 A schematic diagram of an implementation scenario of a method for compressing a cloud native image provided in an embodiment of the present application;
[0063] Figure 2 A flowchart of a method for implementing a compressed cloud native image provided in an embodiment of the present application when applied to a CI platform;
[0064] Figure 3 A schematic diagram of a process for implementing a method for compressing a cloud native image provided in an embodiment of the present application when applied to a k8s platform;
[0065] Figure 4 A flowchart of a method for implementing a compressed cloud native image provided in an embodiment of the present application when applied to a configuration center;
[0066] Figure 5A schematic diagram of the interaction between the CI platform and the configuration center when building a cloud native image in an implementation method for compressing a cloud native image provided in an embodiment of the present application;
[0067] Figure 6 A schematic diagram of the interaction between the k8s platform and the configuration center when deploying a cloud native image, for an implementation method of compressing a cloud native image provided in an embodiment of the present application;
[0068] Figure 7 A schematic diagram of the overall process of implementing a method for compressing a cloud native image provided in an embodiment of the present application;
[0069] Figure 8 A schematic diagram of the structure of a device for implementing a compressed cloud native image provided in an embodiment of the present application when applied to a CI platform;
[0070] Fig. 9 A schematic diagram of the structure of a device for implementing a compressed cloud native image provided in an embodiment of the present application when applied to a k8s platform;
[0071] Fig.10 A schematic diagram of the structure of a device for implementing a compressed cloud native image provided in an embodiment of the present application when applied to a configuration center;
[0072] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0073] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0074] The disclosure below provides many different embodiments or examples to implement different structures of the present invention. In order to simplify the disclosure of the present invention, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present invention. In addition, the present invention can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0075] In order to solve the technical problem in the prior art that the cloud native image is too large and affects the operation of k8s, the present application provides an implementation method for compressing the cloud native image, which can compress the cloud native image to prevent the overly large cloud native image from affecting the operation of k8s.
[0076] Figure 1 A schematic diagram of an implementation scenario of a method for compressing a cloud native image provided in an embodiment of the present application, referring to Figure 1 , a method for implementing a compressed cloud native image provided in this application can be implemented on a CI platform, a configuration center, and a k8s platform.
[0077] The CI platform, configuration center, and k8s platform are set up independently. The CI platform and the configuration center can interact with each other, and the k8s platform and the configuration center can interact with each other. At the same time, the CI platform can also interact with the storage center and the cloud native image center, the k8s platform can also interact with the storage center and the cloud native image center, and the configuration center can interact with the storage center.
[0078] The CI (Continuous Integration) platform is used to build cloud-native images. The CI platform builds cloud-native images based on the build code uploaded by users.
[0079] The k8s platform is used to deploy cloud-native images. The k8s platform deploys cloud-native images based on the deployment code uploaded by the user.
[0080] The storage center is specifically a PV (Persistent Volume). There are multiple storage areas in the storage center, and different storage areas are identified by different PV addresses.
[0081] The cloud native image center is used to store the cloud native images built by the CI platform. At the same time, the cloud native image center is also used to send the corresponding cloud native images to the k8s platform in response to the deployment request of the k8s platform when the cloud native images are deployed on the k8s platform. The cloud native images in the cloud native image center are identified by the image name and version number.
[0082] The configuration center can obtain the PV address from the storage center and send the obtained PV address to the CI platform and k8s platform.
[0083] Figure 2 A schematic diagram of a method for implementing a compressed cloud native image provided in an embodiment of the present application when applied to a CI platform, see Figure 2 The implementation method of compressing a cloud native image provided by an embodiment of the present application specifically includes the following steps:
[0084] S21: Determine the image name and version number of the cloud native image according to the first build code;
[0085] S22: Send a first PV address request to the configuration center to obtain the first PV address returned by the configuration center; wherein the first PV address request includes the image name and version name of the cloud native image, and the configuration center is set outside the CI platform;
[0086] S23: Determine a dependency package of the cloud native image according to the first build code, and install the dependency package in a storage area corresponding to the first PV address in a storage center according to the first PV address; wherein the storage center is set outside the CI platform;
[0087] S24: Mount the first PV address on the cloud native image, and store the cloud native image with the first PV address mounted on it in a cloud native image center; wherein the cloud native image center is set outside the CI platform.
[0088] Specifically, in step S21, the user writes the first build code in the code editing program, the code editing program and the code repository can interact, the code editing program automatically uploads the first build code to the code repository, and the CI platform obtains the first build code from the code repository.
[0089] After the CI platform obtains the first build code from the code repository, the image name and version number of the cloud native image that needs to be created are determined based on the first build code.
[0090] In a feasible embodiment of the present application, the code repository may be a Git Repo, and the CI platform automatically pulls the first build code from the code repository based on continuous integration.
[0091] In order to uniquely identify the cloud native image that needs to be created currently by the image name and version number, in a feasible embodiment of the present application, the image name and version number of the cloud native image are determined according to the first build code, including:
[0092] Read the image name of the cloud native image from the first build code;
[0093] Calculate a hash value of the first build code, and determine the hash value of the first build code as a version name of the cloud native image;
[0094] and / or,
[0095] An acquisition timestamp of the first build code is obtained, and the acquisition timestamp of the first build code is determined as a version name of the cloud native image.
[0096] Specifically, the first build code includes an image name of the cloud native image, which is set by the user. The image name of the cloud native image is determined by reading the first build code.
[0097] The hash value of the first build code and the acquisition timestamp of the first build code are both uniquely corresponding to the first build code. When the first build code is created, the hash value of the first build code is determined, and when the first build code is acquired by the CI platform, the acquisition timestamp of the first build code is determined. The version name of the cloud native image is determined by the hash value of the first build code and / or the acquisition timestamp of the first build code, so that the version name of the cloud native image is uniquely determined, and different cloud native images can be identified by different version names.
[0098] Based on the above embodiments, in a possible actual implementation scenario of the present application, the cloud native image can be identified by: image name + hash value of the first build code, image name + acquisition timestamp of the first build code, or image name + hash value of a build code + acquisition timestamp of the first build code.
[0099] Specifically, in step S22, the CI platform interacts with the configuration center, the CI platform sends a first PV address request to the configuration center, and obtains the returned first PV address from the configuration center. The first PV address request is generated according to the image name and version name of the cloud native image.
[0100] The configuration center can interact with the storage center. After the configuration center obtains the first PV address request, the configuration center obtains the first PV address corresponding to the first PV address request from the storage center.
[0101] Specifically, in step S23, after obtaining the first PV address, the CI platform determines the dependency package of the cloud native image according to the first build code, and installs the dependency package of the cloud native image in the storage area corresponding to the first PV address in the storage center.
[0102] The storage center can install the dependency packages of the cloud native image. There are multiple storage areas in the storage center, and different storage areas are identified by different PV addresses. After obtaining the first PV address, the CI platform searches the storage center based on the first PV address, finds the storage area corresponding to the first PV address, and installs the dependency packages of the cloud native image in the storage area.
[0103] In a feasible embodiment of the present application, determining a dependency package of a cloud native image according to a build code, and installing the dependency package in a storage area corresponding to the first PV address in a storage center according to the first PV address includes:
[0104] Modify the installation path of the dependent package in the first build code to the first PV address, and generate the second build code;
[0105] The dependency package installation script is executed according to the second construction code to install the dependency package in the storage area corresponding to the first PV address in the storage center.
[0106] Specifically, the first build code can be divided into two parts: the first part is the dependency package installation part, and the second part is the cloud native image building part. In the first part, the installation path of the dependency package is described. After the CI platform obtains the first PV address, the installation path of the dependency package in the first part is modified to the first PV address, and the modified first part is combined with the original second part to obtain the second build code.
[0107] Execute the second build code, wherein the first part of the second build code is executed by the dependency package installation script, and the dependency package of the cloud native image is installed in the storage area corresponding to the first PV address in the storage center. Execute the second part of the second build code by creating a script to generate a cloud native image.
[0108] Specifically, in step S24, the first PV address is mounted on the created cloud native image to complete the creation of the cloud native image. After the creation of the cloud native image is completed, the cloud native image mounted with the first PV address is stored in the cloud native image center.
[0109] It is understandable that the cloud native image mounted with the first PV address does not have any dependent packages installed.
[0110] It can be understood that the above embodiment applied to the CI platform actually describes the process of building a cloud-native image.
[0111] Through the technical solution provided by the above embodiment, when the CI platform creates a cloud native image, it obtains the first PV address from the configuration center based on the image name and version number of the cloud native image, and installs the dependency package of the cloud native image in the storage center corresponding to the first PV address. The cloud native image without the dependency package installed and the first PV address are stored in the cloud native image center. In the technical solution provided by the present application, the storage center is only used to install the dependency package, and the generated cloud native image does not contain the dependency package. Through the technical solution provided by the present application, the generated cloud native image is freed from the relatively large dependency package, and the cloud native image is compressed to avoid the overly large cloud native image from affecting the k8s operation.
[0112] Figure 3 A schematic diagram of a method for implementing a compressed cloud native image provided in an embodiment of the present application when applied to a k8s platform, see Figure 3 The implementation method of compressing a cloud native image provided by an embodiment of the present application specifically includes the following steps:
[0113] S31: In response to the first deployment code, determine the image name and version name of the cloud native image to be deployed according to the first deployment code;
[0114] S32: Send a second PV address request to the configuration center to obtain a second PV address returned by the configuration center; wherein the second PV address request includes the image name and version name of the cloud native image to be deployed, and the configuration center is set outside the k8s platform;
[0115] S33: Mount the second PV address on the first deployment code to generate a second deployment code;
[0116] S34: Obtain the cloud native image to be deployed from the cloud native image center according to the second deployment code, and run the dependency package of the cloud native image to be deployed in the storage center according to the second deployment code when the cloud native image to be deployed is running; wherein, the cloud native image center is set outside the k8s platform, the cloud native image center includes multiple cloud native images, the storage center is set outside the k8s platform, and multiple dependency packages are installed in the storage center.
[0117] Specifically, in step S31, when the user expects to deploy a cloud native image, the user uploads a first deployment code to the k8s platform. The k8s platform responds to the upload of the first deployment code, parses the first deployment code, and determines the image name and version name of the current cloud native image to be deployed.
[0118] In a feasible embodiment of the present application, the first deployment code is a yaml file. The k8s library of the k8s platform can be called to parse the first deployment code in the form of the yaml file to obtain the image name and version name of the cloud native image to be deployed corresponding to the first deployment code.
[0119] Specifically, in step S32, the k8s platform interacts with the configuration center, and the k8s platform sends a second PV address request to the configuration center, and obtains the returned second PV address from the configuration center. The second PV address request is generated according to the image name and version name of the cloud native image to be deployed.
[0120] The configuration center can interact with the storage center. After the configuration center obtains the second PV address request, the configuration center obtains the second PV address corresponding to the second PV address request from the storage center.
[0121] Specifically, in step S33, the second PV address is mounted on the first deployment code to obtain the second deployment code. In a specific implementation of the present application, the yaml file corresponding to the first deployment code is modified, and the second PV address is injected into the yaml file corresponding to the first deployment code to obtain the second deployment code. It can be understood that the second deployment code is also a yaml file.
[0122] Specifically, in step S34, the k8s platform determines the second deployment code, and deploys the cloud native image to be deployed according to the second deployment code. The k8s platform obtains the corresponding cloud native image to be deployed in the cloud native image center according to the second deployment code, deploys the cloud native image to be deployed, and after the cloud native image to be deployed is deployed and runs, runs the dependent package of the cloud native image to be deployed in the storage center according to the second deployment code.
[0123] In a feasible embodiment of the present application, obtaining the cloud native image to be deployed from the cloud native image center according to the second deployment code includes:
[0124] Call the k8s library of the k8s platform to parse the second deployment code, and obtain the image name and version name of the cloud native image to be deployed corresponding to the second deployment code;
[0125] The image name and version name of the cloud native image to be deployed are sent to the cloud native image center to obtain the cloud native image to be deployed corresponding to the image name and version name from the cloud native image center.
[0126] Specifically, it can be seen from the above embodiment that the second deployment code is also a yaml file, and the second deployment code in the form of a yaml file is parsed through the k8s library to obtain the image name and version name of the cloud native image to be deployed corresponding to the second deployment code. It can be understood that since the second deployment code is the first deployment code injected with the second PV address, the image name and version name of the cloud native image to be deployed parsed from the second deployment code are consistent with the image name and version name of the cloud native image to be deployed parsed from the first deployment code.
[0127] The cloud native image center stores multiple cloud native images, and different cloud native images are identified by different image names and version names. After determining the image name and version name of the cloud native image to be deployed according to the second deployment code, the cloud native image that uniquely corresponds to the image name and version name of the cloud native image to be deployed is obtained in the cloud native image center based on the image name and version name of the cloud native image to be deployed, thereby completing the acquisition of the cloud native image to be deployed.
[0128] In a feasible embodiment of the present application, when the cloud native image to be deployed is running, the dependent package of the cloud native image to be deployed is run in the storage center according to the second deployment code, including:
[0129] Determine the second PV address from the second deployment code when the cloud native image to be deployed is running;
[0130] A dependency package execution request is sent to the storage area corresponding to the second PV address in the storage center, so as to execute the dependency package of the cloud native image to be deployed in the storage area corresponding to the second PV address in the storage center.
[0131] Specifically, the k8s platform deploys the cloud native image by calling the NODE node. The k8s platform schedules one or more NODE nodes and sends the second deployment code to the NODE node. The NODE node pulls the corresponding cloud native image to be deployed from the cloud native image center according to the second deployment code. After the pull is completed, the container is started in the form of POD, and the second PV address in the second deployment code is mounted in the POD. At this time, when running the cloud native image to be deployed, since the second PV address is mounted in the POD, a dependent package running request is sent to the storage area corresponding to the second PV address in the storage center, and the dependent package of the cloud native image to be deployed is run in the storage area corresponding to the second PV address in the storage center.
[0132] Through the technical solution provided by the present application, when deploying a cloud native image, the cloud native image to be deployed does not contain dependency packages itself, but the dependency packages of the cloud native image to be deployed are run in the storage center when the cloud native image to be deployed is deployed and running.
[0133] It can be understood that the above embodiment applied to the k8s platform actually describes the deployment process of the cloud native image.
[0134] Consider a possible practical scenario, running different cloud native images on multiple physical devices, and the dependency packages of these cloud native images are the same. In the prior art, the same dependency package needs to be encapsulated in each cloud native image, resulting in low deployment efficiency and low physical device operation efficiency. Through the technical solution provided by this application, the same dependency package can be run on the same storage area in the storage center, and the cloud native image running on the physical device does not need to encapsulate the corresponding dependency package. It only needs to run in the storage area corresponding to the second PV address in the storage center during operation, which is more convenient to deploy.
[0135] Figure 4 A flowchart of a method for implementing a compressed cloud native image provided in an embodiment of the present application when applied to a configuration center, referring to Figure 4 The implementation method of compressing a cloud native image provided by an embodiment of the present application specifically includes the following steps:
[0136] S41: In response to the first PV address request, return the first PV address to the CI platform; wherein the first PV address is used to instruct the CI platform to install the dependency package of the cloud native image in the storage area corresponding to the first PV address in the storage center when creating the cloud native image;
[0137] S42: In response to the second PV address request, return the second PV address to the k8s platform; wherein the second PV address is used to instruct the k8s platform to run the dependency package of the cloud native image from the storage area corresponding to the second PV address in the storage center when deploying the cloud native image.
[0138] Specifically, in step S41, the configuration center responds to the first PV address request sent by the CI platform and returns the first PV address to the CI platform; in step S42, the configuration center responds to the second PV address request sent by the k8s platform and returns the second PV address to the k8s platform.
[0139] It can be understood that the configuration center actually implements the allocation of PV addresses. The configuration center manages the PV addresses in the storage center based on the interaction with the storage center.
[0140] In a feasible embodiment of the present application, in response to the first PV address request, returning the first PV address to the CI platform includes:
[0141] Obtain the image name and version number according to the first PV address request; the image name and version number are used to uniquely identify the cloud native image created by the CI platform;
[0142] Search in the storage center according to the image name and version number to determine whether there is a first PV address corresponding to the image name and version number;
[0143] If there is a first PV address corresponding to the image name and version number, return the first PV address to the CI platform;
[0144] If there is no first PV address corresponding to the image name and version number, the PV address corresponding to any storage space where the dependent package is not installed is used as the first PV address, and the first PV address is returned to the CI platform.
[0145] Figure 5 A schematic diagram of the interaction between the CI platform and the configuration center when building a cloud native image is provided for an implementation method of compressing a cloud native image provided in an embodiment of the present application, with reference to Figure 5 In the implementation method of compressing a cloud native image provided in the embodiment of the present application, the CI platform and the configuration center interact through the following steps when building a cloud native image:
[0146] S51: The CI platform determines the image name and version number of the cloud native image;
[0147] S52: The CI platform generates a first PV address request;
[0148] S53: The CI platform sends a first PV address request to the configuration center;
[0149] S54: The configuration center determines the first PV address according to the first PV address request;
[0150] S55: The configuration center sends the first PV address to the CI platform;
[0151] S56: The CI platform installs the dependency package to the storage area corresponding to the first PV address in the storage center;
[0152] S57: The CI platform mounts the first PV address to the cloud native image;
[0153] S58: The CI platform stores the cloud native image mounted with the first PV address in the cloud native image center.
[0154] Figure 6 A schematic diagram of the interaction between the k8s platform and the configuration center when deploying a cloud native image is provided for an implementation method of compressing a cloud native image provided in an embodiment of the present application, with reference to Figure 6 In the implementation method of compressing a cloud native image provided in the embodiment of the present application, the CI platform and the configuration center interact through the following steps when building a cloud native image:
[0155] S61: The k8s platform determines the image name and version number of the cloud native image to be deployed according to the first deployment code;
[0156] S62: The k8s platform generates a second PV address request;
[0157] S63: The k8s platform sends a second PV address request to the configuration center;
[0158] S64: The configuration center determines the second PV address according to the second PV address request;
[0159] S65: The configuration center sends the second PV address to the k8s platform;
[0160] S66: The k8s platform mounts the second PV address to the first deployment code to generate the second deployment code;
[0161] S67: The k8s platform sends the second deployment code to the cloud native image platform;
[0162] S68: The k8s platform obtains the cloud native image to be deployed from the cloud native image platform;
[0163] S69: When the cloud native image to be deployed is running, the k8s platform runs the dependency package in the storage area corresponding to the second PV address in the storage center.
[0164] Figure 7 A schematic diagram of the overall process of implementing a method for compressing a cloud native image provided in an embodiment of the present application, referring to Figure 7 The implementation method of compressing a cloud native image provided in the embodiment of the present application can be implemented through the following steps:
[0165] exist Figure 7In the process of building a cloud native image, steps S701 to S711 are executed.
[0166] S701: The user submits the first build code to Git Repo;
[0167] S702: The CI platform pulls the first build code from the Git Repo;
[0168] S703: The CI platform determines the image name and version name of the cloud native image based on the first build code, and generates a first PV address request according to the image name and version name;
[0169] S704: The CI platform sends a first PV address request to the configuration center;
[0170] S705: The configuration center requests the first PV address from the storage center based on the first PV address request;
[0171] S706: The configuration center receives the first PV address returned by the storage center;
[0172] S707: The CI platform receives the first PV address returned by the configuration center;
[0173] S708: The CI platform mounts the first PV address to the first build code to generate a second build code;
[0174] S709: The CI platform installs the dependency package of the cloud native image to the storage area corresponding to the first PV address in the storage center based on the second build code;
[0175] S710: The CI platform builds a cloud native image based on the second build code, and mounts the first PV address on the cloud native image;
[0176] S711: The CI platform stores the cloud native image mounted with the first PV address in the cloud native image center.
[0177] exist Figure 7 In the process of building a cloud native image, steps S712 to S721 are executed.
[0178] S712: The user submits the first deployment code to the k8s platform;
[0179] S713: The k8s platform parses the first deployment code, determines the image name and version number of the cloud native image to be deployed, and generates a second PV address request
[0180] S714: The k8s platform sends a second PV address request to the configuration center;
[0181] S715: The configuration center requests the second PV address from the storage center based on the second PV address request;
[0182] S716: The configuration center receives the second PV address returned by the storage center;
[0183] S717: The k8s platform receives the second PV address returned by the configuration center;
[0184] S718: The k8s platform mounts the second PV address to the first deployment code to generate a second deployment code;
[0185] S719: The k8s platform schedules the NODE node and sends the second deployment code to one or more NODE nodes;
[0186] S720: The NODE node pulls the corresponding cloud native image to be deployed from the cloud native image center according to the second deployment code;
[0187] S721: When the cloud native image to be deployed is running, the NODE node runs the dependency package of the cloud native image to be deployed in the corresponding storage area in the storage center according to the second PV address in the second deployment code.
[0188] Figure 8 A schematic diagram of a structure of a device for implementing a compressed cloud native image provided in an embodiment of the present application when applied to a CI platform, referring to Figure 8 When a device for implementing a compressed cloud native image provided in an embodiment of the present application is applied to a CI platform, the device includes:
[0189] A first determination module 801 is used to determine the image name and version number of the cloud native image according to the first build code;
[0190] The first sending module 802 is used to send a first PV address request to the configuration center to obtain the first PV address returned by the configuration center; wherein the first PV address request includes the image name and version name of the cloud native image, and the configuration center is set outside the CI platform;
[0191] The installation module 803 is used to determine the dependency package of the cloud native image according to the first build code, and install the dependency package in the storage area corresponding to the first PV address in the storage center according to the first PV address; wherein the storage center is set outside the CI platform;
[0192] The storage module 804 is used to mount the first PV address on the cloud native image, and store the cloud native image mounted with the first PV address in a cloud native image center; wherein the cloud native image center is set outside the CI platform.
[0193] In a feasible embodiment of the present application, the first determining module 801 includes:
[0194] A reading unit, used to read the image name of the cloud native image from the first build code;
[0195] A first determining unit, configured to calculate a hash value of the first build code, and determine the hash value of the first build code as a version name of the cloud native image;
[0196] and / or,
[0197] The second determining unit is used to obtain an acquisition timestamp of the first build code, and determine the acquisition timestamp of the first build code as a version name of the cloud native image.
[0198] In a feasible embodiment of the present application, the installation module 803 includes:
[0199] A modification unit, used to modify the installation path of the dependent package in the first build code to the first PV address, and generate a second build code;
[0200] The execution unit is used to execute the dependency package installation script according to the second construction code to install the dependency package in the storage area corresponding to the first PV address in the storage center.
[0201] In a feasible embodiment of the present application, the device further includes:
[0202] The pull module is used to automatically pull the first build code from the code repository based on continuous integration.
[0203] Fig. 9 A schematic diagram of the structure of a device for implementing a compressed cloud native image provided in an embodiment of the present application when applied to a k8s platform, see Fig. 9 When a device for implementing a compressed cloud native image provided in an embodiment of the present application is applied to a k8s platform, the device includes:
[0204] A second determination module 901 is used to determine the image name and version name of the cloud native image to be deployed according to the first deployment code in response to the first deployment code;
[0205] The second sending module 902 is used to send a second PV address request to the configuration center to obtain a second PV address returned by the configuration center; wherein the second PV address request includes the image name and version name of the cloud native image to be deployed, and the configuration center is set outside the k8s platform;
[0206] A generating module 903 is used to mount the second PV address to the first deployment code to generate a second deployment code;
[0207] Running module 904 is used to obtain the cloud native image to be deployed from the cloud native image center according to the second deployment code, and run the dependency package of the cloud native image to be deployed in the storage center according to the second deployment code when the cloud native image to be deployed is running; wherein, the cloud native image center is set outside the k8s platform, the cloud native image center includes multiple cloud native images, the storage center is set outside the k8s platform, and multiple dependency packages are installed in the storage center.
[0208] In a feasible embodiment of the present application, the second determining module 901 includes:
[0209] The first parsing unit is used to call the k8s library of the k8s platform to parse the first deployment code, and obtain the image name and version name of the cloud native image to be deployed corresponding to the first deployment code.
[0210] In a feasible embodiment of the present application, the operation module 904 includes:
[0211] The second parsing unit is used to call the k8s library of the k8s platform to parse the second deployment code, and obtain the image name and version name of the cloud native image to be deployed corresponding to the second deployment code;
[0212] The first sending unit is used to send the image name and version name of the cloud native image to be deployed to the cloud native image center, so as to obtain the cloud native image to be deployed corresponding to the image name and version name from the cloud native image center.
[0213] In a feasible embodiment of the present application, the operation module 904 includes:
[0214] A third determining unit is used to determine a second PV address from a second deployment code when the cloud native image to be deployed is running;
[0215] The second sending unit is used to send a dependency package execution request to the storage area corresponding to the second PV address in the storage center, so as to execute the dependency package of the cloud native image to be deployed in the storage area corresponding to the second PV address in the storage center.
[0216] Fig.10 A schematic diagram of a structure of a device for implementing a compressed cloud native image provided in an embodiment of the present application when applied to a configuration center, referring to Fig.10 When a device for implementing a compressed cloud native image provided in an embodiment of the present application is applied to a configuration center, the device includes:
[0217] The first response module 1001 is used to respond to the first PV address request and return the first PV address to the CI platform; wherein the first PV address is used to instruct the CI platform to install the dependency package of the cloud native image in the storage area corresponding to the first PV address in the storage center when creating the cloud native image;
[0218] The second response module 1002 is used to return the second PV address to the k8s platform in response to the second PV address request; wherein the second PV address is used to instruct the k8s platform to run the dependency package of the cloud native image from the storage area corresponding to the second PV address in the storage center when deploying the cloud native image.
[0219] In a feasible embodiment of the present application, the first response module 1001 includes:
[0220] An acquisition unit is used to obtain an image name and a version number according to the first PV address request; wherein the image name and the version number are used to uniquely identify the cloud native image created by the CI platform;
[0221] A judgment unit, used to search in the storage center according to the image name and the version number, and judge whether there is a first PV address corresponding to the image name and the version number;
[0222] A first returning unit is used to return the first PV address to the CI platform if there is a first PV address corresponding to the image name and the version number;
[0223] The second returning unit is used to, when there is no first PV address corresponding to the image name and version number, use the PV address corresponding to any storage space where the dependent package is not installed as the first PV address, and return the first PV address to the CI platform.
[0224] like Fig.11 As shown, an embodiment of the present application provides an electronic device, including a processor 1101, a communication interface 1102, a memory 1103 and a communication bus 1104, wherein the processor 1101, the communication interface 1102, and the memory 1103 communicate with each other through the communication bus 1104.
[0225] Memory 1103, used for storing computer programs;
[0226] In one embodiment of the present application, the processor 1101 is used to implement a method for compressing a cloud native image provided by any one of the aforementioned method embodiments when executing a program stored in the memory 1103, including:
[0227] Determine the image name and version number of the cloud native image according to the first build code;
[0228] Send a first PV address request to the configuration center, and obtain the first PV address returned by the configuration center; wherein the first PV address request includes the image name and version name of the cloud native image, and the configuration center is set outside the CI platform;
[0229] Determine a dependency package of the cloud native image according to the first build code, and install the dependency package in a storage area corresponding to the first PV address in a storage center according to the first PV address; wherein the storage center is set outside the CI platform;
[0230] The first PV address is mounted on the cloud native image, and the cloud native image mounted with the first PV address is stored in a cloud native image center; wherein the cloud native image center is set outside the CI platform.
[0231] or include:
[0232] In response to the first deployment code, determine an image name and a version name of the cloud native image to be deployed according to the first deployment code;
[0233] Send a second PV address request to the configuration center to obtain the second PV address returned by the configuration center; wherein the second PV address request includes the image name and version name of the cloud native image to be deployed, and the configuration center is set outside the k8s platform;
[0234] Mount the second PV address to the first deployment code to generate the second deployment code;
[0235] According to the second deployment code, the cloud native image to be deployed is obtained from the cloud native image center, and when the cloud native image to be deployed is running, the dependency package of the cloud native image to be deployed is run in the storage center according to the second deployment code; wherein, the cloud native image center is set outside the k8s platform, the cloud native image center includes multiple cloud native images, the storage center is set outside the k8s platform, and multiple dependency packages are installed in the storage center.
[0236] or include:
[0237] In response to the first PV address request, return the first PV address to the CI platform; wherein the first PV address is used to instruct the CI platform to install the dependency package of the cloud native image in the storage area corresponding to the first PV address in the storage center when creating the cloud native image;
[0238] In response to the second PV address request, the second PV address is returned to the k8s platform; wherein the second PV address is used to instruct the k8s platform to run the dependent package of the cloud native image from the storage area corresponding to the second PV address in the storage center when deploying the cloud native image.
[0239] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of a method for implementing a compressed cloud native image as provided in any of the aforementioned method embodiments are implemented.
[0240] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0241] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0242] It should be understood that the terms used in the text are only for the purpose of describing specific example embodiments, and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used in the text may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.
[0243] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A method for implementing a compressed cloud native image, characterized in that: The method is applied to a CI platform, and the CI platform is used to build a cloud native image. The method includes: Determine the image name and version number of the cloud native image according to the first build code; Sending a first PV address request to a configuration center to obtain a first PV address returned by the configuration center; wherein the first PV address request includes the image name and the version name of the cloud native image, and the configuration center is set outside the CI platform; Determine a dependency package of the cloud native image according to the first build code, and install the dependency package in a storage area corresponding to the first PV address in a storage center according to the first PV address; wherein the storage center is set outside the CI platform; The first PV address is mounted on the cloud native image, and the cloud native image mounted with the first PV address is stored in a cloud native image center; wherein the cloud native image center is set outside the CI platform.
2. The method according to claim 1, characterized in that Determining the image name and version number of the cloud native image according to the first build code includes: Reading the image name of the cloud native image from the first build code; Calculate a hash value of the first build code, and determine the hash value of the first build code as the version name of the cloud native image; and / or, An acquisition timestamp of the first build code is obtained, and the acquisition timestamp of the first build code is determined as the version name of the cloud native image.
3. The method according to claim 1, characterized in that Determining a dependency package of the cloud native image according to the build code, and installing the dependency package in a storage area corresponding to the first PV address in a storage center according to the first PV address, including: Modify the installation path of the dependent package in the first build code to the first PV address to generate a second build code; A dependency package installation script is executed according to the second construction code to install the dependency package in the storage area corresponding to the first PV address in the storage center.
4. The method according to claim 1, characterized in that: Before determining the image name and version number of the cloud native image according to the first build code, the method further includes: The first build code is automatically pulled from the code repository based on continuous integration.
5. A method for implementing a compressed cloud native image, characterized in that: The method is applied to a k8s platform, and the k8s platform is used to deploy a cloud native image. The method includes: In response to the first deployment code, determine the image name and version name of the cloud native image to be deployed according to the first deployment code; Send a second PV address request to the configuration center to obtain a second PV address returned by the configuration center; wherein the second PV address request includes the image name and the version name of the cloud native image to be deployed, and the configuration center is set outside the k8s platform; Mount the second PV address on the first deployment code to generate a second deployment code; According to the second deployment code, the cloud native image to be deployed is obtained from the cloud native image center, and when the cloud native image to be deployed is running, the dependency package of the cloud native image to be deployed is run in the storage center according to the second deployment code; wherein, the cloud native image center is arranged outside the k8s platform, the cloud native image center includes multiple cloud native images, the storage center is arranged outside the k8s platform, and multiple dependency packages are installed in the storage center.
6. The method according to claim 5, characterized in that In response to the first deployment code, determining the image name and version name of the cloud native image to be deployed according to the first deployment code includes: The k8s library of the k8s platform is called to parse the first deployment code, and the image name and the version name of the cloud native image to be deployed corresponding to the first deployment code are obtained.
7. The method according to claim 6, characterized in that Obtaining the to-be-deployed cloud native image from a cloud native image center according to the second deployment code includes: Calling the k8s library of the k8s platform to parse the second deployment code, and obtaining the image name and the version name of the cloud native image to be deployed corresponding to the second deployment code; The image name and the version name of the cloud native image to be deployed are sent to the cloud native image center to obtain the cloud native image to be deployed corresponding to the image name and the version name from the cloud native image center.
8. The method according to claim 5, characterized in that When the cloud native image to be deployed is running, the dependent package of the cloud native image to be deployed is run in the storage center according to the second deployment code, including: Determining the second PV address from the second deployment code when the cloud native image to be deployed is running; Send a dependency package execution request to the storage area corresponding to the second PV address in the storage center, so as to execute the dependency package of the cloud native image to be deployed in the storage area corresponding to the second PV address in the storage center.
9. A method for implementing a compressed cloud native image, characterized in that: The method is applied to a configuration center, the configuration center interacts with a CI platform and a k8s platform, the configuration center is used to allocate a first PV address to the CI platform and allocate a second PV address to the k8s platform, and the method includes: In response to the first PV address request, return the first PV address to the CI platform; wherein the first PV address is used to instruct the CI platform to install the dependency package of the cloud native image in the storage area corresponding to the first PV address in the storage center when creating the cloud native image; In response to the second PV address request, the second PV address is returned to the k8s platform; wherein the second PV address is used to instruct the k8s platform to run the dependent package of the cloud native image from the storage area corresponding to the second PV address in the storage center when deploying the cloud native image.
10. The method according to claim 9, characterized in that In response to the first PV address request, returning the first PV address to the CI platform includes: Obtain an image name and a version number according to the first PV address request; wherein the image name and the version number are used to uniquely identify the cloud native image created by the CI platform; Searching in the storage center according to the image name and the version number, determining whether the first PV address corresponding to the image name and the version number exists; If the first PV address corresponding to the image name and the version number exists, returning the first PV address to the CI platform; If the first PV address corresponding to the image name and the version number does not exist, the PV address corresponding to any storage space where the dependent package is not installed is used as the first PV address, and the first PV address is returned to the CI platform.
