Image distribution method, device, electronic device and storage medium

By determining the image to be tested in the central mirror library and distributing it to the target environment node for processing, combined with the automated construction and deployment process, the problem of high pressure in the central mirror warehouse is solved, and the rapid and reliable deployment of the mirror and load relief are achieved.

CN118631827BActive Publication Date: 2024-11-05E SURFING VISION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411115442.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-14
Publication Date
2024-11-05
Estimated Expiration
2044-08-14

AI Technical Summary

Technical Problem

In the prior art, the distribution and processing of central mirror warehouses is under great pressure and there is a lack of effective solutions.

Method used

By responding to project test requests, determine the image to be tested in the central image library and distribute it to the target environment node for processing based on the mirroring information, avoiding directly obtaining the image from the central image library for processing, and adopting automated construction, testing and deployment processes , mirroring is automatically distributed to the production environment after passing the test environment and grayscale environment, reducing network latency and bandwidth consumption.

Benefits of technology

It alleviates the distribution and processing pressure of the central mirror warehouse, realizes the rapid and reliable deployment of mirrors, and reduces the load on the central mirror warehouse from the development stage to the production environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118631827B_ABST
    Figure CN118631827B_ABST
Patent Text Reader

Abstract

The present application relates to an image distribution method, device, electronic device and storage medium, wherein the image distribution method comprises: in response to a received project test request, determining an image to be tested in a central image library; the image to be tested carries image information; according to the image information, the image to be tested is distributed to a target environment node; the target environment node includes a node for project testing; and the image to be tested is processed in the target environment node. Through the present application, the distribution processing pressure of the central image warehouse is relieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of cloud computing, and in particular to an image distribution method, device, electronic device and storage medium. Background Art

[0002] CICD is the abbreviation of Continuous Integration (CI), Continuous Delivery (CD) and Continuous Deployment (CD). Application services use the CICD process for version upgrades. R&D personnel first submit the code to the code repository, and the CICD tool compiles the code into an image, and then uploads the container image to the image repository. After that, the test environment, grayscale environment, and production environment of the application service will pull the image from the image repository.

[0003] The current method of image distribution is to upload the image to the central image warehouse, and then the test environment, grayscale environment, and production environment of the application service will pull the image from the central image warehouse. However, due to the large number of application services and the need to iteratively upgrade the versions, the pressure on the image warehouse is very high. Therefore, it is necessary to alleviate the distribution processing pressure of the central image warehouse.

[0004] With regard to the problem of high distribution processing pressure of the central image repository in related technologies, no effective solution has been proposed so far. Summary of the invention

[0005] In this embodiment, an image distribution method, device, electronic device and storage medium are provided to solve the problem of high distribution processing pressure of a central image warehouse in related technologies.

[0006] In a first aspect, an image distribution method is provided in this embodiment, the method comprising:

[0007] In response to the received project test request, determine the image to be tested in the central image library; the image to be tested carries image information;

[0008] Distributing the image to be tested to a target environment node according to the image information; the target environment node includes a node for project testing;

[0009] The image to be tested is processed in the target environment node.

[0010] In some of the embodiments, before responding to the project test request, the method further includes:

[0011] Acquire multiple business images, wherein the business images include the image information;

[0012] According to the image information, mark information is added to the plurality of business images, and according to the mark information, the business images are stored in the central image library.

[0013] In some embodiments, in response to the received project test request, determining the image to be tested in the central image library includes:

[0014] Determine the image to be tested from multiple business images in the central image library according to the test project and the image tag carried in the project test request;

[0015] Add a test tag to the image to be tested;

[0016] Using a preset analysis tool, the image to be tested with the test tag added is tested to obtain a test result;

[0017] When the detection result reaches a preset result threshold, the test tag of the image to be tested is updated to a test passed tag.

[0018] In some of these embodiments, the target environment node includes a first environment node;

[0019] The step of distributing the image to be tested to a target environment node according to the image information includes:

[0020] Determine a first environment node for image distribution according to the project test request;

[0021] Pull the image to be tested from the central image library to the first environment node, and test the image to be tested in the first environment node.

[0022] In some embodiments, the target environment node further includes a second environment node; and the step of distributing the image to be tested to the target environment node according to the image information further includes:

[0023] When the image to be tested passes the test in the first environment node, the image to be tested is pulled from the central image library to the second environment node, and the image to be tested is tested in the second environment node.

