A mirror acquisition method, device, apparatus and storage medium

CN116225615BActive Publication Date: 2026-09-25JINAN INSPUR DATA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310112910.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-10
Publication Date
2026-09-25
Estimated Expiration
2043-02-10

AI Technical Summary

Technical Problem

但是在实践过程中发现,以上两种常见处理方案都有其各自的弊端:方案一存在需要人工介入,手工推送镜像后等待POD自动镜像重试拉取镜像会由于kubernetes默认机制后续每次重试间隔时间会逐步增加,导致业务中断,恢复时间较长

Benefits of technology

[0040]可见,本申请提供了一种镜像获取方法,包括:配置包含预设数量个镜像仓库的目标镜像仓库配置模型;扫描所述目标镜像仓库配置模型中的全部所述镜像仓库,以得到每个目标镜像对应的镜像备份集;当监听到镜像拉取失败事件时,获取对应的当前镜像,并从全部所述镜像备份集中确定与所述当前镜像对应的当前镜像备份集;基于预设镜像备份确定方式从所述当前镜像备份集中确定目标镜像备份,并通过预设镜像获取方式获取所述目标镜像备份。由此可见,本申请通过扫描多个镜像仓库,得到每个镜像对应的多仓库镜像备份集,将现有多个集群或者多个独立可用于的镜像仓库配置到一起互为备份,以便在镜像拉取失败时,自动从镜像备份集中获取对应的镜像备份进行替换,无需人工介入,减少了人工并提高了资源利用率与镜像获取方式的灵活性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116225615B_ABST
    Figure CN116225615B_ABST
Patent Text Reader

Abstract

The application discloses a mirror acquisition method and device, equipment and storage medium, and relates to the technical field of computers, and comprises the following steps: configuring a target mirror warehouse configuration model containing a preset number of mirror warehouses; scanning all the mirror warehouses in the target mirror warehouse configuration model to obtain a mirror backup set corresponding to each target mirror; when a mirror pulling failure event is listened to, a current mirror is acquired, and a current mirror backup set corresponding to the current mirror is determined from all the mirror backup sets; a target mirror backup is determined from the current mirror backup set based on a preset mirror backup determination mode; and the target mirror backup is acquired through a preset mirror acquisition mode. The application scans multiple mirror warehouses to obtain a mirror backup set corresponding to each mirror, so that when mirror pulling fails, the corresponding mirror backup can be automatically acquired from the mirror backup set, manual work is reduced, resource utilization is improved, and the flexibility of the mirror acquisition mode is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, device, and storage medium for image acquisition. Background Technology

[0002] Currently, a large number of applications are deployed based on containerization. Kubernetes (an open-source container orchestration engine) has become the de facto standard for container application orchestration. Various workloads run on Kubernetes, and the applications carried by these workloads are pulled and started in the form of images (container images). Image acquisition is mainly used in fields such as finance, telecommunications, and government. Generally, the images running within a container cluster are stored in a private image repository. When a large number of applications are deployed based on Kubernetes containerization, the error "ImagePullBackOff" (image pull failure) often occurs. This error may be caused by the following reasons: 1. The image repository corresponding to the target image to be pulled is corrupted; 2. The target image to be pulled has been accidentally deleted by human operation.

[0003] Currently, this problem is generally solved in two ways: Solution 1: Manual intervention. The target image is found, manually pushed to the image repository, and then the POD (a resource object in the Kubernetes container orchestration engine, a collection of containers) automatically pulls the image again. Solution 2: Configure a highly available image repository, typically using a dual-repository approach, where the system automatically switches to the other repository if one fails. However, in practice, both common solutions have their drawbacks: Solution 1 requires manual intervention. After manually pushing the image and waiting for the POD to automatically retry pulling it, the retry interval gradually increases due to Kubernetes' default mechanism, leading to service interruptions and long recovery times. Solution 2 carries the risk of both repositories failing, and because the dual repositories perform consistency synchronization, the risk of images being accidentally deleted by tasks cannot be effectively addressed. Summary of the Invention

