A container image pulling method, device, equipment and readable storage medium
By prioritizing container images in edge node clusters and utilizing P2P network transmission, the problems of slow container image download speed and high failure rate are solved, the image pulling efficiency is improved, and the dependence on central nodes is reduced.
Patent Information
- Application Number
- CN202210611110.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-31
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2042-05-31
AI Technical Summary
In the existing technology, the download speed of container images is slow and the failure rate is high. The cached data of the central node needs to be cleaned up regularly, the number of connections is large, and the network is unstable, resulting in low efficiency.
By first searching for the target container image in the edge node cluster, directly pulling it if it exists, and synchronizing the image from the central node if it does not exist, the P2P network of the edge node cluster is used for image transmission, reducing dependence on the central node.
It improves the success rate and efficiency of image pulling, reduces dependence on central nodes, and optimizes network resource utilization.
Smart Images

Figure CN114968283B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of container technology, and in particular to a method, apparatus, device, and computer-readable storage medium for pulling a container image. Background Art
[0002] In Docker technology, a container is a standardized software unit that packages code and all its dependencies so that applications can run reliably and quickly from one computing environment to another. A container image is a lightweight, standalone executable software package that contains all the resources required for application runtime, such as code, runtime, system tools, system libraries, and settings.
[0003] There are two main methods for pulling container images. One is to pull images from the Harbor container image repository on a remote server. This process will cause large network egress traffic in the cloud. The efficiency of image distribution depends on a stable high-bandwidth network. However, the network between the edge cloud and edge nodes is unstable, and network jitter or instability often occurs, resulting in a slow traditional image download rate and a high failure rate. The other method is to first save the image to the central node, and then the central node copies the image to the edge node. Compared with the image pulling method of the Harbor container image repository, this image pulling method reduces the failure rate of image pulling. However, the method of pulling container images from the central node also has certain shortcomings. First, the central node has a lot of cached data and needs to clean up local data regularly. Second, when a large number of edge nodes download images from the central node at the same time, a large number of connections will be occupied.
[0004] In summary, how to effectively solve the problems of slow mirror download speed, high failure rate, need to regularly clean up central node data, and occupying a large number of connections is an urgent problem that technicians in this field need to solve. Summary of the Invention
[0005] An object of the present invention is to provide a method for pulling container images, which improves the success rate of image pulling, enhances the efficiency of image pulling, and reduces dependence on central nodes; another object of the present invention is to provide a container image pulling device, equipment, and computer-readable storage medium.
[0006] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0007] A method for pulling a container image, comprising:
[0008] Parse the received container image pull request to obtain the target edge node that sent the container image pull request and the target container image to be pulled;
[0009] When the target container image exists in the edge node cluster after searching the preset database table, the target container image is pulled from the edge node cluster;
[0010] When the target container image is not found in the node cluster from the preset database table, a retrieval request is sent to the central node so that the central node synchronizes the pre-stored target container image to the target edge node; wherein the target container image in the central node is downloaded and saved from the harbor container image repository.
[0011] In a specific embodiment of the present invention, parsing a received container image pull request to obtain a target edge node that sends the container image pull request and a target container image to be pulled includes:
[0012] Parse the received container image pull request to obtain the target edge node that sent the container image pull request and the target layers and number of layers of the target container image to be pulled;
[0013] Pulling the target container image from the edge node cluster includes:
[0014] Obtaining edge weights corresponding to respective edge nodes in the edge node cluster where the target container image exists;
[0015] Calculating the number of layers to be scheduled corresponding to each edge node according to the number of layers and the edge weights corresponding to each edge node;
[0016] Allocate a target layer to be pulled to each edge node according to the number of layers to be scheduled corresponding to each edge node;
[0017] Pull and allocate the target layers from the edge nodes.
[0018] In a specific embodiment of the present invention, in the process of pulling the target layers obtained by allocation from the edge nodes, the process further includes:
[0019] Determine whether the edge node cluster has a newly added edge node deployed with the target container image;
[0020] If so, get the target layers and number of layers to be pulled;
[0021] Repeat the step of obtaining the edge weight corresponding to each edge node in the edge node cluster where the target container image exists.
[0022] In a specific embodiment of the present invention, in the process of pulling the target layers obtained by allocation from the edge nodes, the process further includes:
[0023] Get the pull results for each target layer separately;
[0024] Update the edge weights of the edge nodes corresponding to the target layer according to the pull result;
[0025] Repeat the step of calculating the number of layers to be scheduled corresponding to each edge node according to the number of layers and the edge weight corresponding to each edge node.
[0026] In a specific embodiment of the present invention, updating the edge weight of the edge node corresponding to the target layer according to the pull result includes:
[0027] When the pulling result is a pulling failure, repeatedly pulling the target layer from the edge node that failed to pull the target layer;
[0028] When repeated pulling for a preset number of times fails, the edge weight of the edge node is adjusted to 0.
[0029] In a specific embodiment of the present invention, updating the edge weight of the edge node corresponding to the target layer according to the pull result includes:
[0030] When the pulling result is a success, the edge weights of the edge nodes that are successfully pulled from the target layer are increased according to a preset weight adjustment rule.
[0031] In a specific embodiment of the present invention, after sending a call request to the central node so that the central node synchronizes the pre-stored target container image to the target edge node, the method further includes:
[0032] Get the mirror synchronization result;
[0033] An update operation is performed on the preset database table according to the mirror synchronization result.
[0034] A container image pulling device, comprising:
[0035] A request parsing module is used to parse the received container image pull request to obtain the target edge node that sent the container image pull request and the target container image to be pulled;
[0036] An image pulling module is configured to pull the target container image from the edge node cluster when finding from a preset database table that the target container image exists in the edge node cluster;
[0037] The image synchronization module is used to send a call request to the central node when the target container image is not found in the node cluster from the preset database table, so that the central node synchronizes the pre-stored target container image to the target edge node; wherein, the target container image in the central node is downloaded and saved from the harbor container image repository.
[0038] A container image pulling device, comprising:
[0039] memory for storing computer programs;
[0040] A processor is configured to implement the steps of the aforementioned method for pulling a container image when executing the computer program.
[0041] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the container image pulling method as described above.
[0042] The container image pulling method provided by the present invention parses a received container image pulling request to obtain a target edge node for sending the container image pulling request and a target container image to be pulled; when the target container image exists in the edge node cluster found from a preset database table, the target container image is pulled from the edge node cluster; when the target container image does not exist in the node cluster found from the preset database table, a call request is sent to the central node, so that the central node synchronizes the pre-stored target container image to the target edge node; wherein the target container image in the central node is downloaded and saved from the harbor container image repository.
[0043] It can be seen from the above technical solution that when it is necessary to pull a container image, the target container image to be pulled is first checked in the edge node cluster. If the target container image exists in the edge node cluster, the target container image is directly pulled from the edge node cluster. If the target container image does not exist in the edge node cluster, a call request is sent to the central node, and then the central node synchronizes the pre-stored target container image to the target edge node that sent the container image pull request. By giving priority to edge nodes for image pulling, the success rate of image pulling is improved, the efficiency of image pulling is improved, and the dependence on the central node is reduced.
[0044] Correspondingly, the present invention also provides a container image pulling device, equipment, and computer-readable storage medium corresponding to the above-mentioned container image pulling method, which have the above-mentioned technical effects and are not further described here. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0046] Figure 1 This is a flowchart of an implementation method of a container image pulling method according to an embodiment of the present invention;
[0047] Figure 2 This is another implementation flowchart of the method for pulling a container image in an embodiment of the present invention;
[0048] Figure 3 This is a structural block diagram of a container image pulling system according to an embodiment of the present invention;
[0049] Figure 4 This is a structural block diagram of a container image pulling device according to an embodiment of the present invention;
[0050] Figure 5 This is a structural block diagram of a container image pulling device according to an embodiment of the present invention;
[0051] Figure 6 A schematic diagram of the specific structure of a container image pulling device provided in this embodiment. DETAILED DESCRIPTION
[0052] In order to enable those skilled in the art to better understand the present invention, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the embodiments described are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0053] See also Figure 1 , Figure 1 This is a flowchart of an implementation method for pulling a container image in an embodiment of the present invention. The method may include the following steps:
[0054] S101: Parse the received container image pull request to obtain the target edge node for sending the container image pull request and the target container image to be pulled.
[0055] When it is necessary to pull a mirrored container, a container image pull request is sent to the mirrored container pull control center. The container image pull request includes the target edge node for sending the container image pull request and the target container image to be pulled. The mirrored container pull control center receives the container image pull request and parses the received container image pull request to obtain the target edge node for sending the container image pull request and the target container image to be pulled. If the container image pull request may include the node identification information of the target edge node for sending the container image pull request and the container image identification information of the target container image to be pulled, the mirrored container pull control center may determine the target edge node for sending the container image pull request and the target container image to be pulled based on the parsed node identification information of the target edge node for sending the container image pull request and the container image identification information of the target container image to be pulled.
[0056] S102: When it is found from the preset database table that the target container image exists in the edge node cluster, the target container image is pulled from the edge node cluster.
[0057] An edge node cluster and a database table are pre-set, and the container images existing on each edge node in the edge node cluster are pre-stored in the pre-set database table. After parsing the target edge node for sending the container image pull request and the target container image to be pulled, the pre-set database table is searched to see if the target container image to be pulled exists in the edge node cluster. If the target container image exists in the edge node cluster, the target container image is pulled from the edge node cluster.
[0058] For example, if it is determined that the target edge node sending the container image pull request already has the target container image, the target container image can be retrieved from the target edge node first. Edge nodes can also be divided into availability zones, with edge nodes in the same network segment managed in the same availability zone. After adding the edge node to the edge node cluster, a label specifying the availability zone is added to the edge node. Based on the node label, a P2P (peer-to-peer) network is created for edge nodes in the same availability zone, forming a P2P peer relationship between edge nodes. This allows for management of the P2P network between edge nodes, prioritizing container image transfer within the P2P network. If the target container image does not exist on the target edge node, but exists on other edge nodes in the same availability zone as the target edge node, the target container image is pulled from the other edge nodes in the same availability zone as the target edge node. If the target container image does not exist on either the target edge node or other edge nodes in the same availability zone as the target edge node, but exists on edge nodes in other availability zones, the target container image is pulled from edge nodes in other availability zones. This ensures direct sharing of data between nodes and allows for efficient pulling of container images.
[0059] S103: When no target container image is found in the node cluster from the preset database table, a retrieval request is sent to the central node, so that the central node synchronizes the pre-stored target container image to the target edge node.
[0060] The target container image in the central node is downloaded and saved from the harbor container image repository.
[0061] A central node is pre-set, and container images from the Harbor container image repository are pre-synchronized to the central node. For example, a job service is used to periodically synchronize container images to a designated storage (typically the central node's local storage or external storage). Deploy the Inget-server on the central node and the Insget-client on the edge nodes. The edge node's Insget intercepts and parses container image pull requests. A new database table, image_local, is created to maintain image information. After Harbor container images are synchronized to the central node, the central node's existing container images are also updated to the image_local database table. If the target container image is not found in the pre-set database table in the node cluster, indicating that the target container image does not exist on any edge node, a pull request is sent to the central node. The central node synchronizes the pre-stored target container image to the target edge node. By prioritizing edge nodes for image pulls, the success rate and efficiency of image pulls are improved, while reducing dependence on the central node.
[0062] In a specific embodiment of the present invention, after sending a call request to the central node so that the central node synchronizes the pre-stored target container image to the target edge node, the method may further include the following steps:
[0063] Step 1: Get the mirror synchronization result;
[0064] Step 2: Update the preset database table based on the mirror synchronization result.
[0065] For the convenience of description, the above two steps can be combined for explanation.
[0066] After the central node synchronizes the pre-stored target container image with the target edge node, it obtains the image synchronization results and updates the preset database table based on the image synchronization results. Specifically, after the target edge node synchronizes with the target container image, the existence of the target container image on the target edge node is recorded in the preset database table. This facilitates subsequent pulls of the target container image from the target edge node, such as pulling specific container image layers within the target container image from the target edge node.
[0067] It can be seen from the above technical solution that when it is necessary to pull a container image, the target container image to be pulled is first checked in the edge node cluster. If the target container image exists in the edge node cluster, the target container image is directly pulled from the edge node cluster. If the target container image does not exist in the edge node cluster, a call request is sent to the central node, and then the central node synchronizes the pre-stored target container image to the target edge node that sent the container image pull request. By giving priority to edge nodes for image pulling, the success rate of image pulling is improved, the efficiency of image pulling is improved, and the dependence on the central node is reduced.
[0068] It should be noted that, based on the above embodiment, the embodiment of the present invention also provides corresponding improved solutions. In subsequent embodiments, the same steps or corresponding steps as those in the above embodiment can be referenced to each other, and the corresponding beneficial effects can also be referenced to each other, and will not be described in detail in the following improved embodiments.
[0069] See also Figure 2 , Figure 2 This is another implementation flowchart of a method for pulling a container image according to an embodiment of the present invention. The method may include the following steps:
[0070] S201: Parse the received container image pull request to obtain the target edge node for sending the container image pull request and the target layers and layer numbers of the target container image to be pulled.
[0071] When pulling a container image, you may need to pull only a subset of the image layers used by the target container image. A container image pull request can include the target edge node sending the container image pull request and the target layers and layer count of the target container image to be pulled. When receiving a container image pull request, it is parsed to obtain the target edge node sending the container image pull request and the target layers and layer count of the target container image to be pulled. When pulling an image, instead of downloading the entire image, the required layers are pulled as needed, improving image pull efficiency.
[0072] S202: When it is found from the preset database table that the target container image exists in the edge node cluster, the edge weight corresponding to each edge node in the edge node cluster where the target container image exists is obtained.
[0073] Preset the initial edge weight for each edge node in the edge node cluster that holds the target container image. Since nodes in the same availability zone are consistent during the initial pull, you can set the edge weight for nodes in that availability zone to 100 and the edge weight for nodes in other availability zones to 80. Container image weights are bidirectional. For example, if the edge weight of edge node A pulling from edge node B is 100, then the edge weight of edge node B pulling from edge node A is also 100.
[0074] When it is found from the preset database table that the target container image exists in the edge node cluster, the edge weight corresponding to each edge node in the edge node cluster where the target container image exists is obtained.
[0075] When pulling an image, you can find the manifest of the corresponding image based on the image name + tag, and then find the corresponding image layer from each edge node based on the sha256 and media type of the image layer in the manifest.
[0076] S203: Calculate the number of layers to be scheduled corresponding to each edge node according to the number of layers and the edge weight corresponding to each edge node.
[0077] After obtaining the edge weights corresponding to each edge node in the edge node cluster that contains the target container image, calculate the number of layers to be scheduled for each edge node based on the number of layers and the edge weights corresponding to each edge node. The number of layers to be scheduled for each edge node can be calculated using the following formula:
[0078] Math.Round((WP_n / (WP_1+WP_2+..+WP_n))*N);
[0079] Where N is the number of layers of the target container image to be pulled, WP_n is the weight corresponding to each edge node, and Math.Round(.) represents the rounding function.
[0080] S204: Allocate the target layer to be pulled to each edge node according to the number of layers to be scheduled corresponding to each edge node.
[0081] After the number of layers to be scheduled corresponding to each edge node is calculated, the target layer to be pulled is allocated to each edge node according to the number of layers to be scheduled corresponding to each edge node.
[0082] See also Figure 3 , Figure 3 This is a block diagram of a container image pulling system in an embodiment of the present invention. Node A issues a container image pull (docker pull) command (taking nodes B, C, D, and F as an example, where images are available). To pull images from edge nodes with relatively good performance and stable networks, assuming a total of 10 target layers need to be pulled, calculations can allocate three target layers to nodes B and C, and three to nodes D and F.
[0083] The Insget-client in the edge node obtains all target layers of the image based on the container image's ID (identity document). Based on the scheduling policy, different target layers are downloaded from different nodes. This decentralized downloading not only improves download efficiency but also reduces the number of processes on the same node.
[0084] S205: Pull the allocated target layers from each edge node.
[0085] After assigning target layers to each edge node based on the number of layers to be scheduled, the target layers are pulled from each edge node. Pulling container images concurrently from multiple nodes is supported, improving image pulling efficiency.
[0086] In a specific embodiment of the present invention, in the process of pulling the allocated target layers from the edge nodes, the method may further include the following steps:
[0087] Step 1: Determine whether there is a newly added edge node in the edge node cluster that has the target container image deployed. If so, proceed to step 2. If not, do nothing.
[0088] Step 2: Obtain the target layers and layer numbers to be pulled, and repeat step S202 to obtain the edge weights corresponding to the edge nodes in the edge node cluster that have the target container image.
[0089] For the convenience of description, the above two steps can be combined for explanation.
[0090] In the process of pulling the allocated target layers from each edge node, determine whether there are newly added edge nodes with the target container image deployed in the edge node cluster. If so, it is necessary to adjust the number of layers to be pulled allocated to the edge node with the target container image. As the number of available nodes and downloaded layers continues to change, obtain the current target layers to be pulled and the number of layers, and obtain the edge weights corresponding to each edge node with the target container image in the edge node cluster. Reallocate the target layers to be pulled to each edge node according to the current edge weight, the target layers to be pulled, and the number of layers. If not, it means that there is no need to adjust the number of layers to be pulled allocated to the edge node with the target container image, and no processing is performed.
[0091] In a specific embodiment of the present invention, in the process of pulling the allocated target layers from the edge nodes, the method may further include the following steps:
[0092] Step 1: Get the pull results of each target layer respectively;
[0093] Step 2: Update the edge weights of the edge nodes corresponding to the target layer according to the pull results, and repeat step S203.
[0094] For the convenience of description, the above two steps can be combined for explanation.
[0095] In the process of pulling the allocated target layers from each edge node, the pulling results of each target layer are obtained respectively, and the edge weights of the edge nodes corresponding to the target layer are updated according to the pulling results. The number of layers to be scheduled corresponding to each edge node is calculated according to the current number of layers to be pulled and the edge weights corresponding to each edge node.
[0096] In a specific embodiment of the present invention, updating the edge weights of the edge nodes corresponding to the target layer according to the pull results may include the following steps:
[0097] Step 1: When the pull result is a pull failure, repeatedly pull the target layer from the edge node that failed to pull the target layer;
[0098] Step 2: When repeated pulling for a preset number of times fails, the edge weight of the edge node is adjusted to 0.
[0099] For the convenience of description, the above two steps can be combined for explanation.
[0100] When the pull result is a pull failure, the target layer is repeatedly pulled from the edge node that failed to pull the target layer. When the pull results of repeated pulls for the preset number of times are all failures, it indicates that the edge node may be faulty. The edge weight of the edge node is adjusted to 0 to avoid interference from the faulty node, improve the success rate of container image pulling, and improve the efficiency of container image pulling.
[0101] It should be noted that the preset number of times can be set and adjusted according to actual conditions, and the embodiment of the present invention does not limit this.
[0102] In a specific embodiment of the present invention, updating the edge weights of the edge nodes corresponding to the target layer according to the pull results may include the following steps:
[0103] When the pull result is a success, the edge weights of the edge nodes that are successfully pulled to the target layer are increased according to the preset weight adjustment rules.
[0104] When the pull result is a successful pull, the edge weight of the edge node that successfully pulls the target layer is adjusted upward according to the preset weight adjustment rules. The edge weight of the edge node corresponding to the target layer can be updated by the formula WP_n*R*101 / 100, where WP_n is the original node weight of the edge node, the pull success rate of the edge node R=T / (T+C), T is the number of layers that are successfully pulled, and C is the number of layers that failed to pull. By increasing the edge weight of the edge node that is successfully pulled, the image can be pulled from the edge node with relatively good performance and relatively stable network, further improving the success rate of container image pulling and improving the efficiency of container image pulling.
[0105] S206: When no target container image is found in the node cluster from the preset database table, a retrieval request is sent to the central node, so that the central node synchronizes the pre-stored target container image to the target edge node.
[0106] The target container image in the central node is downloaded and saved from the harbor container image repository.
[0107] Corresponding to the above method embodiment, the present invention further provides a container image pulling device. The container image pulling device described below and the container image pulling method described above can refer to each other.
[0108] See also Figure 4 , Figure 4 This is a structural block diagram of a container image pulling device according to an embodiment of the present invention. The device may include:
[0109] The request parsing module 41 is used to parse the received container image pull request to obtain the target edge node for sending the container image pull request and the target container image to be pulled;
[0110] The image pulling module 42 is configured to pull the target container image from the edge node cluster when the target container image is found in the edge node cluster from the preset database table;
[0111] The image synchronization module 43 is used to send a call request to the central node when the target container image is not found in the node cluster from the preset database table, so that the central node synchronizes the pre-stored target container image to the target edge node; wherein, the target container image in the central node is downloaded and saved from the harbor container image repository.
[0112] It can be seen from the above technical solution that when it is necessary to pull a container image, the target container image to be pulled is first checked in the edge node cluster. If the target container image exists in the edge node cluster, the target container image is directly pulled from the edge node cluster. If the target container image does not exist in the edge node cluster, a call request is sent to the central node, and then the central node synchronizes the pre-stored target container image to the target edge node that sent the container image pull request. By giving priority to edge nodes for image pulling, the success rate of image pulling is improved, the efficiency of image pulling is improved, and the dependence on the central node is reduced.
[0113] In a specific embodiment of the present invention, the request parsing module 41 is specifically a module that parses the received container image pull request to obtain the target edge node for sending the container image pull request and the target layers and layer numbers of the target container image to be pulled;
[0114] The image pull module includes:
[0115] The edge weight acquisition submodule is used to obtain the edge weight corresponding to each edge node in the edge node cluster where the target container image exists;
[0116] The submodule for calculating the number of layers to be scheduled is used to calculate the number of layers to be scheduled corresponding to each edge node according to the number of layers and the edge weights corresponding to each edge node;
[0117] The image layer allocation submodule is used to allocate the target layer to be pulled to each edge node according to the number of layers to be scheduled corresponding to each edge node;
[0118] The image layer pulling submodule is used to pull the allocated target layers from each edge node.
[0119] In a specific embodiment of the present invention, the device may further include:
[0120] A judgment module is used to judge whether there is a newly added edge node with a target container image deployed in the edge node cluster during the process of pulling the allocated target layers from each edge node;
[0121] The module for obtaining layers to be pulled and the number of layers is used to obtain the target layers and the number of layers to be pulled when it is determined that there is a newly added edge node with a target container image deployed in the edge node cluster, and trigger the edge weight acquisition submodule.
[0122] In a specific embodiment of the present invention, the device may further include:
[0123] A pull result acquisition module is used to obtain the pull results of each target layer in the process of pulling the allocated target layers from each edge node;
[0124] The weight update module is used to update the edge weights of the edge nodes corresponding to the target layer according to the pull results, and trigger the sub-module for calculating the number of layers to be scheduled.
[0125] In a specific embodiment of the present invention, the weight updating module includes:
[0126] The repeated pulling submodule is used to repeatedly pull the target layer from the edge node that failed to pull the target layer when the pulling result is a pull failure;
[0127] The weight adjustment submodule is used to adjust the edge weight of the edge node to 0 when the pulling results of repeated pulling for a preset number of times all fail.
[0128] In a specific embodiment of the present invention, the weight updating module is specifically a module that increases the edge weight of the edge node successfully pulled to the target layer according to a preset weight adjustment rule when the pulling result is successful.
[0129] In a specific embodiment of the present invention, the device may further include:
[0130] An image synchronization result acquisition module is used to obtain the image synchronization result after sending a call request to the central node so that the central node synchronizes the pre-stored target container image to the target edge node;
[0131] The database table update module is used to update the preset database table according to the mirror synchronization result.
[0132] Corresponding to the above method embodiment, see Figure 5 , Figure 5 This is a schematic diagram of a container image pulling device provided by the present invention, which may include:
[0133] Memory 332, for storing computer programs;
[0134] The processor 322 is configured to implement the steps of the container image pulling method of the above method embodiment when executing a computer program.
[0135] For details, please refer to Figure 6 , Figure 6 A schematic diagram of the specific structure of a container image pulling device provided in this embodiment, which may have relatively large differences due to different configurations or performances, may include a processor (central processing units, CPU) 322 (for example, one or more processors) and a memory 332, and the memory 332 stores one or more computer applications 342 or data 344. Among them, the memory 332 can be a temporary storage or a persistent storage. The program stored in the memory 332 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the data processing device. Furthermore, the processor 322 can be configured to communicate with the memory 332 to execute a series of instruction operations in the memory 332 on the container image pulling device 301.
[0136] The container image pulling device 301 may further include one or more power supplies 326 , one or more wired or wireless network interfaces 350 , one or more input and output interfaces 358 , and / or one or more operating systems 341 .
[0137] The steps in the container image pulling method described above can be implemented by the structure of the container image pulling device.
[0138] Corresponding to the above method embodiment, the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the following steps can be implemented:
[0139] The received container image pull request is parsed to obtain the target edge node for sending the container image pull request and the target container image to be pulled; when the target container image exists in the edge node cluster from the preset database table, the target container image is pulled from the edge node cluster; when the target container image does not exist in the node cluster from the preset database table, a call request is sent to the central node so that the central node synchronizes the pre-stored target container image to the target edge node; wherein, the target container image in the central node is downloaded and saved from the harbor container image repository.
[0140] The computer-readable storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., which can store program codes.
[0141] For an introduction to the computer-readable storage medium provided by the present invention, please refer to the above method embodiment, and the present invention will not elaborate on it here.
[0142] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from the other embodiments. References to the same or similar parts between the various embodiments are sufficient. The devices, apparatuses, and computer-readable storage media disclosed in the embodiments are described briefly because they correspond to the methods disclosed in the embodiments. For relevant details, refer to the description of the methods.
[0143] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only intended to help understand the technical solutions and core concepts of the present invention. It should be noted that those skilled in the art can make various improvements and modifications to the present invention without departing from the principles of the present invention, and such improvements and modifications also fall within the scope of protection of the claims of the present invention.
Claims
1. A method for pulling a container image, characterized in that: include: Parse the received container image pull request to obtain the target edge node that sent the container image pull request and the target container image to be pulled; When the target container image exists in the edge node cluster after searching the preset database table, the target container image is pulled from the edge node cluster; When the target container image is not found in the edge node cluster from the preset database table, a retrieval request is sent to the central node so that the central node synchronizes the pre-stored target container image to the target edge node; wherein the target container image in the central node is downloaded and saved from the harbor container image repository; The received container image pull request is parsed to obtain the target edge node for sending the container image pull request and the target container image to be pulled, including: Parse the received container image pull request to obtain the target edge node that sent the container image pull request and the target layers and number of layers of the target container image to be pulled; Pulling the target container image from the edge node cluster includes: Obtaining edge weights corresponding to respective edge nodes in the edge node cluster where the target container image exists; Calculating the number of layers to be scheduled corresponding to each edge node according to the number of layers and the edge weights corresponding to each edge node; Allocate a target layer to be pulled to each edge node according to the number of layers to be scheduled corresponding to each edge node; Pull and allocate the target layers from the edge nodes.
2. The method for pulling a container image according to claim 1, wherein: In the process of pulling the target layers obtained by allocation from the edge nodes, the method further includes: Determine whether the edge node cluster has a newly added edge node deployed with the target container image; If so, get the target layers and number of layers to be pulled; Repeat the step of obtaining the edge weight corresponding to each edge node in the edge node cluster where the target container image exists.
3. The method for pulling a container image according to claim 1 or 2, wherein: In the process of pulling the target layers obtained by allocation from the edge nodes, the method further includes: Get the pull results for each target layer separately; Update the edge weights of the edge nodes corresponding to the target layer according to the pull result; Repeat the step of calculating the number of layers to be scheduled corresponding to each edge node according to the number of layers and the edge weight corresponding to each edge node.
4. The method for pulling a container image according to claim 3, wherein: An operation is performed on the edge weight of the edge node corresponding to the target layer according to the pull result, including: When the pulling result is a pulling failure, repeatedly pulling the target layer from the edge node that failed to pull the target layer; When repeated pulling for a preset number of times fails, the edge weight of the edge node is adjusted to 0.
5. The method for pulling a container image according to claim 3, wherein: An operation is performed on the edge weight of the edge node corresponding to the target layer according to the pull result, including: When the pulling result is a success, the edge weights of the edge nodes that are successfully pulled from the target layer are increased according to a preset weight adjustment rule.
6. The method for pulling a container image according to claim 1, wherein: After sending a call request to the central node so that the central node synchronizes the pre-stored target container image to the target edge node, the method further includes: Get the mirror synchronization result; An update operation is performed on the preset database table according to the mirror synchronization result.
7. A container image pulling device, characterized in that: include: A request parsing module is used to parse the received container image pull request to obtain the target edge node that sent the container image pull request and the target container image to be pulled; An image pulling module is configured to pull the target container image from the edge node cluster when finding from a preset database table that the target container image exists in the edge node cluster; An image synchronization module is configured to, when the target container image is not found in the edge node cluster from the preset database table, send a retrieval request to the central node so that the central node synchronizes the pre-stored target container image to the target edge node; wherein the target container image in the central node is downloaded and saved from the Harbor container image repository; The request parsing module is specifically configured to parse the received container image pull request to obtain the target edge node that sends the container image pull request and the target layers and number of layers of the target container image to be pulled; The image pulling module is specifically used to obtain the edge weight corresponding to each edge node in the edge node cluster where the target container image exists; calculate the number of layers to be scheduled corresponding to each edge node according to the number of layers and the edge weight corresponding to each edge node; allocate the target layer to be pulled to each edge node according to the number of layers to be scheduled corresponding to each edge node; and pull the allocated target layers from each edge node.
8. A container image pulling device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the container image pulling method according to any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the container image pulling method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Image pulling method and related product
WO2021232289A1