[0024] In some embodiments, the method further comprises:

[0025] Obtaining the storage time of the business image stored in the central image library;

[0026] Determining whether the storage time exceeds a preset time threshold;

[0027] If the storage time exceeds a preset time threshold, the business image corresponding to the storage time is deleted.

[0028] In some embodiments, the method further comprises:

[0029] The image distribution task of the image to be tested is stored in a task queue, and log data of the image distribution task is obtained;

[0030] Determining whether the image to be tested has failed to be processed according to the log data;

[0031] If so, determining whether the number of processing times of the image distribution task exceeds a preset processing times threshold;

[0032] When the processing times of the image distribution task exceeds a preset processing times threshold, an alarm signal is sent to a preset client.

[0033] In a second aspect, in this embodiment, a mirror distribution device is provided, the device comprising: a response module, a distribution module and a processing module;

[0034] The response module is used to determine the image to be tested in the central image library in response to the received project test request; the image to be tested carries image information;

[0035] The distribution module is used to distribute the image to be tested to a target environment node according to the image information; the target environment node includes a node for project testing;

[0036] The processing module is used to process the image to be tested in the environment node.

[0037] In a third aspect, an electronic device is provided in this embodiment, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the image distribution method described in the first aspect when executing the computer program.

[0038] In a fourth aspect, a storage medium is provided in this embodiment, on which a computer program is stored, and when the program is executed by a processor, the image distribution method described in the first aspect is implemented.

[0039] Compared with the related art, an image distribution method, device, electronic device and storage medium provided in this embodiment obtain the image to be tested in the project in the central image library in response to the received project test request, and distribute the test of the image to be tested to the gray environment node and the production environment node according to the image information, and process the image to be tested in different environments respectively, thereby avoiding directly obtaining the image to be tested from the central image library for processing, thereby alleviating the distribution processing pressure of the central image warehouse.

[0040] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0042] Figure 1 It is a hardware structure block diagram of a terminal of the image distribution method provided in an embodiment of the present application;

[0043] Figure 2 is a flowchart of the image distribution method provided by an embodiment of the present application;

[0044] Figure 3 is a flowchart of the automatic image distribution method based on the CICD process of this specific embodiment;

[0045] Figure 4 This is the image building and uploading process provided by this specific embodiment;

[0046] Figure 5 It is a schematic diagram of the process of image deployment and distribution provided in this specific embodiment;

[0047] Figure 6 It is a structural block diagram of the image distribution device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0048] In order to more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.

[0049] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with general skills in the technical field to which this application belongs. The words "one", "a", "the", "these" and the like in this application do not indicate a quantitative limitation, and they may be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" may mean: A exists alone, A and B exist at the same time, and B exists alone. Generally, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0050] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1 : is a hardware structure block diagram of a terminal of the image distribution method provided in an embodiment of the present application. Figure 1 As shown, the terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 and a memory 104 for storing data, wherein the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.

[0051] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the image distribution method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0052] The transmission device 106 is used to receive or send data via a network. The above network includes a wireless network provided by a communication provider of the terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.

[0053] Based on the problem of high distribution processing pressure of the central image warehouse in the prior art, the embodiment of the present application automatically manages distribution in the entire process of image building, testing and deployment, labels the images of the test environment, gray environment and production environment, and automatically distributes the images that have passed the test environment verification to the gray nodes according to certain strategies. Afterwards, the images that have passed the gray environment verification are automatically distributed to the production nodes according to certain strategies to ensure that the images are pulled from the local when the software is deployed. Automatic distribution of images can reduce network latency and bandwidth consumption, thereby alleviating the distribution processing pressure of the central image warehouse; by automating the construction, testing and deployment of images, it is ensured that the software can be quickly and reliably deployed from the development stage to the production environment.

[0054] Specifically, a mirror distribution method is provided in an embodiment of the present application. Figure 2 is a flowchart of the image distribution method provided by the embodiment of the present application, such as Figure 2 As shown, the process includes the following steps:

[0055] Step S210: In response to the received project test request, determine the image to be tested in the central image library; the image to be tested carries image information.

[0056] Among them, when the project needs to be tested, the processor receives the project test request initiated by the client, that is, receives the project test requirement initiated by the client, and determines the image to be tested in the central image library according to the project test request. The image to be tested also carries unique image information. Exemplarily, the image information includes the image name and the image tag. The project test request includes the target environment information of the project, as well as the image tag in the image information, etc.