[0004] In view of this, the purpose of this invention is to provide a method, apparatus, device, and storage medium for image acquisition, which can reduce manual labor and improve resource utilization and flexibility in image acquisition methods. The specific solution is as follows:

[0005] Firstly, this application discloses a method for obtaining an image, including:

[0006] Configure a target image repository configuration model that includes a preset number of image repositories;

[0007] Scan all the image repositories in the target image repository configuration model to obtain the image backup set corresponding to each target image;

[0008] When an image pull failure event is detected, the corresponding current image is obtained, and the current image backup set corresponding to the current image is determined from all the image backup sets.

[0009] The target image backup is determined from the current image backup set based on the preset image backup determination method, and the target image backup is obtained through the preset image acquisition method.

[0010] Optionally, the configuration includes a preset number of target mirror repository configuration models, including:

[0011] Obtain all existing image repositories and configure the target image repository configuration model using the factory pattern and all the image repositories; wherein, the target image repository configuration model includes repository ID, image repository type, username, and password.

[0012] Optionally, scanning all the image repositories in the target image repository configuration model to obtain the image backup set corresponding to each target image includes:

[0013] Identify the target image, and automatically scan all the image repositories in the target image repository configuration model based on the target image;

[0014] The target image obtained from the scan and the target repository corresponding to each target image are acquired.

[0015] The corresponding image backup set is generated based on the target image and the target repository.

[0016] Optionally, the step of obtaining the target image and the target repository corresponding to each target image through scanning includes:

[0017] Log in to the image repository using the username and password for each image repository;

[0018] Call the preset interface of each image repository to obtain all images in each image repository and the image ID corresponding to each image;

[0019] Accordingly, generating the corresponding image backup set based on the target image and the target repository includes:

[0020] The target image is determined from all the images, and the target image ID of the target image is obtained;

[0021] The remaining image IDs are matched with the target image IDs to obtain a set of successfully matched target images and a set of corresponding repositories.

[0022] Based on the target image, the target repository, the target image set, and the repository set, generate the image backup set corresponding to the target image.

[0023] Optionally, after scanning all the image repositories in the target image repository configuration model to obtain the image backup set corresponding to each target image, the method further includes:

[0024] All the images in the image backup set are sorted according to a preset priority sorting rule to obtain a sorted image backup set.

[0025] Optionally, the step of determining the target image backup from the current image backup set based on a preset image backup determination method, and obtaining the target image backup through a preset image acquisition method, includes:

[0026] The highest priority image backup is determined from the sorted image backup set to obtain the target image backup and the corresponding target backup repository;

[0027] Based on the target image backup and the target backup repository, target image backup acquisition information is generated;

[0028] The current image acquisition information in the current image pull event is replaced with the target image backup acquisition information by a preset image replacement service, so as to acquire the target image backup based on the target image backup acquisition information.

[0029] Optionally, before obtaining the corresponding current image when an image pull failure event is detected, the method further includes:

[0030] The automated controller monitors the image pull event results in real time and determines whether there is an image pull failure event based on the pull results.

[0031] Secondly, this application discloses an image acquisition device, comprising:

[0032] The model configuration module is used to configure a target image repository configuration model containing a preset number of image repositories;

[0033] The image backup set acquisition module is used to scan all the image repositories in the target image repository configuration model to obtain the image backup set corresponding to each target image;

[0034] The current image backup set determination module is used to obtain the corresponding current image when an image pull failure event is detected, and to determine the current image backup set corresponding to the current image from all the image backup sets;

[0035] The image backup acquisition module is used to determine the target image backup from the current image backup set based on a preset image backup determination method, and to acquire the target image backup through a preset image acquisition method.

[0036] Thirdly, this application discloses an electronic device, including:

[0037] Memory, used to store computer programs;

[0038] A processor for executing the computer program to implement the steps of the image acquisition method disclosed above.

[0039] Fourthly, this application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the image acquisition method disclosed above.

