Mirror image file acquisition method and device and computing equipment
By using the private mirror warehouse address information in the container orchestration platform to modify the call request, ensuring that the target mirror file is obtained from the private mirror warehouse, solving the problem of unsuccessful acquisition of mirror files under disconnection or the public mirror warehouse is restricted, and improving success rate and security.
Patent Information
- Application Number
- CN202510229175.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-27
- Publication Date
- 2025-07-25
AI Technical Summary
In container orchestration platforms, the success rate of obtaining target image files is low, especially when the network connection is disconnected or the public image repository is restricted, resulting in container deployment failure.
By storing the address information of the private mirror repository on the computing device, intercepting the first call request and modifying it to the second call request, ensuring that the request is directed to the private mirror repository to obtain the target image file, and even automatically switch to the public mirror repository when the private mirror repository fails to obtain, ensuring that the image file is successfully acquired.
Improves the success rate of acquisition of target image files, reduces dependence on public image repositories, enhances security and efficiency, and improves the success rate of container deployment.
Smart Images

Figure CN120371601A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of virtual machines, and in particular, to a method, apparatus, and computing device for obtaining an image file. Background Art
[0002] A container orchestration platform (such as K8s) manages the life cycle of containers through a container runtime interface (CRI), including operations such as creating, starting, stopping, and deleting containers. During the container creation phase, it is necessary to obtain the target image file required for container creation from an image repository. During the process of obtaining the target image file, the kubelet component on K8s calls the CRI, and obtains the target image file from the image repository through the CRI. After successfully obtaining the target image file, the container orchestration platform creates a container based on the target image file. It can be seen that successfully obtaining the target image file is the basis for creating a container, and it is necessary to improve the success rate of obtaining the target image file. Summary of the Invention
[0003] Embodiments of this application provide a method, apparatus, and computing device for obtaining an image file, thereby improving the success rate of obtaining a target image file.
[0004] In a first aspect, an embodiment of this application provides a method for obtaining an image file, which is applied to a computing device. A target configuration file is stored on the computing device, and the target configuration file includes address information of a private image repository. The private image repository is deployed on the computing device or interconnected with the computing device through a local area network. The method includes: obtaining a first call request, where the first call request includes an identifier of a target image file; obtaining address information of a first image repository from the target configuration file, where the first image repository is one of the private image repositories; modifying the first call request into a second call request according to the address information of the first image repository, where the second call request includes the identifier of the target image file and the address information of the first image repository; and obtaining the target image file according to the second call request.
[0005] In this way, by intercepting the first call request and modifying the first call request into a second call request based on the address information of the private image repository in the target configuration file, and then obtaining the target image file according to the second call request. Since the second call request includes the identifier of the target image file and the address information of the first image repository, therefore, regardless of whether the original first call request includes the address information of the image repository, it can be directed to the private image repository to search for and obtain the target image file. In this way, it is realized that even in specific scenarios (such as when the target interface is docker, the network connection between the computing device and the Internet is disconnected, or the public image repository is restricted, etc.), the business requirement of preferentially obtaining the target image file from the private image repository can be met, thereby improving the success rate of obtaining the target image file and reducing the situation of container deployment (creation) failure. And, by preferentially obtaining the target image file from the private image repository, the dependence on public image repositories such as dockerhub is reduced, and the efficiency and security of obtaining the target image file are improved.
[0006] In addition, by setting the address information of the private image repository through the target configuration file, it is possible to direct different types of target interfaces to the private image repository to search for and obtain the target image file according to the address information of the private image repository, without changing the configuration of the target interface. Especially in the scenario where the target interface is containerd, there is no need to separately configure the address information of each specified image repository in the first call request in the containerd configuration file. That is to say, there is no need to perform cumbersome configuration for different types of target interfaces, which improves the compatibility and simplicity of configuring the private image repository for different target interfaces.
[0007] In a possible implementation manner of the first aspect, modifying the first call request into a second call request according to the address information of the first image repository includes: if the first call request further includes the address information of the public image repository, then replacing the address information of the public image repository with the address information of the first image repository to obtain the second call request, and the public image repository includes the image repositories maintained by the community and / or the official.
[0008] In another possible implementation manner of the first aspect, modifying the first call request into a second call request according to the address information of the first image repository includes: if the first call request further includes the address information of the private image repository, then in the case where the target configuration file does not include the address information of the private image repository, replacing the address information of the private image repository with the address information of the first image repository to obtain the second call request.
[0009] In another possible implementation of the first aspect, modifying the first call request to a second call request according to the address information of the first image repository includes: if the first call request does not include the address information of the image repository, adding the address information of the first image repository to the first call request to obtain the second call request.
[0010] In this way, in different scenarios where the first call request includes the address information of the public image repository, the private image repository, or does not include the address information of the image repository, etc., it is possible to preferentially obtain the target image file from the private image repository. Thus, there is no need to modify the kubelet component and the target interface (such as CRI).
[0011] In a possible implementation of the first aspect, if there is one private image repository, the method further includes: obtaining return information, where the return information is used to indicate that the target image file is successfully obtained or the target image file is not successfully obtained. When it is responded that the return information indicates that the target image file is not successfully obtained, obtaining the target image file from the public image repository. In this way, even if obtaining the target image file from the private image repository fails, it is still possible to try to find and obtain the target image file from the public image repository, further improving the success rate of obtaining the target image file.
[0012] In a possible implementation of the first aspect, if there are N private image repositories, where N is an integer greater than 1, the address information of the first image repository is the address information of the first private image repository traversed from the target configuration file. The method further includes: obtaining the return information of the i-th time, where the return information is used to indicate that the target image file is successfully obtained or the target image file is not successfully obtained; i is an integer greater than or equal to 1 and less than or equal to N. When it is responded that the return information of the i-th time indicates that the target image file is not successfully obtained, traversing to the address information of the (i + 1)-th private image repository from the target configuration file, and modifying the first call request according to the address information of the (i + 1)-th private image repository, so as to obtain the target image file according to the modified call request until N acquisitions are completed or the return information indicates that the target image file is successfully obtained.
[0013] In this way, through the traversal method, it is possible to automatically and orderly modify the first call request, avoid disorder, and realize that when obtaining the target image file from the previous private image repository fails, automatically and efficiently try to obtain the target image file from the next private image repository, and so on in a loop until all private image repositories are traversed (that is, try to obtain the target image file from all private image repositories) or the target image file is successfully obtained. Since N private image repositories are set, the resource coverage range of the private image repository is expanded, and the success rate of obtaining the target image file from the private image repository is further improved.
[0014] In a possible implementation of the first aspect, the method further includes: if there are N private image repositories and the return information for the i-th time indicates that the acquisition of the target image file fails, then acquire the target image file from the public image repository. In this way, if the acquisition of the target image file fails in all the private image repositories in the target configuration file, then attempt to search for and acquire the target image file from the public image repository, expanding the scope for acquiring the target image file and further improving the success rate of acquiring the target image file from the private image repository.
[0015] In a possible implementation of the first aspect, acquiring the target image file according to the second call request includes: calling the container runtime interface according to the second call request to acquire the target image file. In this way, the container runtime interface is directed to the private image repository (specifically, in the first image repository) through the second call request, and the target image file is acquired from the first image repository according to the identifier of the target image file. On the one hand, it meets the requirement of acquiring the target image file from the private image repository. On the other hand, the target image file can be acquired more efficiently and accurately according to the identifier of the target image file.
[0016] In a possible implementation of the first aspect, the first call request is used to call the container runtime interface to acquire the target image file. The return value of the second call request has the same format as the return value returned to the first call request. In this way, the image file acquisition module conforms to the container runtime interface standard and can act as a transparent proxy. For example, the image file acquisition module is set between the kubelet component and the CRI, and is unaware of the middleware between the kubelet component and the CRI. The image file acquisition module does not change the communication protocol between the kubelet component and the CRI, nor does it affect the normal working process of the kubelet component and the CRI, but only plays a role in the process of acquiring the target image file.
[0017] In a possible implementation of the first aspect, if there are N private image repositories, where N is an integer greater than 1, and the first image repository is one of the N private image repositories that meets the preset conditions, and the preset conditions include that the number of image files in the private image repository is greater than or equal to the preset number. In this way, by selecting the private image repository with a larger number of image files as the first image repository, it is possible to search for and acquire the target image file within the largest possible range of image files, so as to search for and acquire the target image file from the first image repository as much as possible, thereby improving the acquisition efficiency.
[0018] In a possible implementation of the first aspect, modifying the first invocation request to a second invocation request according to the address information of the first image repository further includes: when the switch state of the target function is in the on state, modifying the first invocation request to a second invocation request according to the address information of the first image repository, where the target function is used to indicate the function of obtaining the target image file from the private image repository. In this way, through the switch state of the target function, it is clear whether it is necessary to enable the image file acquisition module to execute the operation of obtaining the target image file from the private image repository. For example, when it is necessary to enable the image file acquisition module, the image file acquisition module executes the operation of modifying the first invocation request to a second invocation request according to the address information of the first image repository, which enables the image file acquisition module to be flexibly applied according to actual needs.
[0019] In a possible implementation of the first aspect, the method further includes: in response to detecting that the current scenario is a preset scenario, setting the switch state of the target function to the on state; the preset scenario includes: the network connection between the computing device and the Internet is disconnected, and / or the public image repository has closed the access permission of the computing device. In this way, by setting the switch state of the target function to the on state in the preset scenario, it is possible to effectively handle scenarios such as the network connection between the computing device and the Internet being disconnected and the access to the public image repository being restricted, and further solve the problem of how to improve the success rate of obtaining the target image file in an environment where obtaining the target image file from the public image repository is restricted. It realizes a more comprehensive satisfaction of the business requirement of preferentially obtaining the target image file from the private image repository.
[0020] In a possible implementation of the first aspect, the method further includes: in response to a first instruction from the caller, deleting the address information of the private image repository in the target configuration file, where the first instruction is used to indicate deleting the address information of the private image repository in the target configuration file. In this way, by deleting the address information of the private image repository in the target configuration file, the image file acquisition module becomes ineffective and only plays a role in information transmission between the caller and the target interface, so as to enable the target interface to obtain the target image file from more aspects (such as the public image repository, the private image repository), which is more flexible.
[0021] In a possible implementation of the first aspect, the method further includes: in response to a second instruction from the caller, obtaining the list of image files in the cache and returning the list of image files in the cache to the caller, where the list of image files is used to represent the available image files in the cache, and the second instruction is used to indicate viewing the available image files in the cache. In this way, through the target interface, it is possible to efficiently and accurately obtain the list of image files in the cache and then return the list of image files to the caller, which can meet the needs of the caller.
[0022] In a possible implementation of the first aspect, the method further includes: in response to a third instruction from a caller, determining whether a specified mirror file exists in the cache and the status of the specified mirror file when it exists, and returning the determination result to the caller. The third instruction is used to indicate querying the status of the specified mirror file in the cache. In this way, through the target interface, it is possible to efficiently and accurately determine whether a specified mirror file exists in the cache and the status of the specified mirror file when it exists, and return the mirror file list to the caller, which can meet the requirements of the caller.
[0023] In a possible implementation of the first aspect, the method further includes: in response to a fourth instruction from a caller, determining whether a specified mirror file exists in the cache, and in the case where the specified mirror file exists in the cache, deleting the specified mirror file from the cache through the target interface. In this way, the deletion of the specified mirror file from the cache is realized.
[0024] In a possible implementation of the first aspect, the method further includes: in response to a fifth instruction from a caller, obtaining mirror file system information and returning the mirror file system information to the caller. The mirror file system information includes the disk usage and / or available space of the mirror file system. In this way, returning the mirror file system information to the caller is realized.
[0025] In a second aspect, an embodiment of the present application provides another method for obtaining a mirror file, which is applied to a computing device. A target configuration file is stored on the computing device. The target configuration file includes address information of a private image repository. The private image repository is deployed on the computing device or interconnected with the computing device through a local area network. The method includes: obtaining a creation request of a container. Determining a first call request according to the creation request of the container. The first call request includes an identifier of a target mirror file, and the target mirror file is the mirror file corresponding to the container. Obtaining the address information of a first image repository from the target configuration file. The first image repository is one of the private image repositories. Modifying the first call request into a second call request according to the address information of the first image repository. The second call request includes the identifier of the target mirror file and the address information of the first image repository. Obtaining the target mirror file according to the second call request. Creating a container according to the target mirror file.
[0026] In this way, an overall process from obtaining the creation request of the container to creating the container is shown. It is realized that even in specific scenarios (such as when the target interface is docker, the network connection between the computing device and the Internet is disconnected, or the public image repository is restricted, etc.), the business requirement of preferentially obtaining the target mirror file from the private image repository can be met, thereby improving the success rate of obtaining the target mirror file and further improving the success rate of creating the container.
[0027] In a possible implementation of the second aspect, modifying the first call request to a second call request according to the address information of the first image repository includes: if the first call request further includes the address information of a public image repository, replacing the address information of the public image repository with the address information of the first image repository to obtain the second call request, where the public image repository includes image repositories maintained by the community and / or officially.
[0028] In another possible implementation of the second aspect, modifying the first call request to a second call request according to the address information of the first image repository includes: if the first call request further includes the address information of a private image repository, and when the target configuration file does not include the address information of the private image repository, replacing the address information of the private image repository with the address information of the first image repository to obtain the second call request.
[0029] In another possible implementation of the second aspect, modifying the first call request to a second call request according to the address information of the first image repository includes: if the first call request does not include the address information of an image repository, adding the address information of the first image repository to the first call request to obtain the second call request.
[0030] In a possible implementation of the second aspect, if there is one private image repository, the method further includes: obtaining return information, where the return information is used to indicate that obtaining the target image file is successful or obtaining the target image file fails. When the return information indicates that obtaining the target image file fails, obtaining the target image file from the public image repository.
[0031] In another possible implementation of the second aspect, if there are N private image repositories, N is an integer greater than 1, and the address information of the first image repository is the address information of the first private image repository traversed from the target configuration file. The method further includes: obtaining the return information of the i-th time, where the return information is used to indicate that obtaining the target image file is successful or obtaining the target image file fails; i is an integer greater than or equal to 1 and less than or equal to N. When the return information of the i-th time indicates that obtaining the target image file fails, traversing to the address information of the (i + 1)-th private image repository from the target configuration file, and modifying the first call request according to the address information of the (i + 1)-th private image repository to obtain the target image file according to the modified call request until N acquisitions are completed or the return information indicates that the target image file is successful.
[0032] In a possible implementation of the second aspect, the method further includes: if there are N private image repositories and the return information of the i-th time all indicates that obtaining the target image file fails, obtaining the target image file from the public image repository.
[0033] In a possible implementation of the second aspect, the first call request is used to call the container runtime interface to obtain the target mirror file. The return value of the second call request has the same format as the return value returned to the first call request.
[0034] In a possible implementation of the second aspect, if there are N private mirror repositories, where N is an integer greater than 1, the first mirror repository is one of the N private mirror repositories that meets the preset conditions, and the preset conditions include that the number of mirror files in the private mirror repository is greater than or equal to the preset number.
[0035] In a possible implementation of the second aspect, modifying the first call request to the second call request according to the address information of the first mirror repository further includes: when the switch state of the target function is in the on state, modifying the first call request to the second call request according to the address information of the first mirror repository, and the target function is used to indicate the function of obtaining the target mirror file from the private mirror repository.
[0036] In a possible implementation of the second aspect, the method further includes: in response to detecting that the current scenario is a preset scenario, setting the switch state of the target function to the on state; the preset scenario includes: the network connection between the computing device and the Internet is disconnected, and / or, the public mirror repository has closed the access permission of the computing device.
[0037] In a possible implementation of the second aspect, the method further includes: in response to the first instruction of the caller, deleting the address information of the private mirror repository in the target configuration file, and the first instruction is used to indicate deleting the address information of the private mirror repository in the target configuration file.
[0038] In a possible implementation of the second aspect, the method further includes: in response to the second instruction of the caller, obtaining the mirror file list in the cache and returning the mirror file list in the cache to the caller, and the mirror file list is used to represent the available mirror files in the cache, and the second instruction is used to indicate viewing the available mirror files in the cache.
[0039] In a possible implementation of the second aspect, the method further includes: in response to the third instruction of the caller, determining whether a specified mirror file exists in the cache and the status of the specified mirror file when it exists, and returning the determination result to the caller, and the third instruction is used to indicate querying the status of the specified mirror file in the cache.
[0040] In a possible implementation of the second aspect, the method further includes: in response to the fourth instruction of the caller, determining whether a specified mirror file exists in the cache, and if the specified mirror file exists in the cache, deleting the specified mirror file from the cache.
[0041] In a possible implementation of the second aspect, the method further includes: in response to a fifth instruction of a caller, obtaining mirror file system information and returning the mirror file system information to the caller, where the mirror file system information includes the disk usage and / or available space of the mirror file system.
[0042] In a third aspect, an embodiment of the present application provides a mirror file acquisition device, which is applied to a computing device. A target configuration file is stored on the computing device, and the target configuration file includes address information of a private mirror repository. The private mirror repository is deployed on the computing device or interconnected with the computing device through a local area network. The device includes: a first acquisition module, configured to acquire a first call request, where the first call request includes an identifier of a target mirror file. A second acquisition module, configured to acquire address information of a first mirror repository from the target configuration file, where the first mirror repository is one of the private mirror repositories. A modification module, configured to modify the first call request into a second call request according to the address information of the first mirror repository, where the second call request includes the identifier of the target mirror file and the address information of the first mirror repository. A third acquisition module, configured to acquire the target mirror file according to the second call request.
[0043] In a possible implementation of the third aspect, when the modification module modifies the first call request into the second call request according to the address information of the first mirror repository, it is specifically configured to: if the first call request further includes address information of a public mirror repository, replace the address information of the public mirror repository with the address information of the first mirror repository to obtain the second call request, where the public mirror repository includes a mirror repository maintained by a community and / or an official.
[0044] In another possible implementation of the third aspect, when the modification module modifies the first call request into the second call request according to the address information of the first mirror repository, it is specifically configured to: if the first call request further includes address information of a private mirror repository, and when the target configuration file does not include the address information of the private mirror repository, replace the address information of the private mirror repository with the address information of the first mirror repository to obtain the second call request.
[0045] In another possible implementation of the third aspect, when the modification module modifies the first call request into the second call request according to the address information of the first mirror repository, it is specifically configured to: if the first call request does not include address information of a mirror repository, add the address information of the first mirror repository to the first call request to obtain the second call request.
[0046] In a possible implementation of the third aspect, the apparatus further includes: a fourth acquisition module. The fourth acquisition module is configured to, when there is one private image repository, acquire return information, where the return information is used to indicate that the acquisition of the target image file is successful or the acquisition of the target image file fails. And when it is responsive to the return information indicating that the acquisition of the target image file fails, acquire the target image file from the public image repository.
[0047] In another possible implementation of the third aspect, the apparatus further includes: a fifth acquisition module, a traversal module, and a second modification module. The fifth acquisition module is configured to, when there are N private image repositories, acquire the return information of the i-th time. N is an integer greater than 1, and the address information of the first image repository is the address information of the first private image repository traversed from the target configuration file. The return information is used to indicate that the acquisition of the target image file is successful or the acquisition of the target image file fails; i is an integer greater than or equal to 1 and less than or equal to N. The traversal module is configured to, when it is responsive to the return information of the i-th time indicating that the acquisition of the target image file fails, traverse the address information of the (i + 1)-th private image repository from the target configuration file. The second modification module is configured to modify the first call request according to the address information of the (i + 1)-th private image repository, so as to acquire the target image file according to the modified call request until N acquisitions are completed or the return information indicates that the target image file is successful.
[0048] In a possible implementation of the third aspect, the apparatus further includes: a sixth acquisition module, configured to, when there are N private image repositories and the return information of the i-th time all indicates that the acquisition of the target image file fails, acquire the target image file from the public image repository.
[0049] In a possible implementation of the third aspect, when the third acquisition module acquires the target image file according to the second call request, it is specifically configured to: call the container runtime interface according to the second call request to acquire the target image file.
[0050] In a possible implementation of the third aspect, the first call request is used to call the container runtime interface to acquire the target image file. The return value of the second call request has the same format as the return value returned to the first call request.
[0051] In a possible implementation of the third aspect, if there are N private image repositories, N is an integer greater than 1, and the first image repository is one of the N private image repositories that meets the preset conditions, where the preset conditions include that the number of image files in the private image repository is greater than or equal to the preset number.
[0052] In a possible implementation of the third aspect, when the modification module modifies the first call request to the second call request according to the address information of the first image repository, it is specifically further configured to: when the switch state of the target function is in the on state, modify the first call request to the second call request according to the address information of the first image repository, and the target function is used to indicate the function of obtaining the target image file from the private image repository.
[0053] In a possible implementation of the third aspect, the apparatus further includes: a setting module, configured to set the switch state of the target function to the on state in response to detecting that the current scenario is a preset scenario; the preset scenario includes: the network connection between the computing device and the Internet is disconnected, and / or the public image repository has closed the access permission of the computing device.
[0054] In a possible implementation of the third aspect, the apparatus further includes: a first deletion module, configured to delete the address information of the private image repository of the target configuration file in response to a first instruction from the caller, and the first instruction is used to indicate deleting the address information of the private image repository of the target configuration file.
[0055] In a possible implementation of the third aspect, the apparatus further includes: an image file list acquisition module, configured to acquire the image file list in the cache and return the image file list in the cache to the caller in response to a second instruction from the caller, and the image file list is used to represent the available image files in the cache, and the second instruction is used to indicate viewing the available image files in the cache.
[0056] In a possible implementation of the third aspect, the apparatus further includes: a determination module, configured to determine whether a specified image file exists in the cache and the status of the specified image file when it exists in response to a third instruction from the caller, and return the determination result to the caller, and the third instruction is used to indicate querying the status of the specified image file in the cache.
[0057] In a possible implementation of the third aspect, the apparatus further includes: a second deletion module, configured to determine whether a specified image file exists in the cache in response to a fourth instruction from the caller, and delete the specified image file from the cache if the specified image file exists in the cache.
[0058] In a possible implementation of the third aspect, the apparatus further includes: an image file system information acquisition module, configured to acquire the image file system information and return the image file system information to the caller in response to a fifth instruction from the caller, and the image file system information includes the disk usage and / or available space of the image file system.
[0059] Fourthly, an embodiment of the present application provides another mirror file acquisition device, which is applied to a computing device. A target configuration file is stored on the computing device. The target configuration file includes address information of a private mirror repository, and the private mirror repository is deployed on the computing device or interconnected with the computing device through a local area network. The device includes: a first module, a second module, and a Container Runtime Interface (CRI). Specifically: The first module is configured to obtain a creation request of a container, determine a first call request according to the creation request of the container, and send the first call request to the second module. The first call request includes an identifier of a target mirror file, and the target mirror file is a mirror file corresponding to the container; it is further configured to create a container according to the target mirror file. The second module is configured to obtain the first call request, obtain the address information of the first mirror repository from the target configuration file, modify the first call request into a second call request according to the address information of the first mirror repository, and send the second call request to the CRI; the first mirror repository is one of the private mirror repositories, and the second call request includes the identifier of the target mirror file and the address information of the first mirror repository; it is further configured to receive the target mirror file returned by the CRI and return the target mirror file to the first module; The CRI is configured to obtain the second call request, obtain the target mirror file according to the second call request, and send the target mirror file to the second module.
[0060] Fifthly, an embodiment of the present application provides a computing device, including: a processor and a memory for storing processor-executable instructions. When the processor is configured to execute the instructions, the computing device implements the method as described above.
[0061] Sixthly, an embodiment of the present application provides a storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a computing device, the computing device implements the method as described above.
[0062] Among them, the technical effects brought by any implementation manner in the second to sixth aspects can refer to the technical effects brought by different implementation manners in the first aspect, which will not be elaborated here.
[0063] Based on the implementation manners provided in the above aspects of the present application, further combinations can be made to provide more implementation manners. Description of the Drawings
[0064] Figure 1 It is a schematic diagram of a platform provided by an embodiment of the present application;
[0065] Figure 2 It is a schematic structural diagram of a computing device 1 provided by an embodiment of the present application;
[0066] Figure 3 It is another schematic structural diagram of a computing device 1 provided by an embodiment of the present application;
[0067] Figure 4 A visualization schematic diagram of a method for obtaining an image file provided by an embodiment of the present application;
[0068] Figure 5 A flowchart of a method for obtaining an image file provided by an embodiment of the present application;
[0069] Figure 6 A structural schematic diagram of a module for obtaining an image file provided by an embodiment of the present application;
[0070] Figure 7 A flowchart of another method for obtaining an image file provided by an embodiment of the present application;
[0071] Figure 8 A flowchart of another method for obtaining an image file provided by an embodiment of the present application;
[0072] Figure 9 A flowchart of another method for obtaining an image file provided by an embodiment of the present application;
[0073] Figure 10 A flowchart of another method for obtaining an image file provided by an embodiment of the present application;
[0074] Figure 11 A flowchart of another method for obtaining an image file provided by an embodiment of the present application;
[0075] Figure 12 A flowchart of another method for obtaining an image file provided by an embodiment of the present application;
[0076] Figure 13 A flowchart of another method for obtaining an image file provided by an embodiment of the present application;
[0077] Figure 14 A structural schematic diagram of a device for obtaining an image file provided by an embodiment of the present application;
[0078] Figure 15 A structural schematic diagram of another device for obtaining an image file provided by an embodiment of the present application;
[0079] Figure 16 A structural schematic diagram of another computing device 1 provided by an embodiment of the present application. Detailed implementation manners
[0080] Next, the technical solutions in the embodiments of the present application will be described in conjunction with the accompanying drawings in the embodiments of the present application.
[0081] Among them, in the description of this application, unless otherwise specified, " / " indicates that the objects associated before and after are in an "or" relationship. For example, A / B may represent A or B. The "and / or" in this application is merely a relationship describing the associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. Here, A and B may be singular or plural.
[0082] Moreover, in the description of this application, unless otherwise specified, "a plurality of" means two or more than two. "At least one (item)" or its similar expressions refer to any combination of these items, including any combination of single item(s) or plural item(s). For example, at least one (item) of a, b, or c may represent: a, b, c, a - b, a - c, b - c, or a - b - c, where a, b, and c may be single or plural.
[0083] In addition, to facilitate a clear description of the technical solutions of the embodiments of this application, in the embodiments of this application, terms such as "first" and "second" are used to distinguish identical or similar items with basically the same functions and roles. Those skilled in the art can understand that terms such as "first" and "second" do not limit the quantity and execution order, and terms such as "first" and "second" do not necessarily mean different. At the same time, in the embodiments of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design solution described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Exactly, using words such as "exemplary" or "for example" aims to present relevant concepts in a specific way for easy understanding.
[0084] Hereinafter, a brief introduction to the relevant terms involved in the embodiments of this application will be given.
[0085] Kubernetes: Abbreviated as K8s, it is an open-source container orchestration platform. K8s simplifies the operation and maintenance of application programs through automated container deployment, scaling, and management.
[0086] CRI: It is an application programming interface (API) defined by K8s for realizing the interaction between the container runtime and K8s. CRI allows K8s to use different container runtimes, such as Docker, Containerd, or rkt. Through CRI, K8s can manage the life cycle of containers, including operations such as creating, starting, stopping, and deleting containers.
[0087] kubelet: It is the main component running on the K8s worker node. It is responsible for handling tasks such as the creation, update, and deletion of container pods, starting and stopping containers, and monitoring the health status of containers.
[0088] Image registry: In the embodiments of the present application, it is used to store and distribute container images, providing a centralized storage location for containerized applications. In the image registry, developers can upload, manage, and share base images and application images for creating containers. These images contain all the files and metadata required to run the application, enabling K8s to pull and run these images from the image registry.
[0089] Dockerhub: It is a public container image registry that contains a large number of image files maintained by the community and officially. It is an important resource for developers to obtain and distribute images in containerized application development.
[0090] Address information of the image registry: It is used to locate the specific path or identifier address of the image registry, including protocols (such as HTTP, HTTPS, etc.), server addresses (which can be domain names or IP addresses), etc. For example, the address information of the image registry can be specifically expressed as "https: / / www.docker.com / " or "https: / / k8s.io / v2 / ".
[0091] Image domain name: It is used to identify the name of the image registry server and is part of the address information of the image registry. For example, if the address information of the image registry is expressed as "https: / / k8s.io / v2 / ", the image domain name can be "k8s.io". If the address information of the image registry is expressed as "https: / / www.docker.com / ", the image domain name can be "www.docker.com".
[0092] Hereinafter, an exemplary introduction to the application scenario of the embodiments of the present application will be given.
[0093] The container orchestration platform (hereinafter referred to as the platform, such as K8s) manages the life cycle of containers through CRI, including operations such as creating, starting, stopping, and deleting containers. The container orchestration platform is deployed on a computing device (hereinafter referred to as computing device 1). In the container creation phase, it is necessary to first obtain the target image file required for container creation from the image registry. Taking K8s as an example, in the process of obtaining the target image file, the kubelet component on K8s calls CRI and obtains the target image file from the image registry through CRI. After successfully obtaining the target image file, a container is created based on the target image file. It can be seen that successfully obtaining the target image file is the basis for creating a container. Therefore, there is a need to improve the success rate of obtaining the target image file.
[0094] Image repositories are divided into public image repositories (such as dockerhub) and private image repositories. Among them, public image repositories include those maintained by the community and / or official (also known as official image repositories), which are usually open source; private image repositories are deployed on computing device 1 or interconnected with computing device 1 through a local area network. That is to say, even when the platform is unable to connect to the Internet, the private image repository can communicate with the CRI through the local area network. For the convenience of description, the designated image repository mentioned in the embodiments of the present application can be a public image repository or a private image repository.
[0095] In view of this, in combination with Figure 1 As shown, the embodiments of the present application provide a schematic diagram of a platform. As Figure 1 As shown, the platform includes a kubelet component, an image file acquisition module, and a CRI. When the kubelet component calls the CRI to obtain a target image file, the image file acquisition module obtains the call request used by the kubelet component to call the CRI, modifies the call request, and calls the CRI according to the modified call request. The modified call request includes the address information of the private image repository, so that the CRI obtains the target image file from the private image repository. Among them, the image file acquisition module exists in the form of middleware.
[0096] Next, an exemplary introduction to the system architecture of the embodiments of the present application will be given.
[0097] In combination with Figure 2 As shown, the embodiments of the present application provide a schematic diagram of the structure of computing device 1. As Figure 2 As shown, the platform is deployed in computing device 1.
[0098] Among them, a target configuration file is stored on computing device 1, and the target configuration file includes the address information of the private image repository. The private image repository is deployed on computing device 1 or interconnected with computing device 1 through a local area network. Exemplarily, the private image repository stores one or more image files.
[0099] For example, image repositories 1-n (n represents the first quantity) are deployed on computing device 1, and these image repositories 1-n belong to private image repositories. Computing device 2 represents one or more computing devices other than computing device 1. Image repositories 1-p (p represents the second quantity) and image repositories 1-m (m represents the third quantity) are deployed on computing device 2. When computing device 1 and computing device 2 are interconnected through a local area network, image repositories 1-p and image repositories 1-m belong to private image repositories.
[0100] In some embodiments, the platform includes a kubelet component, an image file acquisition module, and a target interface, where
[0101] An image file acquisition module, configured to acquire a first call request, where the first call request includes an identifier of a target image file. The image file acquisition module is further configured to acquire address information of a first image repository from a target configuration file, where the first image repository is one of private image repositories. The image file acquisition module is further configured to modify the first call request into a second call request according to the address information of the first image repository, where the second call request includes the identifier of the target image file and the address information of the first image repository. In addition, the image file acquisition module is further configured to acquire the target image file according to the second call request.
[0102] Exemplarily, the image file acquisition module acquires the first call request from the kubelet component.
[0103] Exemplarily, the first call request is used to call a target interface to acquire the target image file.
[0104] In one implementation, the image file acquisition module acquiring the target image file according to the second call request includes: the image file acquisition module calling a target interface according to the second call request to acquire the target image file.
[0105] Exemplarily, the return value of the second call request has the same format as the return value returned to the first call request. It can be understood that the image file acquisition module is disposed between the kubelet component and the target interface. That is to say, the image file acquisition module connects the caller and the target interface. In this way, the image file acquisition module intercepts the first call request for the kubelet component to call the target interface, modifies the first call request into a second call request, and then calls the target interface according to the second call request to direct the target interface to search for and acquire the target image file in the private image repository.
[0106] Exemplarily, the target interface may be CRI. Thus, in the scenario of container creation, when the kubelet component calls CRI to acquire the target image file, the first call request is intercepted by the image file acquisition module, modified into a second call request, and CRI is called based on the second call request, so that CRI preferentially acquires the target image file from the private image repository.
[0107] In a possible implementation, the first call request may or may not include the address information of the specified image repository. Based on this, the processing logic of the image file acquisition module is divided into the following two cases: ① If the first call request does not include the address information of the specified image repository, that is, the first call request does not include the address information of the image repository (without including the address information of any image repository), then: the image file acquisition module adds the address information of the first image repository to the first call request to obtain a second call request. ② If the first call request also includes the address information of the specified image repository, then: the address information of the specified image repository may be the address information of a public image repository. In this case, the image file acquisition module replaces the address information of the public image repository with the address information of the first image repository to obtain a second call request; the address information of the specified image repository may also be the address information of a private image repository. In this case, it is necessary to determine whether the address information of the private image repository belongs to the target configuration file. If it belongs, the first call request is not modified. If it does not belong, the address information of the private image repository is replaced with the address information of the first image repository.
[0108] Exemplarily, the address information of the image repository may be an image domain name. For example, if the first call request includes: k8s.io / pause:3.9, where k8s.io is the image domain name (i.e., the address information of the public image repository), and pause is the identifier of the target image file. It can be seen that in addition to the identifier of the target image file, the first call request also includes the address information of the public image repository. If the first call request includes: nginx:latest, where nginx is the identifier of the target image file. It can be seen that the first call request does not include the address information of the image repository.
[0109] In some embodiments, the image file acquisition module is further configured to monitor whether the target configuration file is updated (such as updating the address information of the private image repository therein), and after the target configuration file is updated, obtain the updated target configuration file in real time, and then direct the target interface to a private image repository according to the address information of the private image repository in the updated target configuration file, without restarting the service of the target interface, which improves the flexibility and availability of obtaining the target image file. For example, if it is necessary to update the address information of the private image repository, it is only necessary to add or delete the corresponding address information of the private image repository in the target configuration file, without restarting the target interface service, thus avoiding affecting the target interface service.
[0110] In some embodiments, if there is one private image repository, the image file acquisition module is further configured to obtain the return information, and when it is responsive to the return information indicating that the acquisition of the target image file fails, obtain the target image file from the public image repository. The return information is used to indicate that the acquisition of the target image file is successful or the acquisition of the target image file fails.
[0111] Specifically, the return information is returned by the target interface to the image file acquisition module. That is, the image file acquisition module obtains the return information of the target interface.
[0112] Further, if the return information indicates that the acquisition of the target image file is successful, the return information includes the target image file.
[0113] In other embodiments, if there are N private image repositories, where N is an integer greater than 1, the address information of the first image repository is the address information of the first private image repository traversed from the target configuration file, and the image file acquisition module is further configured to obtain the return information of the i-th time, where i is an integer greater than or equal to 1 and less than or equal to N. And when it is responsive to the return information of the i-th time indicating that the acquisition of the target image file fails, traverse the address information of the (i + 1)-th private image repository from the target configuration file, and modify the first call request according to the address information of the (i + 1)-th private image repository, so as to obtain the target image file according to the modified call request until N acquisitions are completed or the return information indicates that the target image file is successful.
[0114] In one implementation, if there are N private image repositories and the return information of the i-th time all indicates that the acquisition of the target image file fails, the image file acquisition module is further configured to obtain the target image file from the public image repository.
[0115] In this way, regardless of whether the number of private image repositories in the target configuration file is one or more, the target image file is preferentially obtained from all the private image repositories set in the target configuration file. Even if the target image file is not successfully obtained in all the private image repositories, it is still possible to try to obtain the target image file from the public image repository, covering the comprehensive acquisition paths of the private image repository and the public image repository, and further improving the success rate and efficiency of obtaining the target image.
[0116] In the embodiments of the present application, the computing device 1 may refer to a single computing device or a computing device cluster.
[0117] In the embodiments of the present application, the computing device 1 may specifically be a network device. The network device may include a server, etc. Among them, the server may be a physical server, or may be two or more physical servers sharing different responsibilities and cooperating with each other to implement the various functions of the server. When the computing device is multiple servers, the scheduling system is a server cluster with high availability capabilities.
[0118] Exemplarily, the server may be a blade server, a high-density server, a rack server, or a tower server, etc.
[0119] Among them, the hardware part of the computing device 1 includes a processor, a basic input / output system (BIOS) chip, an out-of-band controller, and a memory. The software part mainly includes BIOS, an out-of-band management module, and an operating system (OS), as Figure 3 shown, the embodiments of the present application provide another structural schematic diagram of the computing device 1.
[0120] The processor may include a central processing unit (CPU). The CPU includes one or more CPU cores, and the operations of processing data by the CPU are all executed by the CPU cores. The more CPU cores included in the CPU, the faster the data processing speed. In the embodiments of the present application, the processor in the computing device 1 is used as a scheduler to execute the above workflow scheduling method.
[0121] The BIOS chip is a chip set on the motherboard for initializing and detecting various hardware during the startup process of the computing device 1. The BIOS chip includes a flash memory area.
[0122] The out-of-band management module is located inside the out-of-band controller, and the operating system is located inside the processor.
[0123] The out-of-band management module may be a management unit for non-business modules. For example, the out-of-band management module can remotely maintain and manage the computing device 1 through a dedicated data channel. The out-of-band management module is completely independent of the operating system of the computing device 1 and can communicate with the BIOS and the operating system through the out-of-band management interface of the computing device 1.
[0124] Exemplarily, the out-of-band management module may include a management unit for computing device operation status, a management system in a management chip, a computing device motherboard management unit (baseboard management controller, BMC), a system management module (system management mode, SMM), etc. It should be noted that the embodiments of the present application do not limit the specific form of the out-of-band management module, and the above is only an exemplary description.
[0125] OS is a computer program that manages and controls the hardware and software resources of the computing device 1. Any other software must be supported by the operating system to run. After the computing device 1 is powered on, the BIOS first starts a series of operations such as self-test and initialization, and then guides the OS to start, so that the user can use the computing device 1 normally.
[0126] BIOS is a set of programs fixed to the BIOS chip on the motherboard of the computing device 1. The main function of BIOS is to provide the most basic and direct hardware settings and controls for the computing device 1.
[0127] The memory, also called internal memory or main memory, is installed in a memory slot on the motherboard of the computing device 1 .
[0128] It should be noted that the system architecture and application scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Ordinary technicians in this field can know that with the evolution of the system architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0129] For ease of understanding, the image file acquisition method provided in the embodiment of the present application is exemplarily introduced below in combination with the above system architecture and accompanying drawings.
[0130] like Figure 4 As shown, an embodiment of the present application provides a visual schematic diagram of a method for obtaining an image file, and the method is executed by the above-mentioned image file acquisition module. First, obtain a first call request (from the kubelet component). Secondly, obtain the address information of the first image warehouse from the target configuration file. Then, according to the address information of the first image warehouse, modify the first call request to a second call request. Finally, obtain the target image file according to the second call request (specifically, the target interface can be called according to the second call request to obtain the target image file).
[0131] In addition, when all private image repositories included in the target configuration file fail to obtain the target image file, the method further includes: obtaining the target image file from a public image repository.
[0132] In this way, by intercepting the first call request and modifying the first call request into a second call request based on the address information of the private image repository in the target configuration file, and then obtaining the target image file according to the second call request (invoking the target interface). Since the second call request includes the identifier of the target image file and the address information of the first image repository, therefore, regardless of whether the initial first call request includes the address information of the image repository, it can be directed to the private image repository to search for and obtain the target image file. In this way, it is realized that even in specific scenarios (such as when the target interface is docker, the network connection between the computing device and the Internet is disconnected, or the public image repository is restricted, etc.), the business requirement of preferentially obtaining the target image file from the private image repository can be met, thereby improving the success rate of obtaining the target image file and reducing the situation of container deployment (creation) failure. And, by preferentially obtaining the target image file from the private image repository, the dependence on public image repositories such as dockerhub is reduced, and the efficiency and security of obtaining the target image file are improved.
[0133] In addition, by setting the address information of the private image repository through the target configuration file, it is possible to direct different types of target interfaces to the private image repository to search for and obtain the target image file according to the address information of the private image repository, without changing the configuration of the target interface. Especially in the scenario where the target interface is containerd, there is no need to separately configure the private image repository for the address information of each specified image repository in the first call request in the containerd configuration file. That is to say, there is no need to perform cumbersome configuration for different types of target interfaces, which improves the compatibility and simplicity of configuring the private image repository for different target interfaces.
[0134] As Figure 5 shown, an embodiment of the present application provides a schematic flowchart of a method for obtaining an image file. This method is applied to a computing device 1, and the method can be executed by an image file obtaining module in the computing device 1. The method includes:
[0135] S501, obtain a first call request.
[0136] Among them, the first call request includes the identifier of the target image file. Exemplarily, the identifier of the image file can be an image name, such as pause, nginx, etc. It can be understood that the target image file can be determined through the identifier of the target image file.
[0137] Exemplarily, the first call request is used to obtain the target image file.
[0138] Exemplarily, the first call request may be a call request for a kubelet component to call a target interface, and the image file acquisition module intercepts the call request and obtains the first call request.
[0139] Exemplarily, the first call request may include the address information of the specified image repository, where the specified image repository may be a private image repository or a public image repository. For example, if the first call request includes: k8s.io / pause:3.9, where k8s.io is the address information of the specified image repository (specifically the address information of the public image repository), then the first call request includes the address information of the specified image repository.
[0140] Exemplarily, the first call request may not include address information indicating the image repository. Here, it can be understood that the first call request does not include address information of a public image repository, nor does it include address information of a private image repository, such as nginx:latest.
[0141] S502: Obtain address information of the first image repository from the target configuration file.
[0142] The first image repository is one of the private image repositories.
[0143] The target configuration file is stored in computing device 1. The target configuration file includes the address information of the private image repository. Exemplarily, the address information may be a URL. In other words, the target configuration file specifies the address information (such as a URL) of the private image repository, and these private image repositories are all available (i.e., accessible to the target interface, their image files can be searched, and the target image files can be obtained therefrom). In this way, based on the address information, the corresponding private image repository can be accessed in a targeted manner, and the target image file can be searched therefrom, so that the user can uniformly set the address information of the private image repository through the target configuration file without having to worry about the specific implementation of the underlying target interface, thereby improving the compatibility and ease of configuration for different target interfaces.
[0144] Exemplarily, the number of private image repositories may be one or N, where N is an integer greater than 1.
[0145] In some embodiments, the address information of the first image repository is the address information of the first private image repository traversed from the target configuration file. In this way, starting from the address information of the first private image repository in the target configuration file, trying to obtain the target image file is more orderly, avoiding repeated operations (such as repeatedly selecting the address information of the same private image repository as the address information of the first image repository), and improving efficiency.
[0146] In some other embodiments, the first image repository is one of the N private image repositories that meet the preset conditions, and the preset conditions include that the number of image files in the private image repository is greater than or equal to the preset number. In this way, by selecting a private image repository with a larger number of image files as the first image repository, it is possible to search for and obtain the target image file within the range of as large an image file as possible, so as to realize searching for and obtaining the target image file from the first image repository as much as possible, thereby improving the acquisition efficiency.
[0147] Exemplarily, the preset number can be set according to the actual needs of the user.
[0148] Exemplarily, if the number of private image repositories that meet the preset conditions among the N private image repositories is not unique, then for the private image repositories that meet the preset conditions, select the private image repository including the largest number of image files as the first image repository, or randomly select one as the first image repository.
[0149] In some other embodiments, the N private image repositories have a preset priority. The first image repository is the one with the highest priority among the N private image repositories. In this way, the first image repository can be determined more efficiently, thus better meeting the actual needs of the user.
[0150] S503. Modify the first call request to a second call request according to the address information of the first image repository.
[0151] Wherein, the second call request includes the identifier of the target image file and the address information of the first image repository. It can be understood that operations such as accessing, searching for, and obtaining the target image file in the first image repository can be performed through the identifier of the target image file and the address information of the first image repository.
[0152] In some embodiments, the return value of the second call request has the same format as the return value returned to the first call request. In this way, it is realized that the image file acquisition module conforms to the CRI standard and can act as a transparent proxy, being unaware of both the kubelet component and the CRI middleware. The image file acquisition module does not change the communication protocol between the kubelet component and the CRI, nor does it affect the normal working process of the kubelet component and the CRI, but only plays a role in the process of obtaining the target image file.
[0153] In addition, by setting an image file acquisition module between the caller (kubelet component) and the CRI, and since the target configuration file includes the address information of the private image repository, the differences in configuring private image repositories between different CRIs are simplified, providing a unified and simple method for users to configure the address information of private image repositories.
[0154] In some embodiments, modifying the first call request to a second call request according to the address information of the first image repository includes: if the first call request further includes the address information of a public image repository, replacing the address information of the public image repository with the address information of the first image repository to obtain the second call request. Alternatively, if the first call request further includes the address information of a private image repository, when the target configuration file does not include the address information of the private image repository, replacing the address information of the private image repository with the address information of the first image repository to obtain the second call request. Alternatively, if the first call request does not include the address information of an image repository, adding the address information of the first image repository to the first call request to obtain the second call request.
[0155] It can be understood that modifying the first call request to a second call request according to the address information of the first image repository is divided into different scenarios: First, in the scenario where the first call request further includes the address information of a specified image repository, the address information of the specified image repository may be the address information of a public image repository or the address information of a private image repository. If the address information of the specified image repository is the address information of a public image repository, replacing the address information of the public image repository with the address information of the first image repository; if the address information of the specified image repository is the address information of a private image repository, it is necessary to determine whether the address information of the private image repository exists in the target configuration file. If it exists, there is no need to replace the address information of the private image repository. If it does not exist, modifying the address information of the private image repository to the address information of the first image repository. Another scenario is when the first call request does not include the address information of an image repository. It can be considered that the first call request does not include the address information of any image file. At this time, adding the address information of the first image repository to the first call request to obtain the second call request.
[0156] In the embodiments of the present application, regardless of whether the address information of an image repository is specified in the first call request, it is possible to preferentially obtain the target image file from the private image repository. Thus, there is no need to modify the kubelet component and the target interface (such as CRI).
[0157] In one implementation, the method further includes: if the first call request further includes the address information of a private image repository, determining whether the target configuration file includes the address information of the private image repository. In this way, by first determining whether the target configuration file includes the address information of the private image repository, it is further determined whether the first call request needs to be modified.
[0158] In some embodiments, the method further includes: if the first call request further includes the address information of the private image repository and the target configuration file includes the address information of the private image repository, obtaining the target image file according to the first call request. In this way, when the target configuration file includes the address information of the private image repository in the first call request, it is not necessary to modify the first call request, and the target image file can be directly obtained from the corresponding private image repository by using the first call request.
[0159] In other embodiments, modifying the first call request to the second call request according to the address information of the first image repository further includes: when the switch state of the target function is in the on state, modifying the first call request to the second call request according to the address information of the first image repository.
[0160] Among them, the target function is used to indicate the function of obtaining the target image file from the private image repository. It can be understood that when it is necessary to obtain the target image file from the private image repository, the function of the image file acquisition module can be utilized to meet the requirement of obtaining the target image file from the private image repository.
[0161] Specifically, when the switch state of the target function is in the on state, it indicates that it is necessary to enable the image file acquisition module to implement the target function; while when the switch state of the target function is in the off state, it indicates that it is not necessary to enable the image file acquisition module to implement the target function.
[0162] In the embodiments of the present application, through the switch state of the target function, it is clear whether it is necessary to enable the image file acquisition module to obtain the target image file from the private image repository. For example, when it is necessary to enable the image file acquisition module, the image file acquisition module performs the operation of modifying the first call request to the second call request according to the address information of the first image repository. When it is not necessary to enable the image file acquisition module, the image file acquisition module does not need to perform the above operation, which enables the image file acquisition module to be flexibly applied according to actual needs. That is to say, when the switch state of the target function is in the on state, the operation of modifying the first call request to the second call request according to the address information of the first image repository takes effect. On the contrary, when the switch state of the target function is in the off state, the above operation does not take effect, and only the received first call request needs to be passed into the target interface, expanding the application scenario of the image file acquisition module.
[0163] In one implementation, the method further includes: in response to detecting that the current scenario is a preset scenario, setting the switch state of the target function to the on state.
[0164] Among them, the preset scenarios include: the network connection between the computing device 1 and the Internet is disconnected. And / or, the public image repository has closed the access permission for the computing device 1. In this way, the preset scenarios clarify that the target interface needs to obtain the target image file from the private image repository.
[0165] In the embodiments of the present application, by setting the switch state of the target function to the on state in the preset scenario, it is possible to effectively cope with scenarios such as the disconnection of the network connection between the computing device 1 and the Internet and the restricted access to the public image repository, and further solve the problem of how to improve the success rate of obtaining the target image file in an environment where obtaining the target image file from the public image repository is restricted. It realizes a more comprehensive satisfaction of the business requirement of preferentially obtaining the target image file from the private image repository.
[0166] In some other embodiments, the method further includes: in response to a first instruction from the caller, deleting the address information of the private image repository in the target configuration file, where the first instruction is used to indicate deleting the address information of the private image repository in the target configuration file.
[0167] Exemplarily, the caller may be the kubelet component. It can be understood that the image file acquisition module receives the first instruction sent by the kubelet component and deletes the address information of the private image repository in the target configuration file to complete the deletion operation.
[0168] Exemplarily, if it is necessary to turn off the target function, the caller may issue a first instruction. In this way, it indicates that the image file acquisition module is not currently required to be enabled, and the image file acquisition module no longer changes the first call request, and then directly calls the target interface according to the first call request.
[0169] Furthermore, the first instruction may be issued by the user to the caller (kubelet component) and sent by the caller to the image file acquisition module.
[0170] In the embodiments of the present application, by deleting the address information of the private image repository in the target configuration file, the image file acquisition module becomes ineffective and only plays a role in information transmission between the caller and the target interface, so as to enable the target interface to obtain the target image file from more aspects (such as the public image repository and the private image repository), which is more flexible.
[0171] Exemplarily, the user can manually delete the address information of the private image repository in the target configuration file. In this way, the deletion operation meets the actual needs of the user.
[0172] In some embodiments, the mirror file acquisition module can automatically set the on / off state of the target function according to the current scenario. In this way, whether to perform the operation of modifying the first call request to the second call request according to the address information of the first mirror repository is determined according to different current scenarios, which is more flexible.
[0173] In other embodiments, the platform (such as K8s) is configured with a function switch for controlling and identifying the on or off state of the target function.
[0174] S504, obtain the target mirror file according to the second call request.
[0175] In some embodiments, obtaining the target mirror file according to the second call request includes: calling the target interface according to the second call request to obtain the target mirror file. In this way, the target interface is directed to the private mirror repository (specifically in the first mirror repository) through the second call request, and the target mirror file is obtained from the first mirror repository according to the identifier of the target mirror file. On the one hand, the requirement of obtaining the target mirror file from the private mirror repository is met, and on the other hand, the target mirror file can be obtained more efficiently and accurately according to the identifier of the target mirror file.
[0176] In one implementation, when calling the target interface to obtain the target mirror file according to the second call request, the target interface searches for and obtains the target mirror file from the first mirror repository according to the identifier of the target mirror file and the address information of the first mirror repository.
[0177] Specifically, after the target interface accesses the first mirror repository, it matches with the mirror files in the first mirror repository according to the identifier of the target mirror file. If there is a mirror file in the first mirror repository that matches the target mirror file successfully, the successfully matched mirror file is determined as the target mirror file, and a return message indicating successful acquisition of the target mirror file (including the target mirror file) is returned to the mirror file acquisition module. Based on this, the mirror file acquisition module obtains the target mirror file; if there is no mirror file in the first mirror repository that matches the target mirror file successfully, a return message indicating failure to acquire the target mirror file is returned. In this way, the target interface directly goes to the first mirror repository to obtain the target mirror file by matching the identifier of the target mirror file, which more comprehensively meets the business requirement of obtaining the target mirror file from the private mirror repository.
[0178] In another implementation, when the target interface is called according to the second call request to obtain the target mirror file, if the call policy is the first policy, the target interface first checks whether the target mirror file exists in the cache. For example, the target interface matches the mirror files in the cache according to the identifier of the target mirror file. If there is a mirror file in the cache that matches the target mirror file successfully, the successfully matched mirror file is determined as the target mirror file. If there is no mirror file in the cache that matches the target mirror file successfully, the target mirror file is searched for and obtained from the first mirror repository. The first policy is used to indicate that the target mirror file is first checked in the cache. If it exists, the target mirror file in the cache is returned. If it does not exist, the target mirror file is obtained from the private mirror repository (such as the first mirror repository) indicated in the second call request.
[0179] Exemplarily, the cache may specifically be the local storage of the computing device 1.
[0180] In the embodiments of the present application, the first policy may be preset, indicating that the target mirror file is preferentially obtained from the cache. If the target mirror file does not exist in the cache, the target mirror file is obtained from the private mirror repository, further expanding the acquisition path of the target mirror file and improving the efficiency of obtaining the target file at the same time.
[0181] In some embodiments, if there is one private mirror repository, the method further includes: obtaining return information, where the return information is used to indicate that the acquisition of the target mirror file is successful or the acquisition of the target mirror file fails. When it is responded that the return information indicates that the acquisition of the target mirror file fails, the target mirror file is obtained from the public mirror repository.
[0182] In the embodiments of the present application, even if the acquisition of the target mirror file fails in the private mirror repository, it is still possible to try to search for and obtain the target mirror file from the public mirror repository, further improving the success rate of obtaining the target mirror file.
[0183] Specifically, the return information is returned by the target interface to the mirror file acquisition module. That is, the mirror file acquisition module obtains the return information of the target interface.
[0184] Specifically, when it is responded that the return information indicates that the acquisition of the target mirror file fails, obtaining the target mirror file from the public mirror repository includes: when it is responded that the return information indicates that the acquisition of the target mirror file fails, calling the target interface to obtain the target mirror file from the public mirror repository.
[0185] Further, if the return information indicates that the acquisition of the target mirror file is successful, the return information includes the target mirror file.
[0186] In some other embodiments, if there are N private image repositories, and the address information of the first image repository is the address information of the first private image repository traversed from the target configuration file, the method further includes: obtaining the return information of the i-th time, where the return information is used to indicate that the target image file is successfully obtained or the target image file is not successfully obtained; i is an integer greater than or equal to 1 and less than or equal to N. When it is responsive to the return information of the i-th time indicating that the target image file is not successfully obtained, traverse to the address information of the (i + 1)-th private image repository from the target configuration file, and modify the first call request according to the address information of the (i + 1)-th private image repository, so as to obtain the target image file according to the modified call request, until N acquisitions are completed or the return information indicates that the target image file is successfully obtained.
[0187] In the embodiments of the present application, starting from the first image repository, if the target image file is not successfully obtained in the previous private image repository, the first call request is sequentially modified according to the address information of the next private image repository in the order of the private image repositories in the target configuration file. In this way, through the traversal method, the first call request can be automatically and orderly modified, avoiding disorder, and realizing that when the target image file is not successfully obtained from the previous private image repository, automatically and efficiently attempting to obtain the target image file from the next private image repository, and so on in a loop until all private image repositories are traversed (that is, attempting to obtain the target image file from all private image repositories) or the target image file is successfully obtained. Since N private image repositories are set, the resource coverage range of the private image repositories is expanded, and the success rate of obtaining the target image file from the private image repositories is further improved.
[0188] Specifically, modifying the first call request according to the address information of the (i + 1)-th private image repository to obtain the target image file according to the modified call request includes: modifying the first call request according to the address information of the (i + 1)-th private image repository, so as to make the (i + 1)-th call to the target interface according to the modified call request.
[0189] For example, if N = 4, that is, there are address information of 4 private image repositories in the target configuration file. When the target interface is called according to the second call request, the return information of the first time will be returned. Starting from i = 1, the return information of the first (i) time is received. If the return information of the first time indicates that the acquisition of the target image file fails. Traverse to the address information of the second (i + 1) private image repository in the target configuration file, modify the first call request according to the address information of the second (i + 1) private image repository, and make the second (i + 1) call to the target interface according to the modified call request.... When i = 3, the return information of the third time is received. If the return information of the third time indicates that the acquisition of the target image file fails. Traverse to the address information of the fourth private image repository in the target configuration file, modify the first call request according to the address information of the fourth private image repository, and make the fourth call to the target interface according to the modified call request. That is to say, when i = N - 1, the Nth call (acquisition) is completed. After the Nth call is completed, whether the target image file is successfully acquired or not, the first call request is no longer modified, because the address information of the private image repositories in the target configuration file has been applied and will not be applied repeatedly.
[0190] In one implementation, if there are N private image repositories and the return information of the ith time all indicates that the acquisition of the target image file fails, then the target image file is acquired from the public image repository (specifically, the target interface can be called to acquire the target image file from the public image repository). In this way, if the acquisition of the target image file fails in all private image repositories in the target configuration file, then try to find and acquire the target image file from the public image repository, expanding the scope of acquiring the target image file and further improving the success rate of acquiring the target image file from the private image repository.
[0191] In some other embodiments, the method further includes: in response to the return information indicating that the acquisition of the target image file is successful, returning the return information (including the target image file) to the kubelet component. In this way, the kubelet component can use the target image file to create a container.
[0192] In one implementation, the method further includes: in response to the return information indicating that the acquisition of the target image file is successful, checking whether the target image file exists in the cache and returning the check result to the kubelet component.
[0193] In the embodiments of the present application, it is mainly applied to the scenario where the return information indicates that the acquisition of the target mirror file is successful. By checking whether the target mirror file exists in the cache, it is determined whether the target mirror file is truly acquired successfully. For example, if the target mirror file is found in the cache, it is determined that the acquisition of the target mirror file is successful. If the target mirror file is not found in the cache, it is determined that the acquisition of the target mirror file is not successful. In this way, the return information is checked and verified to further ensure the successful acquisition of the target mirror file.
[0194] In some embodiments, the method further includes: monitoring the update situation of the target configuration file, and after the target configuration file is updated, obtaining the updated target configuration file in real time. Among them, the update situation of the target configuration file can specifically refer to whether the address information of the private image repository therein has changed. In this way, based on the latest set address information of the private image repository, the available address information of the private image repository can be clarified, so as to obtain the address information of the i-th private image repository, improving the availability and accuracy of the address information of the first image repository.
[0195] In some other embodiments, the method further includes: based on the updated target configuration file (the address information of the private image repository therein) obtained in real time, modifying the first call request to obtain a modified call request, and calling the target interface according to the modified call request. In this way, when the target configuration file is updated, there is no need to restart the mirror file acquisition module, realizing the hot update of the mirror file acquisition module (that is, the mirror file acquisition module can obtain the updated address information of the private image repository without restarting). At the same time, the update of the target configuration file is unaware of the target interface. Therefore, there is no need to configure and update the target interface, and thus there is no need to restart the target interface service, improving the maintainability and availability of the system.
[0196] In some embodiments, the target interface includes CRI. CRI includes a first image service module (imageserviceserver) and a runtime service module runtimeserviceserver. runtimeserviceserver is used to provide operations related to containers. The first image service module includes a first list images interface (listimages), a first image status interface (imagestatus), a first image pull interface (pullimages), a first image delete interface (removeimage), and a first image file system information interface (imagehsinfo).
[0197] Exemplarily, the first listed image interface is used to obtain the list of image files in the cache, where the list of image files is used to represent the available image files in the cache. The first image status interface is used to determine whether a specified image file exists in the cache and the status of the specified image file when it exists, where the specified image file may refer to an image file that needs to be operated on (such as searched for, obtained, deleted, etc.). The status includes information such as the identifier of the specified image file and whether the specified image file exists. The first image pull interface is used to obtain a specified image file (such as a target image file). The first image deletion interface is used to determine whether a specified image file exists in the cache, and if the specified image file exists in the cache, delete the specified image file from the cache. The first image file system information interface is used to obtain image file system information, where the image file system information includes the disk usage and / or available space of the image file system.
[0198] In some embodiments, in combination with Figure 6 as shown, the present application provides a schematic structural diagram of an image file acquisition module. As Figure 6 shown, the image file acquisition module includes a second listed image interface (listimages), a second image status interface (imagestatus), a second image pull interface (pullimages), a second image deletion interface (removeimages), and a second image file system information interface (imagehsinfo). Among them, the above-mentioned interfaces in the image file acquisition module interact with the interfaces in the target interface (CRI).
[0199] In one implementation, the second listed image interface: is used to, in response to a second instruction from the caller, obtain the list of image files in the cache through the target interface and return the list of image files in the cache to the caller, where the second instruction is used to indicate viewing the available image files in the cache.
[0200] Exemplarily, the caller may be the kubelet component.
[0201] In combination with Figure 7 as shown, an embodiment of the present application provides another method for acquiring an image file. This method can be specifically executed by the second listed image interface in the image file acquisition module. The method further includes:
[0202] S701, in response to a second instruction from the caller, obtain the list of image files in the cache.
[0203] Exemplarily, in response to the second instruction, the second listed image interface calls the first listed image interface in the target interface according to the second instruction, so that the first listed image interface obtains the list of image files in the cache and returns it to the second listed image interface. In this way, the second listed image interface obtains the list of image files in the cache.
[0204] S702. Return the list of mirror files in the cache to the caller.
[0205] In the embodiments of the present application, the second mirror listing interface can efficiently and accurately obtain the list of mirror files in the cache through the target interface, and then return the list of mirror files to the caller, which can meet the requirements of the caller.
[0206] In one implementation, the second mirror status interface is used to, in response to a third instruction from the caller, determine whether a specified mirror file exists in the cache and the status of the specified mirror file when it exists through the target interface, and return the determination result to the caller. The third instruction is used to indicate querying the status of the specified mirror file in the cache.
[0207] Combined with Figure 8 As shown, the embodiments of the present application provide another method for obtaining mirror files. This method can be specifically executed by the second mirror status interface in the mirror file acquisition module. The method further includes:
[0208] S801. In response to a third instruction from the caller, determine whether a specified mirror file exists in the cache and the status of the specified mirror file when it exists.
[0209] Exemplarily, in response to the third instruction, the second mirror status interface calls the first mirror status interface in the target interface, so that the first mirror status interface determines whether a specified mirror file exists in the cache and the status of the specified mirror file when it exists, and returns it to the second mirror status interface. In this way, the second mirror status interface determines whether a specified mirror file exists in the cache and the status of the specified mirror file when it exists. It can be understood that this process will continue until the status of the specified mirror file is successfully returned or it is determined that the specified mirror file does not exist.
[0210] S802. Return the determination result to the caller.
[0211] In the embodiments of the present application, the second mirror status interface can efficiently and accurately determine whether a specified mirror file exists in the cache and the status of the specified mirror file when it exists through the target interface, return it to the second mirror status interface, and then return the list of mirror files to the caller, which can meet the requirements of the caller.
[0212] In one implementation, the second image pulling interface: is used to obtain a first call request for a caller to call a target interface, obtain address information of a first image repository from a target configuration file, modify the first call request into a second call request according to the address information of the first image repository, and call the first image pulling interface in the target interface according to the second call request. In addition, the second image pulling interface is further used to obtain return information from the first image pulling interface. Finally, the second image pulling interface is further used to return the return information (such as including the target image file when the return information indicates successful acquisition of the target image file) to the caller.
[0213] Combined with Figure 9 As shown, an embodiment of the present application provides another method for obtaining an image file. This method is specifically executed by the second image pulling interface in the image file obtaining module. This method includes:
[0214] S901, obtain a first call request for a caller to call a target interface.
[0215] S902, obtain address information of a first image repository from a target configuration file.
[0216] S903, modify the first call request into a second call request according to the address information of the first image repository.
[0217] S904, call the first image pulling interface in the target interface according to the second call request.
[0218] S905, obtain return information from the first image pulling interface.
[0219] S906, return the return information to the caller.
[0220] In an embodiment of the present application, the execution entity is specifically the second image pulling interface in the image file obtaining module. Through the interaction between the second image pulling interface and the caller and the first image pulling interface, a complete target image obtaining process is realized, so as to return the required target image file to the caller.
[0221] It should be noted that when the second image pulling interface fails to call the first image pulling interface to obtain the target image file according to the second call request, the second image pulling interface sequentially modifies the first call request according to the address information of the private image repository in the target configuration file, and calls the first image pulling interface again according to the modified call request until the first image pulling interface successfully obtains the target image file or traverses all private image repositories.
[0222] In one implementation, the second mirror deletion interface: is used to determine whether a specified mirror file exists in the cache through a target interface in response to a fourth instruction from a caller, and delete the specified mirror file from the cache through the target interface when the specified mirror file exists in the cache.
[0223] Combined with Figure 10 As shown, an embodiment of the present application provides another method for obtaining a mirror file. This method is specifically executed by the second mirror deletion interface in the mirror file acquisition module. The method further includes:
[0224] S1001, in response to a fourth instruction from a caller, determine whether a specified mirror file exists in the cache.
[0225] S1002, when the specified mirror file exists in the cache, delete the specified mirror file from the cache.
[0226] In the embodiment of the present application, through the interaction between the second mirror deletion interface and the caller and the first mirror deletion interface, the specified mirror file is deleted from the cache.
[0227] In one implementation, the second mirror file system information interface: is used to obtain mirror file system information through a target interface in response to a fifth instruction from a caller, and return the mirror file system information to the caller.
[0228] Combined with Figure 11 As shown, an embodiment of the present application provides another method for obtaining a mirror file. This method is specifically executed by the second mirror file system information interface in the mirror file acquisition module. The method includes:
[0229] S1101, in response to a fifth instruction from a caller, obtain mirror file system information.
[0230] S1102, return the mirror file system information to the caller.
[0231] In the embodiment of the present application, through the interaction between the second mirror file system information interface and the caller and the first mirror file system information interface, the mirror file system information is returned to the caller.
[0232] As Figure 12 shown, an embodiment of the present application provides a flowchart of another method for obtaining a mirror file. This method is applied to computing device 1 and is executed by a container orchestration platform deployed on computing device 1. The method includes:
[0233] S1201, obtain a creation request for a container.
[0234] Exemplarily, specifically, it may be that the kubelet component obtains a creation request for a container from a user.
[0235] S1202. Determine the first call request according to the creation request of the container.
[0236] Among them, the first call request includes the identifier of the target mirror file. The target mirror file is the mirror file corresponding to the container.
[0237] S1203. Obtain the address information of the first mirror repository from the target configuration file.
[0238] Among them, the first mirror repository is one of the private mirror repositories.
[0239] S1204. Modify the first call request to the second call request according to the address information of the first mirror repository.
[0240] Among them, the second call request includes the identifier of the target mirror file and the address information of the first mirror repository.
[0241] S1205. Obtain the target mirror file according to the second call request.
[0242] S1206. Create a container according to the target mirror file.
[0243] In the embodiment of the present application, an overall process from obtaining the creation request of the container to creating the container is shown, realizing that even in specific scenarios (such as the target interface is docker, the network connection between the computing device and the Internet is disconnected, or the public mirror repository is restricted, etc.), the business requirement of preferentially obtaining the target mirror file from the private mirror repository can be met, thereby improving the success rate of obtaining the target mirror file and further improving the success rate of container creation.
[0244] Such as Figure 13 shown, the embodiment of the present application provides a schematic flowchart of another method for obtaining a mirror file. This method is applied to the computing device 1 and is executed by the first module, the second module, and the CRI in the container orchestration platform deployed on the computing device 1. Among them, the first module can be Figure 2 the kubelet component in Figure 2 the mirror file acquisition module in Figure 6 or the second image pull interface in the mirror file acquisition module in
[0245] S1301. The first module obtains the creation request of the container.
[0246] S1302. The first module determines the first call request according to the creation request of the container.
[0247] S1303. The first module sends the first call request to the second module.
[0248] S1304, the second module obtains the first call request.
[0249] S1305, the second module obtains the address information of the first image repository from the target configuration file.
[0250] S1306, the second module modifies the first call request to a second call request according to the address information of the first image repository.
[0251] S1307, the second module calls the CRI according to the second call request.
[0252] S1308, in response to the call of the second module, the CRI obtains the target image file according to the second call request.
[0253] S1309, the CRI sends return information to the second module.
[0254] It can be understood that if the return information indicates that the acquisition of the target image file is successful, the return information includes the target image file.
[0255] In this way, the CRI can respond to the call of the second module in a timely manner and return the return information to the second module in a timely manner, so that the second module can obtain the specific call result: whether the acquisition of the target image file is successful or the acquisition of the target image file fails. Based on the call result, it is determined whether it is necessary to modify the first call request again.
[0256] S1310, the second module receives the return information returned by the CRI.
[0257] S1311, the second module returns the return information to the first module.
[0258] S1312, the first module receives the return information.
[0259] S1313, when the first module obtains the target image file, it creates a container according to the target image file.
[0260] In this way, by the second module returning the acquisition of the target image file, the first module creates a container based on the target image file, completing the process of container creation.
[0261] Such as Figure 14As shown in the figure, an embodiment of the present application provides an image file acquisition device 200, which includes: a first acquisition module 21, a second acquisition module 22, a modification module 23, and a third acquisition module 24. The first acquisition module 21 is used to acquire a first call request, and the first call request includes an identifier of a target image file. The second acquisition module 22 is used to acquire address information of a first image repository from a target configuration file, and the first image repository is one of the private image repositories. The modification module 23 is used to modify the first call request into a second call request according to the address information of the first image repository, and the second call request includes the identifier of the target image file and the address information of the first image repository. The third acquisition module 24 is used to acquire the target image file according to the second call request.
[0262] Exemplarily, the image file acquisition device 200 corresponds to the above-mentioned second module.
[0263] As Figure 15 shown in the figure, an embodiment of the present application provides another image file acquisition device 300, which is applied to a computing device 1. The computing device 1 stores a target configuration file, and the target configuration file includes address information of a private image repository. The private image repository is deployed on the computing device 1 or is interconnected with the computing device 1 through a local area network. The image file acquisition device 300 includes: a first module 31, a second module 32, and a CRI 33, where:
[0264] The first module is used to acquire a container creation request, determine a first call request according to the container creation request, and send the first call request to the second module. The first call request includes an identifier of a target image file, and the target image file is an image file corresponding to the container.
[0265] The second module is used to acquire the first call request, acquire address information of a first image repository from the target configuration file, modify the first call request into a second call request according to the address information of the first image repository, and send the second call request to the CRI; the first image repository is one of the private image repositories, and the second call request includes the identifier of the target image file and the address information of the first image repository; it is also used to receive the target image file returned by the CRI and return the target image file to the first module.
[0266] The CRI is used to acquire the second call request, acquire the target image file according to the second call request, and send the target image file to the second module.
[0267] Exemplarily, the image file acquisition device 300 corresponds to the above-mentioned platform.
[0268] As Figure 16As shown, an embodiment of the present application provides another computing device 1 (hereinafter referred to as computing device 500). The computing device 500 includes a processor 510 and a memory 520 for storing processor-executable instructions. When the processor 510 is configured to execute instructions, the computing device 500 implements the mirror file acquisition method as described above.
[0269] Figure 16 The shown computing device 500 is merely an example and should not impose any limitations on the functions and usage scope of the embodiments of the present application.
[0270] The computing device 500 is presented in the form of a general-purpose computing device. The components of the computing device 500 may include, but are not limited to: one or more processors 510, a memory 520, a communication bus 540 connecting different system components (including the memory 520 and the processor 510), and a communication interface 530.
[0271] The communication bus 540 represents one or more of several types of bus structures, including a memory bus or a memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus structures. For example, these architectures include, but are not limited to, Industry Standard Architecture (hereinafter referred to as ISA) bus, Micro Channel Architecture (hereinafter referred to as MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (hereinafter referred to as VESA) local bus, and Peripheral Component Interconnection (hereinafter referred to as PCI) bus.
[0272] The computing device 500 typically includes a variety of computer system-readable media. These media can be any available media accessible by the computing device, including volatile and non-volatile media, removable and non-removable media.
[0273] The memory 520 may include computer system-readable media in the form of volatile memory, such as random access memory (hereinafter referred to as RAM) and / or cache memory. The computing device may further include other removable / non-removable, volatile / non-volatile computer system storage media. Although Figure 16Not shown in the figure, a disk drive for reading and writing a removable non-volatile disk (such as a "floppy disk") and an optical disk drive for reading and writing a removable non-volatile optical disk (such as a Compact Disc Read Only Memory (hereinafter referred to as: CD-ROM), a Digital Video Disc Read Only Memory (hereinafter referred to as: DVD-ROM) or other optical media) can be provided. In these cases, each drive can be connected to the communication bus 540 through one or more data medium interfaces. The memory 520 may include at least one program product having a set (such as at least one) of program modules configured to perform the functions of the embodiments of the present application.
[0274] A program / utility having a set (at least one) of program modules can be stored in the memory 520. Such program modules include - but are not limited to - an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include the implementation of a network environment. The program modules generally perform the functions and / or methods in the embodiments described in the present application.
[0275] The computing device 500 can also communicate with one or more external devices (such as a keyboard, a pointing device, a display, etc.), and can also communicate with one or more devices that enable a user to interact with the computing device, and / or communicate with any device that enables the computing device to communicate with one or more other computing devices (such as a network card, a modem, etc.). Such communication can be carried out through the communication interface 530. And, the computing device 500 can also communicate with one or more networks (such as a Local Area Network (hereinafter referred to as: LAN), a Wide Area Network (hereinafter referred to as: WAN) and / or a public network, such as the Internet) through a network adapter ( Figure 16 not shown in the figure). The above network adapter can communicate with other modules of the computing device through the communication bus 540. It should be understood that although Figure 16 not shown in the figure, other hardware and / or software modules can be used in combination with the computing device 500, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, Redundant Arrays of Independent Drives (hereinafter referred to as: RAID) systems, tape drives, and data backup storage systems, etc.
[0276] The processor 510 executes various functional applications and data processing by running programs stored in the memory 520, such as implementing the mirror file acquisition method provided in the embodiments of the present application.
[0277] It can be understood that the interface connection relationships between the modules illustrated in the embodiments of the present application are only illustrative descriptions and do not constitute a structural limitation on the computing device 500. In other embodiments of the present application, the computing device 500 may also adopt different interface connection manners in the above embodiments, or a combination of multiple interface connection manners.
[0278] It can be understood that in order to implement the above functions, the above computing device and the like include corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should easily realize that, in combination with the various exemplary units and algorithm steps described in the embodiments disclosed in this article, the embodiments of the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the manner of hardware or computer software driving the hardware depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the embodiments of the present application.
[0279] The embodiments of the present application can perform functional module division on the above computing device and the like according to the above method examples. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware or in the form of a software functional module. It should be noted that the division of modules in the embodiments of the present application is illustrative, only a logical function division, and there may be other division methods in actual implementation.
[0280] The embodiments of the present application also provide a storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a computing device, the computing device is enabled to implement the mirror file acquisition method as described above.
[0281] The embodiments of the present application also provide a program product, which includes a computer program. When at least one processor executes the computer program, at least one processor is enabled to execute the mirror file acquisition method provided in the embodiments of the present application.
[0282] The computing device, storage medium, or computer program product provided in the embodiments of the present application are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above, and will not be elaborated here.
[0283] Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. For the specific working processes of the systems, devices, and units described above, reference can be made to the corresponding processes in the foregoing method embodiments, which will not be elaborated here.
[0284] In each embodiment of this application, the various functional units can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0285] If the above integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application embodiment, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of this application. The foregoing storage medium includes: flash memory, mobile hard disk, read-only memory, random access memory, magnetic disk, or optical disk and other various media that can store program codes.
[0286] The above is only the specific embodiment of this application, but the protection scope of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be covered by the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.
Claims
1. A method for obtaining an image file, characterized in that Applied to a computing device on which a target configuration file is stored. The target configuration file includes address information of a private image repository, and the private image repository is deployed on the computing device or interconnected with the computing device through a local area network. The method includes: Obtain a first call request, where the first call request includes an identifier of a target image file; Obtain the address information of a first image repository from the target configuration file, where the first image repository is one of the private image repositories; Modify the first call request to a second call request according to the address information of the first image repository, where the second call request includes the identifier of the target image file and the address information of the first image repository; Obtain the target image file according to the second call request.
2. The method according to claim 1, characterized in that The modifying the first call request to a second call request according to the address information of the first image repository includes: If the first call request further includes the address information of a public image repository, replace the address information of the public image repository with the address information of the first image repository to obtain the second call request, where the public image repository includes image repositories maintained by the community and / or official; or, If the first call request further includes the address information of a private image repository, and when the target configuration file does not include the address information of the private image repository, replace the address information of the private image repository with the address information of the first image repository to obtain the second call request; or, If the first call request does not include the address information of an image repository, add the address information of the first image repository to the first call request to obtain the second call request.
3. The method according to claim 2, wherein If there is one private image repository, the method further includes: Obtain return information, where the return information is used to indicate that obtaining the target image file is successful or obtaining the target image file fails; When the return information indicates that obtaining the target image file fails in response, obtain the target image file from the public image repository; If there are N private image repositories, where N is an integer greater than 1, and the address information of the first image repository is the address information of the first private image repository traversed from the target configuration file, the method further includes: Obtain the return information of the i-th time, where the return information is used to indicate that obtaining the target image file is successful or obtaining the target image file fails; i is an integer greater than or equal to 1 and less than or equal to N; When the return information of the i-th time indicates that obtaining the target image file fails in response, traverse to the address information of the (i + 1)-th private image repository from the target configuration file, and modify the first call request according to the address information of the (i + 1)-th private image repository, so as to obtain the target image file according to the modified call request until N times of obtaining are completed or the return information indicates that the target image file is successful.
4. The method according to claim 3, characterized in that The method further includes: If there are N private image repositories and the return information for the i-th time all indicates that the acquisition of the target image file fails, then acquire the target image file from the public image repository.
5. The method according to any one of claims 1 to 4, characterized in that, The acquiring the target image file according to the second call request includes: Calling the container runtime interface according to the second call request to acquire the target image file.
6. The method according to claim 5, wherein: The first call request is used to call the container runtime interface to acquire the target image file; The return value of the second call request has the same format as the return value returned to the first call request.
7. The method according to claim 1 or 2, characterized in that, If there are N private image repositories, where N is an integer greater than 1, and the first image repository is one of the N private image repositories that meets the preset conditions, and the preset conditions include that the number of image files in the private image repository is greater than or equal to the preset number.
8. The method according to any one of claims 1-7, characterized in that, The modifying the first call request to a second call request according to the address information of the first image repository further includes: When the switch state of the target function is in the on state, modifying the first call request to the second call request according to the address information of the first image repository, where the target function is used to indicate the function of acquiring the target image file from the private image repository.
9. The method according to claim 8, wherein The method further includes: In response to detecting that the current scenario is a preset scenario, setting the switch state of the target function to the on state; the preset scenario includes: the network connection between the computing device and the Internet is disconnected, and / or the public image repository has closed the access permission of the computing device.
10. The method according to any one of claims 1-9, characterized in that, The method further includes: In response to the first instruction of the caller, deleting the address information of the private image repository of the target configuration file, where the first instruction is used to indicate deleting the address information of the private image repository of the target configuration file; or, In response to the second instruction of the caller, acquiring the list of image files in the cache and returning the list of image files in the cache to the caller, where the list of image files is used to represent the available image files in the cache, and the second instruction is used to indicate viewing the available image files in the cache; or, In response to the third instruction of the caller, determining whether a specified image file exists in the cache and the status of the specified image file when it exists, and returning the determination result to the caller, where the third instruction is used to indicate querying the status of the specified image file in the cache; or, In response to the fourth instruction of the caller, determining whether a specified image file exists in the cache, and when the specified image file exists in the cache, deleting the specified image file from the cache through the container runtime interface; or, In response to the fifth instruction of the caller, acquiring the image file system information and returning the image file system information to the caller, where the image file system information includes the disk usage and / or available space of the image file system.
11. A method for obtaining an image file, characterized in that, Applied to a computing device on which a target configuration file is stored, the target configuration file includes address information of a private image repository, the private image repository is deployed on the computing device or interconnected with the computing device through a local area network, the method includes: Obtain a creation request for a container; Determine a first call request according to the creation request of the container, the first call request includes an identifier of a target image file, and the target image file is the image file corresponding to the container; Obtain the address information of a first image repository from the target configuration file, and the first image repository is one of the private image repositories; Modify the first call request into a second call request according to the address information of the first image repository, and the second call request includes the identifier of the target image file and the address information of the first image repository; Obtain the target image file according to the second call request; Create the container according to the target image file.
12. An image file acquisition device, characterized in that, Applied to a computing device on which a target configuration file is stored, the target configuration file includes address information of a private image repository, the private image repository is deployed on the computing device or interconnected with the computing device through a local area network; the device includes: A first acquisition module, configured to acquire a first call request, and the first call request includes an identifier of a target image file; A second acquisition module, configured to acquire the address information of a first image repository from the target configuration file, and the first image repository is one of the private image repositories; A modification module, configured to modify the first call request into a second call request according to the address information of the first image repository, and the second call request includes the identifier of the target image file and the address information of the first image repository; A third acquisition module, configured to acquire the target image file according to the second call request.
13. An image file acquisition device, characterized in that, Applied to a computing device on which a target configuration file is stored, the target configuration file includes address information of a private image repository, the private image repository is deployed on the computing device or interconnected with the computing device through a local area network; the device includes: a first module, a second module and a container runtime interface CRI, wherein: The first module is configured to obtain a creation request for a container, determine a first call request according to the creation request of the container, and send the first call request to the second module, the first call request includes an identifier of a target image file, and the target image file is the image file corresponding to the container; and is further configured to create the container according to the target image file; The second module is configured to obtain the first call request, obtain the address information of the first image repository from the target configuration file, modify the first call request into a second call request according to the address information of the first image repository, and send the second call request to the CRI; the first image repository is one of the private image repositories, and the second call request includes the identifier of the target image file and the address information of the first image repository; it is further configured to receive the target image file returned by the CRI and return the target image file to the first module; The CRI is configured to obtain the second call request, obtain the target image file according to the second call request, and send the target image file to the second module.
14. A computing device, characterized in that, Comprising: A processor and a memory for storing processor-executable instructions; When the processor is configured to execute the instructions, the computing device implements the method according to any one of claims 1-11.
Citation Information
Cited By
Image file acquisition method and apparatus, and computing device
WO2026179100A1