[0057] Step S220, distributing the image to be tested to the target environment nodes according to the image information; the target environment nodes include the nodes for project testing.

[0058] Wherein, the target environment node includes a first environment node and a second environment node. The processor distributes the image to be tested to the target environment node for project testing according to the image information of the image to be tested. The target environment node is determined according to the project test request initiated by the client and the image information. Exemplarily, the first environment node includes a gray environment node, and the second environment node includes a production environment node. By distributing the image to be tested to the first environment node and the second environment node in turn, it is determined whether the image to be tested passes the gray test and the production test. Furthermore, after the project test request is distributed to the first environment node, the first environment node obtains the image to be tested from the central image library to the local image library of the first environment node according to the request, so as to reduce the pressure on the central image library during the peak period of project testing.

[0059] Step S230: Process the image to be tested in the target environment node.

[0060] Among them, after the processor pulls the image to be tested at the first environment node and the test passes, it pulls the image to be tested at the second environment node to test, thereby realizing the distribution test of the image in the project.

[0061] Through the steps in the above embodiment, the processor responds to the received project test request, obtains the image to be tested in the project from the central image library, and distributes the test of the image to be tested to the gray environment node and the production environment node according to the image information, and processes the image to be tested in different environments respectively, thereby avoiding directly obtaining the image to be tested from the central image library for processing, thereby alleviating the distribution processing pressure of the central image warehouse.

[0062] In some of the embodiments, before responding to the project test request, it also includes: obtaining multiple business images, the business images include image information; adding marking information to the multiple business images according to the image information, and storing the business images in a central image library according to the marking information.

[0063] Among them, after the R&D personnel build the business image according to the code integration, the multiple business images are pushed to the final image library. Furthermore, the business image includes image information, and the image information includes an image tag and an image name. According to the image tag and the image name in the image information, the business image is stored in the central image library. Exemplarily, the specific method of storing the business image includes: logging in to the central image library, marking the business image, and pushing the marked business image to the central image library.

[0064] The method of storing the business image in the central image library is conducive to subsequently pulling the business image from the central image library according to the image information of the business image, and distributing and testing the business image.

[0065] In some embodiments, in response to the received project test request, determining the image to be tested in the central image library in step S210 includes:

[0066] Step S211 , according to the test project and the image tag carried in the project test request, determine the image to be tested from multiple business images in the central image library.

[0067] The processor determines the test project to be tested and the image tag of the business image corresponding to the project according to the project test request, and then determines the corresponding image to be tested in the central image library according to the test project and the image tag.

[0068] Step S212, adding a test tag to the image to be tested; using a preset analysis tool, testing the image to be tested with the test tag added to obtain a test result.

[0069] Among them, after the processor determines the image to be tested, it performs automated testing on the image to be tested with the test tag added according to the preset analysis tool, which can be specifically code quality analysis testing and image security testing, and obtains the test results. The preset analysis tool can be a static code tool, an automated vulnerability scanner, a container image security assessor, etc., which is not specifically limited here.

[0070] Step S213: When the detection result reaches a preset result threshold, the test tag of the image to be tested is updated to a test passed tag.

[0071] When the detection result of the image to be tested reaches a preset result threshold, that is, after the test is passed, the test tag of the image to be tested is updated to a test pass tag to indicate that the image to be tested has passed the test in the test environment.

[0072] Through the above steps, after the processor determines the image to be tested corresponding to the project test request, it first pulls the image to be tested from the central image warehouse in the test environment, tests the image to be tested, and finally obtains the result that the image to be tested passes the test.

[0073] In some embodiments, the image to be tested is distributed to the target environment node according to the image information, including: determining the first environment node for image distribution according to the project test request; pulling the image to be tested from the central image library to the first environment node, and testing the image to be tested in the first environment node. When the image to be tested passes the test in the first environment node, the image to be tested is pulled from the central image library to the second environment node, and the image to be tested is tested in the second environment node.

[0074] Among them, when the image to be tested passes the test environment, the processor determines the first environment node for grayscale testing according to the project test request and the image information of the image to be tested, and obtains the image to be tested with a test pass label from the central image library to the local image library, and then pulls the image to be tested from the local image library, and performs grayscale testing on the image to be tested in the first environment node. Then, according to the same steps, production testing is performed on the image to be tested in the second environment node.