[0040] As can be seen, this application provides an image acquisition method, including: configuring a target image repository configuration model containing a preset number of image repositories; scanning all the image repositories in the target image repository configuration model to obtain an image backup set corresponding to each target image; when an image pull failure event is detected, acquiring the corresponding current image, and determining the current image backup set corresponding to the current image from all the image backup sets; determining the target image backup from the current image backup set based on a preset image backup determination method, and acquiring the target image backup through a preset image acquisition method. Therefore, this application, by scanning multiple image repositories to obtain a multi-repository image backup set corresponding to each image, configures multiple existing clusters or multiple independently available image repositories together as mutual backups, so that when an image pull fails, the corresponding image backup is automatically obtained from the image backup set for replacement, without manual intervention, reducing manual labor and improving resource utilization and the flexibility of image acquisition methods. Attached Figure Description

[0041] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0042] Figure 1 This is a flowchart of a mirror acquisition method disclosed in this application;

[0043] Figure 2 This is a schematic diagram of the mirror repository configuration model disclosed in this application;

[0044] Figure 3This is a flowchart of a specific image acquisition method disclosed in this application;

[0045] Figure 4 This is a flowchart of a specific image acquisition method disclosed in this application;

[0046] Figure 5 This is a schematic diagram of the mirror update process disclosed in this application;

[0047] Figure 6 A schematic diagram of the image acquisition device provided in this application;

[0048] Figure 7 This application provides a structural diagram of an electronic device. Detailed Implementation

[0049] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0050] Currently, image pull failures may be due to several reasons: 1. The image repository corresponding to the target image is corrupted; 2. The target image has been accidentally deleted by human intervention. The current solutions typically involve two methods: manual intervention, finding the target image, manually pushing it to the image repository, and waiting for the POD to automatically pull the image again. However, this method requires manual intervention, and waiting for the POD to automatically retry pulling the image after manual pushing will cause the retry interval to gradually increase due to Kubernetes' default mechanism, leading to service interruptions and long recovery times. Configuring a highly available image repository generally uses a dual-repository approach, automatically switching to the other repository if one fails. However, this method carries the risk of both repositories failing, and due to the consistency synchronization between the two repositories, it cannot effectively address the risk of images being accidentally deleted by tasks. Therefore, this application provides an image acquisition method that reduces manual intervention and improves resource utilization and flexibility in image acquisition methods.

[0051] This invention discloses a method for obtaining an image, see [link to relevant documentation]. Figure 1 As shown, the method includes:

[0052] Step S11: Configure a target mirror repository configuration model containing a preset number of mirror repositories.

[0053] In this embodiment, a target image repository configuration model containing a preset number of image repositories is configured. Specifically, all existing image repositories are obtained, and the target image repository configuration model is configured using a factory pattern with all of these image repositories. The target image repository configuration model includes a repository ID, image repository type, username, and password. It is understood that configuring the image repository requires the administrator to configure all repositories that may be involved in image backup. Furthermore, to increase flexibility and improve resource utilization, multiple existing clusters or multiple independently available image repositories are configured together for mutual backup. The image repository scanning and processing mode is developed using a factory pattern to facilitate the later addition of different types of image repositories. Various types of target image repository configuration models are shown below. Figure 2 As shown, the target image repository configuration model includes the repository ID, image repository type, username, and password for each repository; and different repositories can exist for the same image repository type. The image repository types include Harbor, Docker Registry, and Nexus.

[0054] Step S12: Scan all the image repositories in the target image repository configuration model to obtain the image backup set corresponding to each target image.

[0055] In this embodiment, after configuring a target image repository configuration model containing a preset number of image repositories, all image repositories in the target image repository configuration model are scanned to obtain the image backup set corresponding to each target image. It can be understood that after the target image repository configuration model is successfully built, a backup image set is established. The establishment of the backup image set is completed through a periodic automatic scanning device, and the backup image priority sorting metadata settings are performed.

[0056] Step S13: When an image pull failure event is detected, obtain the corresponding current image and determine the current image backup set corresponding to the current image from all the image backup sets.