[0075] The image distribution request is received in sequence by the first environment node and the second environment node, and the image to be tested is pulled from the local image library, avoiding directly obtaining the image to be tested from the central image library for processing, thereby alleviating the distribution processing pressure of the central image warehouse.

[0076] In some of the embodiments, the image distribution also includes obtaining the storage time of the business image stored in the central image library; determining whether the storage time exceeds a preset time threshold; if the storage time exceeds the preset time threshold, deleting the business image corresponding to the storage time.

[0077] Among them, after the image distribution to the first environment node and the second environment node is enabled according to the test request of the project, a large number of images are stored in the corresponding local image library. Therefore, the images need to be processed in a timely manner, that is, according to the time when the business image is pulled to the local image library, as well as the dimensions such as project, node, and label, the business image whose storage time exceeds the preset time threshold is deleted.

[0078] Deleting business images that have been stored for a long time can help alleviate the storage pressure of the local image library.

[0079] In some of the embodiments, the image distribution task of the image to be tested is stored in a task queue, and log data of the image distribution task is obtained; based on the log data, it is determined whether there is a processing failure in the image to be tested; if so, it is determined whether the processing times of the image distribution task exceed a preset processing times threshold; when the processing times of the image distribution task exceed the preset processing times threshold, an alarm signal is sent to a preset client.

[0080] Among them, in the process of processing the image to be tested according to the project test request, the log data of the image distribution task is obtained, and it is determined whether the processing fails based on the log data. If it fails, it is determined whether the processing times of the image distribution task in the task queue exceeds the preset processing times threshold. If it exceeds, it means that an alarm signal needs to be sent to the preset client.

[0081] Through the above steps, the log data of the image distribution task is analyzed and monitored, and an alarm is issued for the failed tasks, which is conducive to improving the accuracy of image distribution and image pulling.

[0082] The present embodiment is described and illustrated by means of specific examples below.

[0083] CICD is the abbreviation of Continuous Integration (CI), Continuous Delivery (CD) and Continuous Deployment (CD). The main process of CICD is as follows:

[0084] (1) Submit code: Developers submit code changes in the code repository.

[0085] (2) Continuous Integration: After the code is submitted, the user triggers the continuous integration process through CICD tools (such as Jenkins). The CICD tool will pull the latest code and compile, build, and package it into an image in a clean environment.

[0086] (3) Automated testing: After the image is built, the automated testing tool will run various tests, including unit testing, integration testing, and end-to-end testing, to verify the correctness and functionality of the code.

[0087] (4) Static code analysis: CICD tools (such as SonarQube) also use static code analysis tools to check code quality, find potential errors and vulnerabilities, and ensure that the code complies with coding standards.

[0088] (5) Deploy to a test environment: Once the tests pass and the code quality is satisfactory, CICD tools (such as Kubernetes) will deploy the application to a test environment so that developers and other team members can perform further testing and review.

[0089] (6) Deployment to the grayscale environment: After the application passes the testing and review in the test environment, the CICD tool (such as Kubernetes) will deploy the application to the grayscale environment for grayscale verification and review.

[0090] (7) Deployment to the production environment: After the application has passed the verification and review in the grayscale environment, the CICD tool (such as Kubernetes) will deploy the application to the production environment to provide external services.

[0091] (8) Monitoring and feedback: When an application is deployed in a production environment, CICD tools (such as Pinpoint) will monitor application performance, availability, and errors, and send alerts when problems occur. In addition, it can generate operation logs and reports to help team members better understand the operation status of the application.

[0092] This application is based on the CICD process, and automatically manages the entire process of image building, testing and deployment. It labels the images of the test environment, grayscale environment and production environment. The images that have passed the test environment verification are automatically distributed to the grayscale node images according to certain strategies. The images that have passed the grayscale environment verification are automatically distributed to the production nodes according to certain strategies to ensure that the images are pulled locally when the software is deployed.

[0093] Figure 3 This is a flowchart of the automatic image distribution method based on the CICD process of this specific embodiment. Figure 3 , including steps S310 to S380.

[0094] Step S310: submit the code and build a business image.

[0095] Specifically, Figure 4 This is the image building and uploading process provided by this specific embodiment. Figure 4 , R&D personnel submit the code to the code and document management warehouse - Gitlab warehouse, then select the branch of the code, use the independent program Jenkins to trigger continuous integration, and Jenkins compiles and builds the Docker image according to the text file Dockerfile. The complete image contains the image name and image tag. The image tag contains the branch number and timestamp to ensure the uniqueness of the image. Among them, the complete image format is: <local-image> : <tag>.

[0096] Furthermore, local-image indicates the image name, and tag indicates the image tag. Jenkins is a standalone program based on Java, including Windows, Mac OS X, and other Linix operating systems.

[0097] Step S320: Upload the business image to the central image repository.

[0098] Specifically, after the business image is built, it needs to be uploaded to the central image warehouse, where the central image warehouse is the central image library in the aforementioned embodiment; Figure 4 , upload the business image to the Harbor image repository. This operation is automatically completed through Jenkins (a continuous integration tool used to monitor continuous and repetitive work). The push method is as follows:

[0099] Log in to the image repository

[0100] docker login <registry-url>

[0101] Tag local image

[0102] docker tag <local-image> : <tag> <registry-url> / <namespace> / <repository> : <tag>

[0103] Push the image to the repository

[0104] docker push <registry-url> / <namespace> / <repository> : <tag>

[0105] Step S330: initiate a test request and pull the image from the test environment.

[0106] Specifically, Figure 5 This is a schematic diagram of the image deployment and distribution process provided by this specific embodiment. Figure 5 First, the test deployment is carried out. The R&D personnel initiate the test in the test module of the work order system. The work order system records the project's test environment, grayscale environment, and production environment information. After the R&D selects the project to be tested and selects the image tag in the work order system, the work order system will generate a test work order and send a rolling upgrade request to the test environment. After receiving the request, the project's test environment will go to the central image warehouse to pull the image. After the image is successfully started, the image management module of the work order system will label the image with a test.

[0107] Step S340: code quality analysis.

[0108] Specifically, refer to Figure 5 After the image deployment is completed in the testing environment, code quality analysis and image security scanning will be performed. Use static code analysis tools (such as SonarQube) to check code quality, find potential errors and vulnerabilities, and ensure that the code complies with coding standards; then use software component analysis tools such as Qingyuan SCA to scan the container to ensure container security.

[0109] Step S350: After the test is passed, the image is distributed.

[0110] Specifically, refer to Figure 5 , after the image deployed in the test environment passes the automated test and the test department's verification, the tester clicks the test pass in the work order system test module, and the work order system image management module will label the image of the project with a test pass label; the test pass label here is the test pass label in the aforementioned embodiment; at the same time, an image distribution request will be sent to the image distribution module (i.e., the image distribution task producer), and then the image will be distributed to the gray environment node according to the image distribution request. The gray environment node here is the first environment node in the aforementioned embodiment.

[0111] Step S360: Pull the image in the grayscale environment.

[0112] Specifically, for the image that has passed the project test, the image pulling module (image distribution task consumer) of the grayscale node where the project is located will receive the image distribution request and pull the image from the central warehouse to the local image warehouse of the grayscale node. When the image is deployed in the grayscale environment of the project for rolling upgrade, the image will be pulled from the local warehouse, which is conducive to reducing the pressure on the central warehouse during the peak period of business upgrade. Afterwards, when the image deployed in the grayscale environment is verified by the testing department in the grayscale environment, the tester clicks on the grayscale pass in the work order system test module, and the image management module of the work order system will label the image of the project with a gray-pass label, and at the same time send an image distribution request to the image distribution module (image distribution task producer), and the image will start to be distributed to the production environment node. The production environment node here is the second environment node in the aforementioned embodiment.

[0113] Step S370: Pull the image from the production environment.

[0114] Specifically, refer to Figure 5 For images that have passed the grayscale environment test, the image pulling module (image distribution task consumer) of the production node where the project is located will receive the image distribution request and pull the image from the central warehouse to the local image warehouse of the production node. When the project production environment is rolling upgraded and deployed, the image will be pulled from the local warehouse to reduce the pressure on the central warehouse during the peak period of business upgrades. After the image deployed in the production environment passes the regression verification of the production environment test department, the tester clicks on the production pass in the work order system test module, and the work order system image management module will label the image of the project with a production pass (product-pass).

[0115] Step S380: image cleanup and monitoring alarms.