[0057] In this embodiment, after scanning all image repositories in the target image repository configuration model to obtain the image backup set corresponding to each target image, when an image pull failure event is detected, the corresponding current image is obtained, and the current image backup set corresponding to the current image is determined from all the image backup sets. It can be understood that by automatically monitoring the ImagePullBackOff event, when an image pull failure event is detected, the current image backup set corresponding to the current image is automatically determined from all the image backup sets based on the current image corresponding to the current image pull failure event. This allows for the selection and invocation of an image that meets the current requirements from the current image backup set, thereby avoiding manual intervention.

[0058] Step S14: Determine the target image backup from the current image backup set based on the preset image backup determination method, and obtain the target image backup through the preset image acquisition method.

[0059] In this embodiment, after determining the current image backup set corresponding to the current image from all the image backup sets, a target image backup is determined from the current image backup set based on a preset image backup determination method, and the target image backup is obtained through a preset image acquisition method. It can be understood that after determining the target image backup from the current image backup set based on the preset image backup determination method, the target address information of the target image backup is obtained, and the original address information in the original image pull failure event is replaced with the aforementioned target address information, so that the target image backup can be obtained from the corresponding repository according to the aforementioned target address information. Specifically, the Kubernetes API server is called to perform image replacement. When replacing the image, the image with the highest priority is selected, which ensures that the image repository of the production environment corresponding to this cluster is pulled first, thereby ensuring the efficiency and reliability of image pulling.

[0060] The present invention includes a mirror repository configuration device, an automatic scanning device, a manual configuration device for mirror backup relationships, and an automated processing device for mirror pull failures.

[0061] This solution does not restrict image repository types or require strict image synchronization, thus improving resource utilization. It does not require any single image repository to be highly available, supporting the integration of multiple repositories into the image backup set without limitations on repository type or version. This provides greater flexibility in image repository selection and access to existing image repositories in the data center. It automatically scans each image repository, establishes corresponding relationships for identical images, and forms an image backup set. It can automatically monitor ImagePullBackOff events for all workloads within the cluster and call the Kubernetes API in real time to replace images, achieving automatic, real-time handling of image pull failures without manual intervention. This is a more flexible high-availability image solution that can adaptively replace container images in real time, thereby dynamically adjusting the container density of the container cluster.

[0062] As can be seen, this application provides an image acquisition method, including: configuring a target image repository configuration model containing a preset number of image repositories; scanning all the image repositories in the target image repository configuration model to obtain an image backup set corresponding to each target image; when an image pull failure event is detected, acquiring the corresponding current image, and determining the current image backup set corresponding to the current image from all the image backup sets; determining the target image backup from the current image backup set based on a preset image backup determination method, and acquiring the target image backup through a preset image acquisition method. Therefore, this application, by scanning multiple image repositories to obtain a multi-repository image backup set corresponding to each image, configures multiple existing clusters or multiple independently available image repositories together as mutual backups, so that when an image pull fails, the corresponding image backup is automatically obtained from the image backup set for replacement, without manual intervention, reducing manual labor and improving resource utilization and the flexibility of image acquisition methods.

[0063] See Figure 3 As shown, this embodiment of the invention discloses a mirror acquisition method. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution.

[0064] Step S21: Configure a target mirror repository configuration model containing a preset number of mirror repositories.

[0065] Step S22: Determine the target image and automatically scan all the image repositories in the target image repository configuration model based on the target image.

[0066] In this embodiment, after configuring a target image repository configuration model containing a preset number of image repositories, a target image is determined, and all image repositories in the target image repository configuration model are automatically scanned based on the target image. It can be understood that an image from any repository that does not have a corresponding image backup set is selected as the target image, so that the same image can be obtained by scanning all image repositories in the target image repository configuration model based on the target image.

[0067] Step S23: Obtain the target image obtained from the scan and the target repository corresponding to each target image.