[0116] Specifically, the project image is distributed to the grayscale node and the production node. The local image warehouse of the grayscale node and the production node, that is, the local image warehouse in the aforementioned embodiment, will have a large number of business images. If it is not cleaned up in time, it will occupy disk space and affect machine performance. The image cleaning module of the work order system will analyze the images of each project grayscale node and production node, and analyze them according to the project dimension, node dimension, and label dimension. According to the number of images reserved by the project configuration (the default is 10), according to the order of image upload time, the earliest uploaded images in the local warehouse and the central warehouse will be cleaned up first.

[0117] At the same time, it is necessary to monitor the image center warehouse and the local image warehouse, mainly monitoring the warehouse load (CPU, memory, disk, bandwidth) indicators to ensure the stability of the image warehouse. Use the Prometheus tool to periodically capture the status of the monitored components through the HTTP protocol to collect and process indicator data. The monitoring implementation method is as follows:

[0118] CPU usage: The monitoring indicator node_cpu_seconds_total{mode="idle"} is used to indicate the total amount of CPU idle time in seconds. By monitoring the CPU usage, you can understand the system load;

[0119] Memory usage: Monitor the indicators node_memory_MemFree_bytes and node_memory_MemTotal_bytes. Through these indicators, you can calculate the memory usage using the following formula:

[0120] (node_memory_MemTotal_bytes-node_memory_MemFree_bytes-node_memory_Cached_bytes) / node_memory_MemTotal_bytes.

[0121] Among them, node_memory_MemTotal_bytes indicates the total system memory, node_memory_Cached_bytes indicates the memory used by the system cache, and node_memory_MemFree_bytes indicates the amount of physical memory that is not actually used by the node.

[0122] Disk I / O: Monitoring indicators monitor the disk read and write rates, waiting time, etc., to understand the disk load and performance bottlenecks.

[0123] Network traffic: The monitoring indicator irate (node_network_receive_bytes_total[5m]) indicates the rate at which the network receives bytes and is used to monitor network traffic.

[0124] In one of the specific embodiments, logs are embedded for business image uploading, image pulling, image distribution, and image cleaning. The log collection tool - filebeat is used to collect standardized logs. The work order system image monitoring and alarm module analyzes the logs, monitors the entire process of business images, and sends email alerts for execution errors to ensure successful image distribution and image pulling.

[0125] The real-time monitoring method is as follows: for operations such as image upload, image pull, image distribution, and image pull, print behavior logs, including operation time, operation type, warehouse address, image name, image tag, image size, processing results, upload IP, uploader and other information. The log collection tool filebeat collects logs in real time to the distributed message distribution subscription system - kafka, monitors the service consumption of kafka messages, filters and processes failed requests, and sends alarm emails.

[0126] The embodiment of the present application manages the software image, analyzes and labels the image deployed to the test environment, and ensures the consistency of the image versions of the test, grayscale, and production environments; the software image is automatically distributed, and the image that passes the test will automatically send the image distribution task to the node where the software is deployed. When the node receives the image distribution request, it will automatically pull the image to the local disk.

[0127] In one of the specific embodiments, a local image pulling method is provided. Specifically, when the software is rolling upgraded, a container is preferentially created from a local image, and the image name and label are referenced to run the container.

[0128] In this embodiment, a mirror distribution device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. The terms "module", "unit", "subunit", etc. used below can be a combination of software and / or hardware that implements the predetermined functions. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0129] Figure 6 is a structural block diagram of the image distribution device provided in an embodiment of the present application, such as Figure 6 As shown, the device includes: a response module 10, a distribution module 20 and a processing module 30.

[0130] The response module 10 is used to determine the image to be tested in the central image library in response to the received project test request; the image to be tested carries image information.

[0131] The distribution module 20 is used to distribute the image to be tested to the target environment node according to the image information; the target environment node includes the node for project testing.

[0132] The processing module 30 is used to process the image to be tested in the environment node.

[0133] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.

[0134] In this embodiment, an electronic device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0135] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0136] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:

[0137] S1, in response to a received project test request, determining an image to be tested in a central image library; the image to be tested carries image information.

[0138] S2, distribute the image to be tested to the target environment nodes according to the image information; the target environment nodes include the nodes for project testing.

[0139] S3, processes the image to be tested in the target environment node.

[0140] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and will not be repeated in this embodiment.

[0141] In addition, in combination with the image distribution method provided in the above embodiments, a storage medium may be provided in this embodiment to implement the image distribution method. The storage medium stores a computer program; when the computer program is executed by a processor, any image distribution method in the above embodiments is implemented.