[0068] In this embodiment, after determining the target image and automatically scanning all image repositories in the target image repository configuration model based on the target image, the scanned target image and the target repository corresponding to each target image are obtained. Specifically, the user logs into the image repository using the username and password recorded in the target image repository configuration model; the user calls the preset interface of each image repository to obtain all images in each image repository and the image ID corresponding to each image. It can be understood that, after successfully logging into the corresponding image repository using the username and password recorded in the target image repository configuration model, the user calls the corresponding image repository type's API (Application Program Interface) to obtain all images in each image repository, as well as the image ID and image repository corresponding to each image.

[0069] Step S24: Generate the corresponding image backup set based on the target image and the target repository.

[0070] In this embodiment, after obtaining the target image and the target repository corresponding to each target image through scanning, a corresponding image backup set is generated based on the target image and the target repository. Specifically, the target image is determined from all the images, and the target image ID of the target image is obtained; the image IDs of the remaining images are matched with the target image ID to obtain a set of successfully matched target images and a corresponding set of repositories; and an image backup set corresponding to the target image is generated based on the target image, the target repository, the set of target images, and the set of repositories. It can be understood that by determining the target image and obtaining the target image ID, all obtained image IDs are sequentially compared with the target image ID to extract the matching image IDs, and the matched image and the matched image repository corresponding to the matched image ID are obtained. An image backup set corresponding to the target image is generated based on the target image, the target repository, the set of target images, and the set of repositories, and the image backup set contains images generated from all image IDs and image repository information corresponding to each image.

[0071] Step S25: When an image pull failure event is detected, obtain the corresponding current image and determine the current image backup set corresponding to the current image from all the image backup sets.

[0072] Step S26: Determine the target image backup from the current image backup set based on the preset image backup determination method, and obtain the target image backup through the preset image acquisition method.

[0073] For details regarding steps S21, S25, and S26, please refer to the corresponding content disclosed in the foregoing embodiments, which will not be repeated here.

[0074] As can be seen, this embodiment of the application configures a target image repository configuration model containing a preset number of image repositories; determines a target image, and automatically scans all the image repositories in the target image repository configuration model based on the target image; obtains the scanned target image and the target repository corresponding to each target image; generates a corresponding image backup set based on the target image and the target repository; when an image pull failure event is detected, obtains the corresponding current image, and determines the current image backup set corresponding to the current image from all the image backup sets; determines the target image backup from the current image backup set based on a preset image backup determination method, and obtains the target image backup through a preset image acquisition method, thereby reducing manual labor and improving resource utilization and the flexibility of image acquisition methods.

[0075] See Figure 4 As shown, this embodiment of the invention discloses a mirror acquisition method. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution.

[0076] Step S31: Configure a target mirror repository configuration model containing a preset number of mirror repositories.

[0077] Step S32: Scan all the image repositories in the target image repository configuration model to obtain the image backup set corresponding to each target image.

[0078] Step S33: Sort all the images in the image backup set according to the preset priority sorting rules to obtain the sorted image backup set.

[0079] In this embodiment, after scanning all the image repositories in the target image repository configuration model to obtain the image backup set corresponding to each target image, all the images in the image backup set are sorted according to a preset priority sorting rule to obtain a sorted image backup set. It can be understood that each image backup set is sorted by the same image backup priority based on all images and metadata in the image backup set, so that a priority for selecting the image to be pulled is added for the same images in each group of image backup sets, and the image repository location and image repository positioning are added to each image metadata; wherein, the image repository positioning includes production environment, test environment, and development environment.

[0080] Each image backup set is sorted by the same image backup priority. Specifically, a weight coefficient is set for priority sorting. Based on the weight coefficient, the priority value of each image in the image backup set is calculated, and the images in the image backup set are sorted according to the priority value. For example, when the image repository and container cluster are in the same cluster, the priority is increased by a sorting weight coefficient of up to 2. The weight of an image repository positioned for the production environment is 2, the weight of an image repository positioned for the test environment is 1.5, and the weight of an image repository positioned for the development environment is 1. The above weight values ​​can be customized according to user needs.

[0081] Step S34: When an image pull failure event is detected, obtain the corresponding current image and determine the current image backup set corresponding to the current image from all the image backup sets.