[0142] It should be understood that the specific embodiments described herein are only used to explain the application, rather than to limit it. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of this application.

[0143] Obviously, the drawings are only some examples or embodiments of the present application. For ordinary technicians in the field, the present application can also be applied to other similar situations based on these drawings without creative work. In addition, it is understandable that although the work done in this development process may be complicated and lengthy, for ordinary technicians in the field, certain changes in design, manufacturing or production based on the technical content disclosed in this application are only conventional technical means and should not be regarded as insufficient content disclosed in this application.

[0144] The term "embodiment" in this application refers to a specific feature, structure or characteristic described in conjunction with the embodiment that can be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. It is clearly or implicitly understood by those of ordinary skill in the art that the embodiments described in this application can be combined with other embodiments without conflict.

[0145] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of patent protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the attached claims.< / tag> < / repository> < / namespace> < / registry-url> < / tag> < / repository> < / namespace> < / registry-url> < / tag> < / local-image> < / tag> < / local-image>

Claims

1. A mirror distribution method, characterized in that: The method comprises: In response to the received project test request, determine the image to be tested in the central image library; the image to be tested carries image information; Distributing the image to be tested to a target environment node according to the image information; the target environment node includes a node for project testing; Processing the image to be tested in the target environment node; The target environment node includes a first environment node and a second environment node; and distributing the image to be tested to the target environment node according to the image information includes: According to the project test request, determine the first environment node for image distribution; pull the image to be tested from the central image library to the local image repository of the first environment node, pull the image to be tested from the local image repository when rolling upgrades the image to be tested, and test the image to be tested in the first environment node; When the image to be tested passes the test in the first environment node, the image to be tested is pulled from the central image library to the local image repository of the second environment node. When the image to be tested is deployed by rolling upgrade, the image to be tested is pulled from the local image repository and tested in the second environment node.

2. The image distribution method according to claim 1, characterized in that: Before responding to the project test request, the method further includes: Acquire multiple business images, wherein the business images include the image information; According to the image information, mark information is added to the plurality of business images, and according to the mark information, the business images are stored in the central image library.

3. The image distribution method according to claim 1, characterized in that: The step of determining the image to be tested in the central image library in response to the received project test request includes: Determine the image to be tested from multiple business images in the central image library according to the test project and the image tag carried in the project test request; Add a test tag to the image to be tested; Using a preset analysis tool, the image to be tested with the test tag added is tested to obtain a test result; When the detection result reaches a preset result threshold, the test tag of the image to be tested is updated to a test passed tag.

4. The image distribution method according to claim 2, characterized in that: The method further comprises: Obtaining the storage time of the business image stored in the central image library; Determining whether the storage time exceeds a preset time threshold; If the storage time exceeds a preset time threshold, the business image corresponding to the storage time is deleted.

5. The image distribution method according to claim 1, characterized in that: The method further comprises: The image distribution task of the image to be tested is stored in a task queue, and log data of the image distribution task is obtained; Determining whether the image to be tested has failed to be processed according to the log data; If so, determining whether the number of processing times of the image distribution task exceeds a preset processing times threshold; When the processing times of the image distribution task exceeds a preset processing times threshold, an alarm signal is sent to a preset client.

6. A mirror distribution device, characterized in that: The device comprises: a response module, a distribution module and a processing module; The response module is used to determine the image to be tested in the central image library in response to the received project test request; the image to be tested carries image information; The distribution module is used to distribute the image to be tested to the target environment node according to the image information; the target environment node includes a node for project testing; the target environment node includes a first environment node and a second environment node; the distribution of the image to be tested to the target environment node according to the image information includes: determining the first environment node for image distribution according to the project test request; pulling the image to be tested from the central image library to the local image warehouse of the first environment node, and when rolling upgrades the image to be tested, pulling the image to be tested from the local image warehouse and testing the image to be tested in the first environment node; when the image to be tested passes the test in the first environment node, pulling the image to be tested from the central image library to the local image warehouse of the second environment node, and when rolling upgrades the image to be tested, pulling the image to be tested from the local image warehouse and testing the image to be tested in the second environment node; The processing module is used to process the image to be tested in the environment node.

7. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the image distribution method according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the image distribution method according to any one of claims 1 to 5 are implemented.