[0082] In this embodiment, all images in the image backup set are sorted according to a preset priority sorting rule to obtain the sorted image backup set. When an image pull failure event is detected, the corresponding current image is obtained, and the current image backup set corresponding to the current image is determined from all the image backup sets. Specifically, before obtaining the corresponding current image when an image pull failure event is detected, the image pull result of the image pull event is monitored in real time by the automation controller (imagePullErrorController), and the existence of the image pull failure event is determined based on the pull result. It can be understood that the automation controller monitors all events in the container cluster in real time using a list-watch method to obtain the pull result of each image pull event. When an image pull failure event is detected for a certain workload, the corresponding current image is obtained, and the backup image set is queried based on the image that failed to pull in the original workload. That is, the current image backup set corresponding to the current image ID is determined from all the image backup sets based on the current image ID of the current image.

[0083] Step S35: Determine the highest priority image backup from the sorted image backup set to obtain the target image backup and the corresponding target backup repository.

[0084] In this embodiment, after determining the current image backup set corresponding to the current image from all the image backup sets, the image backup with the highest priority is determined from the sorted image backup set to obtain the target image backup and its corresponding target backup repository. For example, the image matching API is called through imagePullErrorController to obtain the highest priority standby image from the image backup set so as to call the Kubernetes API server for image updates. It is understood that since each image backup set is sorted, the current image backup set is also a sorted backup set, meaning the image backup with the highest priority is determined from the current image backup set, i.e., the highest priority backup image (back-image), to obtain the target image backup and its corresponding target backup repository, thereby completing the acquisition of the alternative image address. It is understood that the step of prioritizing the images in the image backup set can be performed after obtaining the image backup set, or it can be performed after determining the current image backup set corresponding to the current image from all the image backup sets, and only prioritizing the images in the current image backup set.

[0085] Step S36: Generate target image backup acquisition information based on the target image backup and the target backup repository.

[0086] In this embodiment, after determining the highest-priority image backup from the sorted image backup set to obtain the target image backup and its corresponding target backup repository, target image backup acquisition information is generated from the target image backup and the target backup repository. It is understood that the target image backup acquisition information includes image repository information, image name information, and image version number information.

[0087] Step S37: Replace the current image acquisition information in the current image pull event with the target image backup acquisition information through the preset image replacement service, so as to acquire the target image backup based on the target image backup acquisition information.

[0088] In this embodiment, after generating target image backup acquisition information based on the target image backup and the target backup repository, the current image acquisition information in the current image pull event is replaced with the target image backup acquisition information through a preset image replacement service, so as to acquire the target image backup based on the target image backup acquisition information. Figure 5As shown, multiple identical image sets (i.e. image backup sets) are obtained through the image repository configuration center. When an image pull failure event is detected, the highest priority image is pulled from the identical image set corresponding to the image pull failure event through the image pull failure handling controller. The current image acquisition information in the current image pull event is replaced with the target image backup acquisition information so that the corresponding target image backup can be obtained directly based on the target image backup acquisition information. The target image backup is then sent to the Kubernetes cluster.

[0089] For details regarding steps S31 and S32, please refer to the corresponding content disclosed in the foregoing embodiments, which will not be repeated here.

[0090] As can be seen, this application embodiment configures a target image repository configuration model containing a preset number of image repositories; scans all the image repositories in the target image repository configuration model to obtain the image backup set corresponding to each target image; sorts all the images in the image backup set according to a preset priority sorting rule to obtain a sorted image backup set; when an image pull failure event is detected, the corresponding current image is obtained, and the current image backup set corresponding to the current image is determined from all the image backup sets; the image backup with the highest priority is determined from the sorted image backup set to obtain the target image backup and the corresponding target backup repository; target image backup acquisition information is generated based on the target image backup and the target backup repository; and the current image acquisition information in the current image pull event is replaced with the target image backup acquisition information through a preset image replacement service, so that the target image backup can be acquired based on the target image backup acquisition information, reducing manual labor and improving resource utilization and the flexibility of image acquisition methods.

[0091] See Figure 6 As shown in the figure, this application also discloses a mirror acquisition device, including:

[0092] Model configuration module 11 is used to configure a target image repository configuration model containing a preset number of image repositories;

[0093] The image backup set acquisition module 12 is used to scan all the image repositories in the target image repository configuration model to obtain the image backup set corresponding to each target image;

[0094] The current image backup set determination module 13 is used to obtain the corresponding current image when an image pull failure event is detected, and to determine the current image backup set corresponding to the current image from all the image backup sets;

[0095] The image backup acquisition module 14 is used to determine the target image backup from the current image backup set based on a preset image backup determination method, and acquire the target image backup through the preset image acquisition method.

[0096] As can be seen, this application includes: configuring a target image repository configuration model containing a preset number of image repositories; scanning all the image repositories in the target image repository configuration model to obtain an image backup set corresponding to each target image; when an image pull failure event is detected, obtaining the corresponding current image, and determining the current image backup set corresponding to the current image from all the image backup sets; determining the target image backup from the current image backup set based on a preset image backup determination method, and obtaining the target image backup through a preset image acquisition method. Therefore, this application, by scanning multiple image repositories to obtain a multi-repository image backup set corresponding to each image, configures multiple existing clusters or multiple independently available image repositories together as mutual backups, so that when an image pull fails, the corresponding image backup is automatically obtained from the image backup set for replacement, without manual intervention, reducing manpower and improving resource utilization and the flexibility of image acquisition methods.

[0097] In some specific embodiments, the model configuration module 11 specifically includes:

[0098] The model configuration unit is used to obtain all existing image repositories and configure the target image repository configuration model with all the image repositories using the factory pattern; wherein, the target image repository configuration model includes repository ID, image repository type, username, and password.

[0099] In some specific embodiments, the image backup set acquisition module 12 specifically includes:

[0100] The target image determination unit is used to determine the target image.

[0101] The mirror repository scanning unit is used to automatically scan all the mirror repositories in the target mirror repository configuration model based on the target mirror;

[0102] A mirror repository login unit is used to log in to the mirror repository based on the username and password of each mirror repository;

[0103] The image acquisition unit is used to call the preset interface of each image repository to obtain all images in each image repository and the image ID corresponding to each image;

[0104] The target image ID acquisition unit is used to determine the target image from all the images and acquire the target image ID of the target image;

[0105] The ID matching unit is used to match the image IDs of the remaining images with the target image IDs to obtain a set of successfully matched target images and a set of corresponding repositories.

[0106] The image backup set generation unit is used to generate the image backup set corresponding to the target image based on the target image, the target repository, the target image set, and the repository set.

[0107] The image backup sorting unit is used to sort all the images in the image backup set according to a preset priority sorting rule to obtain a sorted image backup set.

[0108] In some specific embodiments, the current image backup set determination module 13 specifically includes:

[0109] The image pull event listening unit is used to listen to the image pull event results in real time through the automation controller, and determine whether there is an image pull failure event based on the pull results;

[0110] The current image backup set determination unit is used to obtain the corresponding current image when an image pull failure event is detected, and to determine the current image backup set corresponding to the current image from all the image backup sets.

[0111] In some specific embodiments, the image backup acquisition module 14 specifically includes:

[0112] The target backup repository determination unit is used to determine the highest priority image backup from the sorted image backup set, so as to obtain the target image backup and the corresponding target backup repository.

[0113] A target image backup acquisition information acquisition unit is used to generate target image backup acquisition information based on the target image backup and the target backup repository;

[0114] The target image backup acquisition unit is used to replace the current image acquisition information in the current image pull event with the target image backup acquisition information through a preset image replacement service, so as to acquire the target image backup based on the target image backup acquisition information.

[0115] Furthermore, embodiments of this application also provide an electronic device. Figure 7 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.

[0116] Figure 7This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the image acquisition method disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0117] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0118] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0119] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the image acquisition method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include a computer program capable of performing other specific tasks.

[0120] Furthermore, this application also discloses a storage medium storing a computer program, which, when loaded and executed by a processor, implements the image acquisition method steps disclosed in any of the foregoing embodiments.

[0121] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0122] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0123] The present invention has provided a detailed description of an image acquisition method, apparatus, device, and storage medium. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A method for obtaining an image, characterized in that, include: Configure a target image repository configuration model that includes a preset number of image repositories; Scan all the image repositories in the target image repository configuration model to obtain the image backup set corresponding to each target image; All images in the image backup set are sorted according to a preset priority sorting rule to obtain a sorted image backup set; When an image pull failure event is detected, the corresponding current image is obtained, and the current image backup set corresponding to the current image is determined from all the image backup sets. The target image backup is determined from the current image backup set based on a preset image backup determination method, and the target image backup is obtained through a preset image acquisition method. This includes: determining the image backup with the highest priority from the sorted image backup set to obtain the target image backup and its corresponding target backup repository; generating target image backup acquisition information based on the target image backup and the target backup repository; and replacing the current image acquisition information in the current image pull event with the target image backup acquisition information through a preset image replacement service, so as to obtain the target image backup based on the target image backup acquisition information.

2. The image acquisition method according to claim 1, characterized in that, The configuration includes a preset number of target mirror repository configuration models, including: Obtain all existing image repositories and configure the target image repository configuration model using the factory pattern and all the image repositories; wherein, the target image repository configuration model includes repository ID, image repository type, username, and password.

3. The mirror acquisition method according to claim 2, characterized in that, The step of scanning all the image repositories in the target image repository configuration model to obtain the image backup set corresponding to each target image includes: Identify the target image, and automatically scan all the image repositories in the target image repository configuration model based on the target image; The target image obtained from the scan and the target repository corresponding to each target image are acquired. The corresponding image backup set is generated based on the target image and the target repository.

4. The mirror acquisition method according to claim 3, characterized in that, The process of obtaining the target image and the target repository corresponding to each target image through scanning includes: Log in to the image repository using the username and password for each image repository; Call the preset interface of each image repository to obtain all images in each image repository and the image ID corresponding to each image; Accordingly, generating the corresponding image backup set based on the target image and the target repository includes: The target image is determined from all the images, and the target image ID of the target image is obtained; The remaining image IDs are matched with the target image IDs to obtain a set of successfully matched target images and a set of corresponding repositories. Based on the target image, the target repository, the target image set, and the repository set, generate the image backup set corresponding to the target image.

5. The mirror acquisition method according to any one of claims 1 to 4, characterized in that, Before obtaining the corresponding current image when an image pull failure event is detected, the process also includes: The automated controller monitors the image pull event results in real time and determines whether there is an image pull failure event based on the pull results.

6. A mirror acquisition device, characterized in that, include: The model configuration module is used to configure a target image repository configuration model containing a preset number of image repositories; The image backup set acquisition module is used to scan all the image repositories in the target image repository configuration model to obtain the image backup set corresponding to each target image; All the images in the image backup set are sorted according to a preset priority sorting rule to obtain a sorted image backup set; The current image backup set determination module is used to obtain the corresponding current image when an image pull failure event is detected, and to determine the current image backup set corresponding to the current image from all the image backup sets; The image backup acquisition module is used to determine a target image backup from the current image backup set based on a preset image backup determination method, and to acquire the target image backup through the preset image acquisition method. The image backup acquisition module includes: a target backup repository determination unit, used to determine the highest priority image backup from the sorted image backup set to obtain the target image backup and the corresponding target backup repository; a target image backup acquisition information acquisition unit, used to generate target image backup acquisition information based on the target image backup and the target backup repository; and a target image backup acquisition unit, used to replace the current image acquisition information in the current image pull event with the target image backup acquisition information through a preset image replacement service, so as to acquire the target image backup based on the target image backup acquisition information.

7. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the image acquisition method as described in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, Used to store computer programs; wherein, when the computer programs are executed by a processor, they implement the image acquisition method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Mirror image backup method and device, electronic equipment and readable storage medium

    CN113886021A

  • Method and device for improving stability of mirror image warehouse, equipment and medium

    CN115695453A