Service starting method, mirror image generation method and related device

By obtaining the image file generated by the second container and determining the dependency file, the problem of low service startup efficiency in the container is solved, and the effect of improving the success rate and speed of startup is achieved.

CN119690578APending Publication Date: 2025-03-25MASHANG CONSUMER FINANCE CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411410578.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-10
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

In the prior art, the startup efficiency of the service in the container is low, which affects the execution efficiency of the service.

Method used

By obtaining the image file generated by the second container, the dependency file of the image file is determined and the service is started based on the image file and the dependency file.

Benefits of technology

It improves the service startup success rate, reduces the amount of data in the image file, increases the speed of obtaining the image file and starting the service, and saves the service startup time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119690578A_ABST
    Figure CN119690578A_ABST
Patent Text Reader

Abstract

The invention provides a service starting method, a mirror image generation method and a related device. The service starting method is applied to a first container and comprises the steps that a mirror image file is obtained, the mirror image file is generated by a second container, the first container and the second container belong to the same container cluster system, a dependent file of the mirror image file is determined, and a service corresponding to the mirror image file is started based on the mirror image file and the dependent file. According to the invention, the starting efficiency of the service can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Internet technology, and in particular to a service startup method, an image generation method, and related devices. Background Art

[0002] Container technology is a virtual technology that can improve resource utilization. In container technology, a container usually uses an image file to start the service in the corresponding container. The service can be a service provided by the application. For example, for applications in the financial field, the service can be a user authentication service. Users can use the user authentication service to log in to an account, register an account, reset passwords for an account, etc., thereby improving the security of user accounts. The startup efficiency of the service directly affects the execution efficiency of the service. Therefore, how to improve the startup efficiency of services in containers has become one of the hot issues in research. Summary of the invention

[0003] The embodiments of the present application provide a service startup method, an image generation method and related devices, which can improve the startup efficiency of the service.

[0004] The technical solution of the embodiment of the present application is implemented as follows:

[0005] An embodiment of the present application provides a service startup method, which is applied to a first container and includes:

[0006] Obtain an image file, where the image file is generated by a second container, and the first container and the second container belong to the same container cluster system;

[0007] Determine the dependent files of the image file;

[0008] Based on the image file and the dependent files, a service corresponding to the image file is started.

[0009] The embodiment of the present application further provides a method for generating an image, which is applied to a second container and includes:

[0010] In response to a request for generating an image file for a service, obtaining a base image and a service code of the service;

[0011] Based on the base image and the service code of the service, an image file is generated, so that after the first container determines the dependent files of the image file, the first container starts the service based on the image file and the dependent files, and the first container and the second container belong to the same container cluster system.

[0012] The embodiment of the present application further provides a service startup device, which is applied to a first container and includes:

[0013] An acquisition module, used to acquire an image file, where the image file is generated by a second container, and the first container and the second container belong to the same container cluster system;

[0014] A determination module, used to determine dependent files of the image file;

[0015] A startup module is used to start the service corresponding to the image file based on the image file and the dependent file.

[0016] The embodiment of the present application further provides an image generation device, which is applied to a second container and includes:

[0017] An acquisition module, configured to acquire a base image and a service code of the service in response to a request for generating an image file for the service;

[0018] A generation module is used to generate an image file based on the base image and the service code of the service, so that the first container starts the service based on the image file and the dependent file after determining the dependent file of the image file, and the first container and the second container belong to the same container cluster system.

[0019] An embodiment of the present application provides an electronic device, the electronic device comprising:

[0020] A memory for storing computer executable instructions or computer programs;

[0021] The processor is used to implement the service startup method provided in the embodiment of the present application, or implement the image generation method provided in the embodiment of the present application when executing the computer executable instructions or computer programs stored in the memory.

[0022] An embodiment of the present application provides a computer-readable storage medium storing a computer program or a computer-executable instruction, which is used to implement the service startup method provided in the embodiment of the present application, or implement the image generation method provided in the embodiment of the present application when executed by a processor.

[0023] An embodiment of the present application provides a computer program product, including a computer program or a computer executable instruction. When the computer program or the computer executable instruction is executed by a processor, the service startup method provided in the embodiment of the present application is implemented, or the image generation method provided in the embodiment of the present application is implemented.

[0024] The embodiments of the present application have the following beneficial effects:

[0025] In the service startup method provided in the embodiment of the present application, the first container obtains the image file generated by the second container, determines the dependent files of the image file, and based on the image file and the dependent files, the service corresponding to the image file can be started. It can be seen that in the service startup method provided in the embodiment of the present application, the dependent files of the image file can be determined in the process of starting the service, so as to ensure that the service corresponding to the image file is started, and the success rate of starting the service is improved. In addition, since the dependent files are determined in the process of starting the service, it is equivalent to not including the dependent files in the image file, so the data volume of the image file is small, and accordingly, the speed of obtaining the image file can be improved, and the speed of starting the service corresponding to the image file can also be improved, which is equivalent to saving the time of service startup and improving the startup efficiency of the service. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 It is a structural diagram of a service startup and image generation system provided in an embodiment of the present application;

[0027] Figure 2A This is a schematic diagram of the structure of the electronic device provided in the embodiment of the present application. Figure 1 ;

[0028] Figure 2B This is a second structural diagram of an electronic device provided in an embodiment of the present application;

[0029] Figure 3 This is a flow chart of the service startup method provided in the embodiment of the present application. Figure 1 ;

[0030] Figure 4 This is a second flow chart of the service startup method provided in an embodiment of the present application;

[0031] Figure 5 It is a flowchart of the process of starting related technical services and image generation;

[0032] Figure 6 This is a flow chart of the service startup method and image generation method provided in the embodiment of the present application. Figure 1 ;

[0033] Figure 7 This is a second flow chart of the service startup method and the image generation method provided in the embodiment of the present application;

[0034] Figure 8 This is a flow chart of the service startup method and image generation method provided in the embodiment of the present application. Figure 3 . DETAILED DESCRIPTION

[0035] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.

[0036] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0037] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0038] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0039] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meanings as those commonly understood by those skilled in the art. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.

[0040] The relevant data collection and processing in the embodiments of this application should be strictly in accordance with the requirements of relevant laws and regulations when applied in examples, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of authorization of laws and regulations and the personal information subject.

[0041] Embodiments of the present application provide a service startup method, an image generation method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product, which can improve the startup efficiency of the service.

[0042] See also Figure 1 , Figure 1It is a structural diagram of the service startup and image generation system provided in an embodiment of the present application. The service startup and image generation system 100 is to support a service startup application. The terminal 400-1 is connected to the server 200 through the network 300. The network 300 can be a wide area network or a local area network, or a combination of the two.

[0043] In some embodiments, when a user wants to start a service, a service start instruction can be triggered on the graphical interface 410-1 displayed on the terminal 400-1. In response to the service start instruction triggered on the graphical interface 410-1 displayed on the terminal 400-1, the terminal 400-1 can send the service start instruction to the server 200.

[0044] The server 200 is deployed with a container cluster system, which includes a first container group and a second container group, wherein the first container group includes one or more first containers, the second container group includes one or more second containers, and one or more second containers in a second container group can generate an image file, and the image file does not include dependent files. After receiving the service start instruction, the server 200 can obtain the image file and the dependent files of the image file through the first container, and start the service corresponding to the image file based on the image file and the dependent files.

[0045] In some embodiments, when a user wants to generate an image, an image generation instruction can be triggered on the graphical interface 410-1 displayed on the terminal 400-1. In response to the image generation instruction triggered on the graphical interface 410-1 displayed on the terminal 400-1, the terminal 400-1 can send a generation request for generating an image file for the service to the server 200.

[0046] After the server 200 receives the request to generate the image file for the service, the second container responds to the request to generate the image file for the service, obtains the base image and the service code of the service, and then generates an image file that does not include dependent files based on the base image and the service code of the service. The dependent files are used by the first container to determine the dependent files of the image file and then start the corresponding service based on the image file and the dependent files.

[0047] The electronic device provided in the embodiments of the present application is described below. The electronic device provided in the embodiments of the present application may be a terminal, a server, or a combination of the two. In some embodiments, the terminal may be implemented as various types of terminals such as a laptop computer, a tablet computer, a desktop computer, a set-top box, a smart phone, a smart speaker, a smart watch, a smart TV, and a car terminal.

[0048] In some embodiments, the server may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms. The terminal and the server may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present application.

[0049] See also Figure 2A and Figure 2B , Figure 2A This is a schematic diagram of the structure of the electronic device provided in the embodiment of the present application. Figure 1 , Figure 2B is a second structural diagram of an electronic device provided in an embodiment of the present application, Figure 2A and Figure 2B The electronic device shown includes at least one processor 410 , a memory 450 , at least one network interface 420 , and a user interface 430 . Figure 2A and Figure 2B The components in the electronic device shown are coupled together via a bus system 440. It is understood that the bus system 440 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 440 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, the bus system 440 is not used in the following examples. Figure 2A and Figure 2B Various buses are labeled as bus system 440 .

[0050] The processor 410 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.

[0051] The user interface 430 includes one or more output devices 431 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 430 also includes one or more input devices 432, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.

[0052] The memory 450 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drives, optical disk drives, etc. The memory 450 may optionally include one or more storage devices that are physically remote from the processor 410.

[0053] The memory 450 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 450 described in the embodiments of the present application is intended to include any suitable type of memory.

[0054] In some embodiments, memory 450 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.

[0055] Operating system 451, including system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;

[0056] A network communication module 452, used to reach other electronic devices via one or more (wired or wireless) network interfaces 420, exemplary network interfaces 420 include: Bluetooth, Wireless Compatibility Certification (WiFi), and Universal Serial Bus (USB), etc.;

[0057] a presentation module 453 for enabling presentation of information via one or more output devices 431 (e.g., display screen, speaker, etc.) associated with the user interface 430 (e.g., a user interface for operating peripherals and displaying content and information);

[0058] The input processing module 454 is used to detect one or more user inputs or interactions from one of the one or more input devices 432 and translate the detected inputs or interactions.

[0059] In some embodiments, the service startup device provided in the embodiments of the present application can be implemented in software. Figure 2A The service startup device 455 stored in the memory 450 is shown, which can be software in the form of a program and a plug-in, etc., including the following software modules: an acquisition module 4551, a determination module 4552 and a startup module 4553. These modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be described below.

[0060] In some embodiments, the image generation device provided in the embodiments of the present application can be implemented in software. Figure 2B The image generation device 456 stored in the memory 450 is shown, which can be software in the form of a program and a plug-in, etc., including the following software modules: an acquisition module 4561 and a generation module 4562. These modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be described below.

[0061] In other embodiments, the device provided in the embodiments of the present application can be implemented in hardware. As an example, the device provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the service startup method provided in the embodiments of the present application, or it is programmed to execute the image generation method provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application-specific integrated circuits (Application Specific Integrated Circuit, ASIC), digital signal processors (Digital Signal Processor, DSP), programmable logic devices (Programmable Logic Device, PLD), complex programmable logic devices (Complex Programmable Logic Device, CPLD), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other electronic components.

[0062] See also Figure 3 , Figure 3 This is a flow chart of the service startup method provided in the embodiment of the present application. Figure 1 As mentioned above, the electronic device that implements the service startup method of the embodiment of the present application can be a terminal, a server, or a combination of the two.

[0063] Combine the following Figure 3 Taking the electronic device as a server as an example, the service startup method provided in the embodiment of the present application is described, wherein a first container group is provided in the server, and the first container group includes one or more first containers. The service startup method provided in the embodiment of the present application is applied to the first container group provided in the server, that is, the service startup method provided in the embodiment of the present application is applied to the first container.

[0064] In step 101, an image file is obtained.

[0065] To facilitate understanding of the service startup method and image generation method provided in the embodiments of the present application, the container cluster system is first introduced below. The container cluster system provided in the embodiments of the present application may be a Kubernetes system. The container cluster system may include one Kubernetes cluster or multiple Kubernetes clusters, which may be specifically set according to actual usage requirements.

[0066] For a Kubernetes cluster, there are multiple worker nodes. For a worker node, there are one or more container groups (pods). The number of container groups corresponding to a worker node can be set according to actual usage requirements. For example, the number of container groups corresponding to a worker node can be 5, 10, 13, etc., which is not specifically limited here.

[0067] Among them, a working node can correspond to a server, or a server can include multiple working nodes, or a working node can correspond to multiple servers, which can be set according to actual usage. In this application, the container group is a pod, and an integrated tool can be set in the pod, so that image generation and service startup can be achieved through the pod.

[0068] For a Kubernetes cluster, it can also include a master node, which is the management node responsible for managing the Kubernetes cluster. A master node can correspond to a server. The master node includes an interface service (API server), a scheduler, and a state storage module. Among them, the interface service is used to provide an access interface for the terminal, and the scheduler is used to schedule the container group, thereby scheduling the container group to the working node.

[0069] The state storage module stores the cluster state information of the Kubernetes cluster, which may include the state information of each working node, the state information of the container group, the storage state information, etc. The state information of the working node includes whether the working node can receive the container group and the resource usage status of the working node, which may specifically include the memory usage status, disk usage status, CPU usage status, etc.

[0070] The state information of the container group is information used to indicate whether the container group is currently in a running state, a suspended state, or other states. The state information of the container group also includes the address information of the container group, etc. The storage state information includes the storage capacity of the storage area, the access mode of the storage area, the storage class, and the binding state, etc.

[0071] The access mode defines how the container group interacts with the storage area. Specifically, the number of worker nodes that can read and / or write can be set according to usage requirements. The storage class can define the storage type, which can be cloud storage or local storage. The storage class can also define the capacity, level, encryption, etc.

[0072] The binding state is the relationship state between the storage area (PersistentVolume, PV) and the storage claim (PersistentVolumeClaim, PVC). The relationship state can be that the storage area and the storage claim are not bound, the storage area and the storage claim are bound, the binding relationship between the storage area and the storage claim has been deleted, and the binding relationship between the storage area and the storage claim has failed.

[0073] The storage area is persistent and its life cycle is independent of the container group. The storage declaration is created and maintained by the user. The storage declaration can include the amount of data and access mode of the storage area used. The container group can match the storage area based on the storage declaration.

[0074] A container group includes one or more containers. Multiple containers in a container group can share network and storage resources. The Kubernetes cluster can manage the life cycle of the containers in each container group, which may include creating containers, scheduling containers, and running containers. In some embodiments, the containers in a container group can be run using Docker.

[0075] Docker container technology has the following advantages: Since multiple containers can share network and storage resources, there is no need to restart the operating system for each container, which can improve the startup speed and resource utilization. Docker containers (i.e. containers in a container group) have environmental consistency.

[0076] In addition, Docker container technology also supports continuous integration / continuous delivery (continuous deployment). The continuous integration process includes image generation, and the continuous delivery (continuous deployment) process includes service startup, that is, it can support the service startup method and image generation method provided in the embodiments of the present application.

[0077] In the present application, the number of services may be multiple, for example, the service may include a first service, a second service, a third service, etc., and the number of services may be set according to actual usage requirements. The service has a corresponding image file and a dependent file, for example, the first server corresponds to the first image file, and the first service corresponds to the first image file. In order to clarify the above relationship, the service startup method provided in the embodiment of the present application is described below by taking the service as the first service, the image file as the first image file, and the dependent file as the first dependent file as an example.

[0078] In some embodiments, step 101 can be implemented in the following manner: when a user needs to start the first service, in response to a service start instruction triggered by a display page of the terminal, the Kubernetes cluster can receive a service start request through an interface service, wherein the service start request includes the first container group information.

[0079] After the Kubernetes cluster receives the service startup request through the interface service, the first container group information can be bound to the first working node among the multiple working nodes through the scheduler based on the first container group information, and then the first working node can create a first container group based on the first container group information, which is equivalent to implementing scheduling for the first container group. The first container group includes one or more first containers, which is equivalent to implementing scheduling for the first container.

[0080] The first container group information may include first affinity configuration information, first resource requirement information, first node identification information, etc., wherein the first affinity configuration information is used to set the requirements for the first working node to be bound to the first container group (that is, the requirements for the first working node that can be scheduled by the first container group).

[0081] The first resource requirement information is resource information required by the first container group to start the first service, and the first node identification information is used to identify a working node that the first container group cannot be bound to (that is, a working node that the first container group cannot schedule).

[0082] For example, the first affinity configuration information may be combined with the first resource requirement information and / or the first node identification information to set the schedulable working node of the first container group. Specifically, the first affinity configuration information may be to set the schedulable working node of the first container group to be a working node with 2 cores of the central processing unit. The first affinity configuration information may be to set the first container group to be unschedulable to working node 1. The configuration may be performed according to actual usage requirements.

[0083] In some embodiments, the first affinity configuration information and the status information of the working node can be compared, and the working node whose status information satisfies the first affinity configuration information is used as the first working node, and then the first working node can create the first container group based on the first container group information.

[0084] In some embodiments, the controller may pre-create a container group, and the controller may define an operation strategy for the pre-created container group, wherein the operation strategy is a rolling update of the container group, and the purpose of the rolling update is to replace the historical container group with the newly created container group, thereby realizing the update of the container group.

[0085] After the Kubernetes cluster receives the service startup request through the interface service, the service information of the first service carried in the service startup request can be used to determine the first working node corresponding to the service information from the pre-set correspondence between the candidate service information and the candidate working nodes based on the service information of the first service, and then the service startup request is forwarded through the interface service to any container group (i.e., the first container group) in the first working node, that is, the first container in the first container group in the first working node to which the service startup request is forwarded through the interface service.

[0086] In some embodiments, the service information of the first service includes a service identifier, which may be one or more of a service name, a character string identifying the uniqueness of the service, and service version information, and may be specifically set according to actual usage requirements.

[0087] Accordingly, the correspondence between the preset candidate service information and the candidate working nodes is the correspondence between the preset candidate service identifiers and the candidate working nodes. Based on the service identifier, the first working node can be determined from the correspondence between the preset candidate service identifiers and the candidate working nodes.

[0088] In some embodiments, the service information of the first service may include container group identification information, and the correspondence between the pre-set candidate service information and the candidate working nodes is the correspondence between the pre-set candidate container group identification information and the candidate working nodes. Based on the container group identification information, the first working node can be determined from the correspondence between the pre-set candidate container group identification information and the candidate working nodes.

[0089] In some embodiments, the service information of the first service includes a service identifier and environment information, and the environment information is used to indicate the operating environment of the first service. The environment information may be information indicating that the operating environment is a test environment, information indicating that the operating environment is a production environment, information indicating that the operating environment is a demonstration environment, etc. The specific setting may be based on actual usage requirements.

[0090] Correspondingly, the correspondence between the pre-set candidate service information and the candidate working nodes includes the correspondence between the pre-set candidate service identifier and the candidate working node, as well as the correspondence between the pre-set candidate environment information and the candidate working node. The second working node can be determined based on the service identifier from the correspondence between the pre-set candidate service identifier and the candidate working node. The third working node can be determined based on the environment information from the correspondence between the pre-set candidate environment information and the candidate working node, thereby taking any consistent working node between the second working node and the third working node as the first working node.

[0091] By determining the first working node through the above service identifier, container group identifier information and environment information, it is possible to ensure that the first service is processed by the same one or more working nodes, thereby improving the accuracy of container group scheduling and improving resource utilization of the working nodes.

[0092] The following describes the method of setting the correspondence between the candidate service identifier and the candidate work node. In some embodiments, one service may correspond to one work node, for example, service a corresponds to work node a. In some embodiments, one service may correspond to multiple work nodes, for example, application a corresponds to work nodes a-work node c. In the case where one service corresponds to multiple work nodes, the multiple work nodes may be located in the same area, and the multiple work nodes may have the same operating system.

[0093] The first container group can obtain the first image file from the image storage area of ​​the first service, which is equivalent to the first container group pulling the first image file from the image warehouse of the first service. That is, the first container can obtain the first image file from the image storage area of ​​the first service, so that the first container can obtain the image file.

[0094] The first service may be a service provided to the user, specifically an application for the user to use, for example, application a in the financial field is a service. The first service may also be a function of an application for the user to use, for example, the first service may be function 1 in application b, and for the financial field, function 1 in application b may be a financial product browsing function, which may be set according to actual usage requirements.

[0095] The location information of the image storage area of ​​the first service can be obtained based on the service startup request. In some embodiments, the service startup request can carry the service identification information of the first service. After the service startup request is obtained, the location information corresponding to the service identification information can be determined from the correspondence between the pre-stored candidate service identification information and the candidate location information based on the service identification information, that is, the location information of the image storage area of ​​the first service can be obtained.

[0096] In some embodiments, the service startup request may carry location information of the image storage area of ​​the first service. After the service startup request is obtained, the location information of the image storage area of ​​the first service may be used as a kind of first container group information, that is, the first container group information may also include the location information of the image storage area of ​​the first service.

[0097] In some embodiments, a plurality of image files are stored in the image storage area, and a service identifier is present in each of the plurality of image files. The first container group (or the first container in the first container group) can pull a first image file consistent with the service identifier of the first service from the plurality of image files in the image storage area based on the service identifier of the first service.

[0098] In some embodiments, a plurality of image files with the same service name are stored in the image storage area. The first container group (or the first container in the first container group) can determine, based on the service identifier of the first service, a candidate image file that is consistent with the service identifier of the first service from the plurality of image files in the image storage area. If the number of candidate image files is 1, the candidate image file can be used as the first image file.

[0099] If there are multiple candidate image files and their storage times are different, a candidate image file whose storage time is before the time of the service startup request and whose difference between the storage time and the time of the service startup request is the smallest can be selected from the multiple candidate image files, and the candidate image file can be used as the first image file, wherein the time of the service startup request can be the time when the service startup request is generated, or the time when the Kubernetes cluster receives the service startup request.

[0100] The service information of the first service may further include service version information. If the versions of the multiple candidate image files are different, the first container group may select a first candidate image file that is consistent with the service version information of the first service as the first image file.

[0101] The service information of the first service may further include environmental information that can characterize the operating environment. The operating environments of multiple first candidate image files are different. The first container group (or the first container in the first container group) may select a candidate image file whose operating environment is consistent with the environmental information of the first service as the first image file.

[0102] The first image file is generated by the second container group (or the second container in the second container group), and the first image file does not include dependent files. The first image file may include a base image and a service code of the first service. The base image is a read-only template, and the base image includes an operating system, wherein the operating system may be Linux, Windows, etc. The first container group and the second container group belong to the same container cluster system. The second container group is used to generate the first image file of the first service.

[0103] The following describes a method for generating a first image file by the second container group, that is, a method for generating an image file by the second container. The embodiment of the present application further provides an image generation method, which is applied to the second container.

[0104] In response to a request for generating an image file for a service, a base image and a service code of the service are obtained, and an image file is generated based on the base image and the service code of the service, so that the first container starts the service based on the image file and the dependent files after determining the dependent files of the image file.

[0105] When a user needs to create an image file (first image file) for a first service, in response to an image generation instruction triggered by a display page of a terminal, the Kubernetes cluster can receive a generation request for the image file for the first service through an interface service, wherein the generation request for the image file for the first service includes second container group information of a second container group to which the second container belongs.

[0106] In some embodiments, after the Kubernetes cluster receives a request to generate an image file for the first service through the interface service, the second container group information can be bound to a fourth working node among multiple working nodes through a scheduler based on the second container group information, and then the fourth working node can create a second container group based on the second container group information, which is equivalent to implementing scheduling for the second container group. The second container group includes one or more second containers, which is equivalent to implementing scheduling for the second container.

[0107] After creating the second container group, that is, after creating the second container, a request for generating an image file for the first service can be sent to the second container group, that is, a request for generating an image file for the first service is sent to the second container in the second container group. For the description of the second container group information, refer to the description of the first container group information, and the description of the first container group information is equivalently replaced, which is not repeated here.

[0108] In some embodiments, the controller can pre-create a container group, and the service startup request carries service information of the first service. After the Kubernetes cluster receives a request to generate an image file for the first service through an interface service, the service information of the first service carried in the service startup request can be determined.

[0109] Then, based on the service information of the first service, the fourth working node corresponding to the service information can be determined from the correspondence between the pre-set candidate service information and the candidate working nodes, and then the image file generation request for the first service is forwarded to any container group (i.e., the second container group) in the fourth working node through the interface service, that is, the service startup request is forwarded to the second container in the second container group in the fourth working node through the interface service. Among them, the fourth working node can be consistent with the first working node, or it can be inconsistent with the first working node. For details, please refer to the instructions for determining the first working node, which will not be repeated here.

[0110] The second container group (or the second container in the second container group) can obtain the basic image and the service code of the first service in response to the request to generate the image file for the first service. In some embodiments, the request to generate the image file for the first service can include the service identifier of the first service, and then based on the service identifier of the first service, the basic image corresponding to the service identifier of the first service can be determined from the correspondence between the pre-stored candidate service identifiers and the candidate basic images. The basic image is stored in the basic image storage area. The second container group can pull the basic image corresponding to the service identifier of the first service from the basic image storage area, which is equivalent to obtaining the basic image.

[0111] In some embodiments, the request to generate the image file for the first service includes the service code of the first service. The second container group (or the second container in the second container group) responds to the request to generate the image file for the first service and can extract the service code of the first service from the request to generate the image file for the first service, thereby obtaining the service code of the first service.

[0112] In some embodiments, a user can upload the service code of the first service to a code library, and based on the service identifier of the first service, determine the service code of the first service from a pre-stored correspondence between candidate service identifiers and candidate service codes. The second container group (or the second container in the second container group) can pull the service code of the first service from the code library, which is equivalent to obtaining the service code of the first service.

[0113] After obtaining the base image and the service code of the first service, a first image file excluding dependent files can be generated based on the base image and the service code of the first service, which is equivalent to generating an image file based on the base image and the service code of the service.

[0114] The first image file not including the dependent file is used for the first container group to start the first service based on the first image file and the first dependent file after determining the first dependent file of the first image file. That is, after the second container group (or the second container in the second container group) generates the first image file, the first image file can enable the first container (that is, the first container group) to start the first service based on the first image file and the first dependent file after determining the dependent file of the first image file (that is, the first dependent file).

[0115] After generating the first image file that does not include dependent files, the first image file and the service identifier may be stored in the image storage area in correspondence. To facilitate the first container group to pull the accurate first image file when starting the first service, the storage time of the first image file may be recorded in the image storage area.

[0116] In some embodiments, the request for generating the image file for the first service includes service version information of the first service, and the first image file and service identifier, as well as the first image file and service version information, may be stored in the image storage area accordingly.

[0117] In some embodiments, there is a pre-stored correspondence between historical image files and historical service identifiers, as well as a correspondence between historical image files and historical service version information in the image storage area. After the first image file and the service identifier are stored in the image storage area in correspondence, a historical image file with a historical service identifier consistent with the service identifier can be obtained.

[0118] Then, the historical service version information of the historical image file is obtained, and the service version information of the first image file is generated by combining the historical service version information and the update information, and the first image file and the service version information are stored correspondingly. The update information may include a target parameter, and the target parameter may be added on the basis of the historical service version information, so as to obtain the service version information.

[0119] In step 102, dependent files of the image file are determined.

[0120] In some embodiments, there are multiple implementations of step 102. The following describes multiple implementations of step 102. In the first implementation, the operating environment of the first container is determined. Based on the operating environment and the identifier of the image file, dependent files of the image file are determined from the storage area corresponding to the first container.

[0121] In the following description, the image file is still the first image file, the dependent file is the first dependent file, and the operating environment of the first container is the operating environment of the first container group, that is, the operating environment of the first container group can be determined. Based on the operating environment and the identifier of the first image file, the first dependent file of the first image file is determined from the storage area corresponding to the first container.

[0122] In some embodiments, the service information of the first service may include environment information, where the environment information is used to indicate an operating environment of the first service. The first container group may determine an operating environment of the first container group to which the first container belongs based on the environment information, that is, determine the environment information of the first container group to which the first container belongs to start the first service.

[0123] In some embodiments, the service start request carries an environment identifier, and based on the environment identifier, the operating environment corresponding to the environment identifier can be determined from the correspondence between pre-set candidate environment identifiers and candidate operating environments.

[0124] The environment identifier may be a pre-set environment label of different operating environments, for example, the environment label of the test environment may be 1, and the environment label of the production environment may be 2. The environment identifier may also be text information corresponding to different operating environments, which may be set according to actual use requirements.

[0125] In some embodiments, the location information of the storage area mounted on the first container group can be determined, which is equivalent to determining the storage area corresponding to the first container. The storage area is used to store dependent files of the image file. In some embodiments, the location information of the storage area mounted on the first container group is determined by the binding state, that is, the storage area corresponding to the first container can be determined by the binding state, which is described in detail below.

[0126] The binding state is the relationship state between the storage area and the storage declaration. The correspondence between the candidate image files and the candidate storage declarations is pre-stored. After the first image file is obtained, the storage declaration of the first image file can be determined based on the first image file from the pre-stored correspondence between the candidate image files and the candidate storage declarations.

[0127] According to the storage declaration of the first image file, from the storage declarations that are bound between the relationship state representation storage area and the storage declaration, it is searched whether there is a storage declaration that is consistent with the storage declaration of the first image file. If there is a storage declaration that is consistent with the storage declaration of the first image file, the location information of the storage area corresponding to the storage declaration can be determined, and the location information can be mounted on the first container group, so that the location information of the storage area mounted on the first container group can be determined.

[0128] In the absence of a storage declaration consistent with the storage declaration of the first image file, it indicates that there may be no pre-stored dependent file, and therefore, a service startup failure message may be sent to the terminal. In some embodiments, the service startup failure message may include the absence of a storage declaration, so that the user can check the binding status without checking whether other information is wrong, thereby improving the efficiency of troubleshooting the service startup failure message.

[0129] After determining the location information of the storage area mounted on the first container group, that is, after determining the storage area corresponding to the first container, the first dependent file of the first image file can be found in the storage area based on the location information, the operating environment and the identifier of the first image file, wherein the operating environment includes N types, N is a positive integer greater than or equal to 2, for example, the operating environment may include 3, specifically a test environment, a production environment and a demonstration environment.

[0130] In some embodiments, different sub-storage areas may be set for different operating environments, and the correspondence between candidate operating environments and candidate sub-storage areas may be pre-stored. After the operating environment is acquired, the sub-storage area corresponding to the operating environment of the first service may be searched from the storage area based on the location information.

[0131] The sub-storage area includes the correspondence between the identifier of the candidate image file and the candidate dependent file, so the first dependent file corresponding to the identifier of the first image file can be found in the sub-storage area. The identifier of the first image file can be the name of the first image file, a string that identifies the uniqueness of the first image file, etc.

[0132] For example, operating environment 1 can be a test environment, and the storage area includes the correspondence between the test environment (candidate operating environment) and sub-storage area 1 (candidate sub-storage area), and also includes the correspondence between the production environment (candidate operating environment) and sub-storage area 2 (candidate sub-storage area).

[0133] Sub-storage area 1 and sub-storage area 2 both include the correspondence between the identifier of the candidate image file and the candidate dependent file. After obtaining the operating environment 1, it can be determined that sub-storage area 1 is the sub-storage area corresponding to the operating environment of the first service. From the sub-storage area, the first dependent file corresponding to the identifier of the first image file 1 is found. In this way, the first dependent file 1 of the first image file 1 can be accurately determined.

[0134] The second method is to determine the storage location of the dependent file based on the identification information of the application corresponding to the image file, and determine the dependent file of the image file based on the storage location of the dependent file and the identification of the image file.

[0135] The following description still assumes that the image file is the first image file and the dependent file is the first dependent file. That is, the storage location of the first dependent file can be obtained based on the identification information of the application corresponding to the first image file.

[0136] In some embodiments, for different applications, dependent files may be stored in different storage locations, so after the first image file is acquired, identification information of the application corresponding to the first image file may be determined.

[0137] The identification information of the application may be one or more of the following three situations: in the first situation, the identification information of the application may be the name of the application, a pre-set label representing the uniqueness of the application, etc. In the second situation, the identification information of the application may also be the name of the service of the application, a pre-set label representing the uniqueness of the service of the application, etc. In the third situation, the identification information of the application may include the storage location of the dependent files of the application.

[0138] After determining the identification information of the application, the storage location of the first dependent file can be obtained based on the identification information of the application corresponding to the first image file. In some embodiments, for the first case or the second case, the storage location corresponding to the identification information of the application can be determined from the correspondence between the candidate identification information and the candidate storage location based on the identification information of the application. The candidate identification information can be replaced accordingly for different identification information of the application.

[0139] For the third situation above, the storage location of the dependent files of the application program may be extracted from the identification information of the application program, and the extracted storage location of the dependent files of the application program may be determined as the storage location of the first dependent file.

[0140] In some embodiments, for the case where both the first case and the second case mentioned above exist, the identification information of the application in the first case may be application identification information, and the identification information of the application in the second case may be service identification information.

[0141] Based on the application identification information, the storage location corresponding to the application identification information can be determined from the correspondence between the candidate application identification information and the candidate storage location. The storage location corresponding to the application identification information has a correspondence between the candidate service identification information and the candidate storage sub-location, and then based on the service identification information, the candidate storage sub-location corresponding to the service identification information can be determined from the correspondence between the candidate service identification information and the candidate storage sub-location, and the candidate storage sub-location corresponding to the service identification information is used as the storage location of the first dependent file.

[0142] In response to the situation where the third situation mentioned above exists together with the first situation and / or the second situation, the storage location of the dependent files of the application can be first extracted from the identification information of the application corresponding to the first image file. If the storage location of the dependent files of the extracted application does not have a sub-storage location, the storage location of the dependent files of the extracted application will be used as the storage location of the first dependent files.

[0143] If the storage location of the extracted application's dependent file has a sub-storage location, the corresponding storage location can be determined according to the application identification information and / or service identification information, thereby obtaining the storage location of the first dependent file. In this way, the storage location of the first dependent file can be accurately determined in combination with the identification information of the application in one or more situations, and the storage location of the first dependent file is used to determine the first dependent file, thereby improving the accuracy of the determined first dependent file.

[0144] In some embodiments, after obtaining the storage location of the first dependent file, the first dependent file of the first mirror file can be determined from the storage area corresponding to the storage location of the first dependent file based on the identifier of the first mirror file, and the storage location of the first dependent file is the location of the storage area.

[0145] The first container group (or the first container in the first container group) can access the storage resources of the storage area through the storage declaration, and the first container group (or the first container in the first container group) can perform a read operation on the storage resources of the storage area. The storage resources are the dependent files (including the first dependent file), which is equivalent to not needing to transmit the first dependent file during the service startup process, thereby saving network resources for transmitting the first dependent file during the service startup process.

[0146] The third method, in some embodiments, the location information of the storage area can be first determined by the first method mentioned above, and then, based on the storage area, based on the identification information of the application corresponding to the first image file, the storage location of the first dependent file in the storage area can be further determined, so that the first dependent file can be obtained. For details, please refer to the description of the first method and the second method, which will not be repeated here.

[0147] In some embodiments, the sub-storage area can be first determined by the first method mentioned above, and then, based on the sub-storage area, based on the identification information of the application corresponding to the first image file, the storage location of the first dependent file in the sub-storage area can be further determined, so that the first dependent file can be obtained. For details, please refer to the description of the first method and the second method, which will not be repeated here.

[0148] It can be known from step 102 that the first dependency file can be determined by any one of the first to third methods in combination with actual conditions. Since the first dependency file is stored in the storage area, and the first container group (or the first container in the first container group) can read the first dependency file according to the storage declaration, without transmitting the first dependency file to the first container group (correspondingly, the first container in the first container group) through network data, it is possible to save network resources for transmitting the first dependency file during the service startup process on the basis of determining the accurate first dependency file.

[0149] In step 103, based on the image file and the dependent files, the service corresponding to the image file is started.

[0150] The following description still assumes that the service is the first service, the image file is the first image file, and the dependent file is the first dependent file. In some embodiments, step 103 can be implemented in the following manner: after determining the first dependent file of the first image file, the first container group (or the first container in the first container group) can read the first dependent file and install the first dependent file, so that the first service corresponding to the first image file can be started, that is, the service corresponding to the image file can be started.

[0151] In some embodiments, after starting the first service corresponding to the first image file, traffic can be enabled for the first service. Enabling traffic means allowing requests outside the Kubernetes cluster to access the first container group. Users can access the first container group and thus use the first service.

[0152] In the service startup method provided by the embodiment of the present application, the first container obtains the first image file, the first image file is generated by the second container, and the first image file does not include a dependent file. Based on the first image file, the first dependent file of the first image file can be determined, and based on the first image file and the first dependent file, the first service corresponding to the first image file can be started. Since the first image file does not include a dependent file, the data volume of the first image file is small, and accordingly, the speed at which the first container group obtains the first image file can be increased, and the occupancy of the input / output corresponding to the container cluster system can be reduced.

[0153] Furthermore, the embodiment of the present application can obtain the first dependent file based on the first image file, thereby ensuring that the first service corresponding to the first image file is started. Since the speed of obtaining the first image file can be increased, the speed of starting the service corresponding to the first image file can also be increased, which is equivalent to saving the time of service startup and improving the startup efficiency of the service.

[0154] An embodiment of the present application provides a mirror image generation method. As mentioned above, the electronic device that implements the mirror image generation method of the embodiment of the present application may be a terminal, a server, or a combination of the two. The mirror image generation method provided by the embodiment of the present application is described below by taking the electronic device as a server as an example.

[0155] In order to facilitate understanding of the image generation method provided in the embodiment of the present application, the correspondence between the container group, service, image file and dependent file in the embodiment of the present application is first described. In the present application, for a container group, the container group can execute service startup for a service, or the container group can execute image generation for a service.

[0156] In some embodiments, the Kubernetes cluster can enable the container group to execute service startup for a service, or enable the container group to execute image generation for a service by controlling the life cycle of each container in the container group.

[0157] For example, there is a correspondence between the first service and the first image file and the first dependent file, and there is a correspondence between the second service and the second image file and the second dependent file. The first image file that does not include the first dependent file can be generated through the second container group, and the first service can be started according to the first image file and the first dependent file through the first container group.

[0158] For the second service, a second image file excluding the second dependent file may be generated through the third container group, and the second service may be started according to the second image file and the second dependent file through the fourth container group.

[0159] That is to say, in the embodiment of the present application, a container group is only used to execute service startup or image generation of a service. The services corresponding to different container groups may be different. If the services corresponding to different container groups are the same, the tasks executed by the different container groups are different, and the tasks are service startup tasks or image generation tasks.

[0160] The following takes the service as the second service, the image file as the second image file, and the dependent file as the second dependent file as an example to illustrate the image generation method provided in the embodiment of the present application. The image generation method can be applied to the third container, and the third container group (or the third container in the third container group) responds to the generation request for the image file of the second service to obtain the base image and the service code of the second service.

[0161] In some embodiments, the request for generating an image file for the second service may include a service identifier of the second service, and then based on the service identifier of the second service, the basic image corresponding to the service identifier of the second service can be determined from the correspondence between pre-stored candidate service identifiers and candidate basic images. The basic image is stored in a basic image storage area, and the third container group can pull the basic image corresponding to the service identifier of the first service from the basic image storage area, which is equivalent to obtaining the basic image.

[0162] In some embodiments, the request to generate the image file for the second service includes a service code for the second service. The second container group responds to the request to generate the image file for the second service and can extract the service code for the second service from the request to generate the image file for the second service, thereby obtaining the service code for the second service.

[0163] For the method of generating the second image file for the third container group, reference may be made to the description of the method of generating the first image file for the second container group, and the description of the method of generating the first image file for the second container group may be equivalently replaced, which will not be described in detail here.

[0164] After the service code and the base image are obtained, an image file excluding dependent files may be generated based on the base image and the service code of the second service, that is, a second image file excluding dependent files may be generated.

[0165] The second image file that does not include dependent files is used for the fourth container group to start the second service based on the second image file and the second dependent file after determining the second dependent file of the second image file. The third container group and the fourth container group belong to the same container cluster system.

[0166] The fourth container group can obtain the second image file, determine the second dependent file of the second image file based on the second image file, and start the second service corresponding to the second image file based on the second image file and the second dependent file. Figure 3 description, and Figure 3 The corresponding contents are replaced equivalently and will not be elaborated here.

[0167] The embodiment of the present application can generate an image file that does not include dependent files, thereby reducing the data volume of the image file. After the image file is generated, the image file can be stored in the image storage area. Since the data volume of the image file is small, the efficiency of storing the image file can be improved. For the method of storing the image file, refer to the description of storing the first image file, and the description of storing the first image file is equivalently replaced, which will not be repeated here.

[0168] The following describes the processing method of dependent files in the process of generating an image file. In some embodiments, in response to a request for generating an image file for a service, dependency information is extracted from the generation request. The generation request carries dependency information, and the dependency information includes dependency identification information and dependency version information.

[0169] In some embodiments, the request to generate the image file for the service (first service or second service) includes dependency information. Therefore, in response to the request to generate the image file for the service (first service or second service), the dependency information can be extracted from the generation request.

[0170] In some embodiments, the generation request for the image file of a service (the first service or the second service) includes a service code of the service (corresponding to the first service or the second service), and then the service code of the service (corresponding to the first service or the second service) can be extracted from the generation request, and then based on the service code, the dependency information of the service code is determined.

[0171] In some embodiments, the generation request of the image file for a service (the first service or the second service) may include a service identifier of the service (corresponding to the first service or the second service), and the service identifier can be extracted from the generation request, thereby determining the service code based on the service identifier from the correspondence between pre-stored candidate service identifiers and candidate service codes, and then determining the dependency information of the service code based on the service code.

[0172] Among them, the dependency information can be information that characterizes the uniqueness of the dependent file. The dependent file may include the dynamic link library or static library files required for the application to run, the configuration files required for the application to run, such as database connection configuration, service endpoint configuration, etc., and the resource files required for the application to run, such as data files, template files, static resources, etc., which can be set specifically based on actual usage.

[0173] After the dependency information is obtained, it is possible to search the local storage area for the dependency files corresponding to the dependency information. If the dependency files corresponding to the dependency information are found in the local storage area, that is, the dependency files corresponding to the dependency information exist in the local storage area, there is no need to process the dependency files of the image file in the process of generating the image file, which can save network resources for downloading the dependency files, and can also reduce the number of installations of the dependency files in the image file generation stage, which can improve the generation efficiency of the image file. The above-mentioned image file can be the first image file or the second image file, and the above-mentioned dependency file can correspond to the first dependency file or the second dependency file.

[0174] In some embodiments, in order to facilitate the first container group or the fourth container group to determine the dependent files of the image file, after the dependent files corresponding to the dependent information are found, the dependent files can be synchronized to the storage area of ​​the running environment.

[0175] In some embodiments, the environment can be determined according to the operating environment corresponding to the image file. The image generation request can carry environmental information corresponding to the image file, and the operating environment can be determined through the environmental information. For example, the environmental information corresponding to the image file carried in the image generation request indicates that the operating environment of the service is a test environment.

[0176] In some embodiments, there is a preset order between the operating environments. After synchronizing the dependent files to the storage area of ​​the operating environment, if it is detected that the container group (the first container group or the third container group) starts the service in the operating environment, the dependent files can be synchronized to the storage area of ​​the operating environment arranged after the operating environment in the preset order according to the preset order, and the mirror file can be synchronized to the mirror storage area of ​​the operating environment arranged after the operating environment in the order. The preset order can be set according to actual usage requirements.

[0177] For example, see Figure 4 , Figure 4 This is a flow chart 2 of the service startup method provided by the embodiment of the present application. The operating environment may include a development environment, a test environment and a production environment, and the preset order is that the development environment is before the test environment, and the test environment is before the production environment.

[0178] For the fourth container group 1, the operating environment can be a development environment. When the second image file 401 is generated and the second dependency file 402 corresponding to the dependency information is found, the second image file 401 can be stored in the image storage area 403 under the development environment, and the second dependency file 402 can be synchronized to the storage area 404 by file synchronization.

[0179] When it is detected that the fourth container group 1 starts the second service in the development environment, the second dependency file 402 can be synchronized to the storage area 406 of the environment (i.e., the test environment) arranged after the running environment in the sequence through file synchronization in a preset order, and the second image file 401 can be synchronized to the image storage area 405 of the environment (i.e., the test environment) arranged after the running environment in the sequence.

[0180] After the fourth container group 1 starts the second service in the development environment, the fourth container group 1 can be deleted, and the second service can be started in the test environment through the fourth container group 2. When it is detected that the fourth container group 2 starts the second service in the test environment, the second dependency file 402 can be synchronized to the storage area 408 of the environment (i.e., the production environment) arranged after the running environment in the sequence by file synchronization in a preset order, and the second image file 401 can be synchronized to the image storage area 407 of the environment (i.e., the production environment) arranged after the running environment in the sequence.

[0181] The present application can automatically synchronize image files and dependent files to storage areas corresponding to different operating environments according to the pre-set order between the operating environments, and can start the services of the next operating environment only after ensuring that the services can be started in the previous operating environment, thereby ensuring the rationality and security of service startup.

[0182] In some embodiments, for the same image file and the same dependent file, if the operating environments are different, different container groups can be created to perform image generation or service startup in different operating environments. In other words, one container group is used to execute service startup or image generation for one service in one environment.

[0183] If the dependent file corresponding to the dependent information is not found in the local storage area, that is, the dependent file corresponding to the dependent information does not exist in the local storage area, the dependent file (the first dependent file or the second dependent file) can be downloaded and stored in the local storage area.

[0184] In some embodiments, the dependency information includes dependency identification information and dependency version information. The dependency identification information may be the name of the dependency file, a label identifying the uniqueness of the dependency file, etc. The dependency version information is information that can characterize the version of the dependency file.

[0185] Based on the dependency identification information, it is possible to search the local storage area for a dependency file corresponding to the dependency identification information. Specifically, the dependency identification information can be compared with the initial dependency identification information of the dependency file in the local storage area. If there is a dependency file whose initial dependency identification information is consistent with the dependency identification information, it means that the dependency file corresponding to the dependency identification information can be found in the local storage area. If there is no dependency file whose initial dependency identification information is consistent with the dependency identification information, it means that the dependency file corresponding to the dependency identification information has not been found in the local storage area.

[0186] If the dependent file corresponding to the dependent identification information is not found in the local storage area, it means that the dependent file corresponding to the dependent identification information does not exist in the local storage area. Therefore, the dependent file corresponding to the dependent identification information can be downloaded and stored in the local storage area, and then the downloaded dependent file can be synchronized to the storage area of ​​the running environment through file synchronization.

[0187] If a dependent file corresponding to the dependent identifier is found in the local storage area, in order to further improve the accuracy of the dependent file, the initial dependent version information and the dependent version information of the dependent file corresponding to the dependent identifier information may be compared to see whether they are consistent.

[0188] If the initial dependency version information is consistent with the dependency version information, it means that the dependency file corresponding to the dependency identification information exists in the local storage area. Therefore, the dependency file in the local storage area can be synchronized to the storage area of ​​the running environment by file synchronization.

[0189] If the initial dependency version information and the dependency version information are inconsistent, the dependency file corresponding to the dependency version information is downloaded and stored in the local storage area, and then the downloaded dependency file is synchronized to the storage area of ​​the running environment by file synchronization. In this way, the dependency file corresponding to the image file can be determined conveniently and accurately by the first method mentioned above, so that the service can be started, thereby improving the startup efficiency of the service.

[0190] In some embodiments, the dependency information may be requirement1.txt, and the initial dependency information corresponding to the dependency file pre-stored in the local storage area, the initial dependency information may include initial dependency identification information and initial dependency version information, the initial dependency information may be requirement2.txt, and then by comparing the dependency information and the initial dependency information, corresponding steps may be performed for different situations. For details, please refer to the above description, which will not be repeated here.

[0191] In some embodiments, if a dependency file corresponding to a dependency identifier is found in a local storage area, but the initial dependency version information and the dependency version information are inconsistent, the dependency file corresponding to the dependency version information can be downloaded and stored, and the dependency file corresponding to the initial dependency version information can be deleted, and the dependency file corresponding to the initial dependency version information in the storage area corresponding to each operating environment can be synchronously deleted. In this way, storage space in the local storage area and the storage area corresponding to each operating environment can be saved.

[0192] In some embodiments, when storing dependent files, the dependent files can be stored in a storage area corresponding to the identification information of the application, so that during the process of starting the service, the dependent files can be determined by the second method mentioned above, thereby starting the service and improving the startup efficiency of the service.

[0193] In the process of generating an image file for a container group (a second container group or a third container group), the container group can respond to a request for generating an image file for a service and extract dependency information from the generation request; based on the dependency information, if a dependency file corresponding to the dependency information is not found in the local storage area, the dependency file is downloaded and stored in the local storage area. The dependency file in the local storage area is used by the container group to start the service in combination with the dependency file and the image file.

[0194] Combine the following Figure 5-Figure 6 The differences between the related technology and the service startup method and the image generation method provided in the embodiment of the present application are compared and explained. Figure 5 This is a flowchart of related technical service startup and image generation. Figure 6 This is a flow chart of the service startup method and image generation method provided in the embodiment of the present application. Figure 1 .

[0195] See also Figure 5 In the related art, the container group 510 can perform steps 501 to 503. In step 501, the base image and the service code of the service are obtained. In step 502, the dependent files are installed according to the base image and the service code. In step 503, the image file is generated based on the service code, the base image and the dependent files.

[0196] After the image file is generated, the image file can be uploaded to the image repository. Then the container group 520 can execute steps 504-505. In step 504, the image file is obtained. For step 504, the container group 520 can pull the image file from the image repository. In step 505, the service of the image file is started.

[0197] See also Figure 6 In the embodiment of the present application, the second container group 610 can perform steps 601 to 607.

[0198] In step 601, a request for generating an image file for a first service is received.

[0199] In step 602, in response to a request for generating an image file for a first service, a base image and a service code of the first service are obtained.

[0200] In step 603, the service code of the first service is copied to the base image to generate a first image file. After step 603, the first image file can be uploaded to the image storage area.

[0201] In step 604, in response to a request for generating an image file for a first service, dependency information is extracted from the generation request.

[0202] In step 605, based on the dependency information, a first dependency file corresponding to the dependency information is searched in the local storage area.

[0203] With respect to step 605, if the first dependent file corresponding to the dependent information is found in the local storage area, step 606 is executed. If the first dependent file corresponding to the dependent information is not found in the local storage area, step 607 is executed.

[0204] In step 606, processing stops.

[0205] In step 607, the first dependent file is downloaded.

[0206] After downloading the first dependent file, the downloaded first dependent file can be stored in a local storage area, and then the first dependent file can be synchronized to the storage area by file synchronization, wherein the storage area is a shared storage area. In this way, the first dependent file can be cached to the storage area. In some embodiments, the first dependent file can be downloaded to the local storage area by a download command (pip download).

[0207] For example, the download command can be pip download-d / home / {appName} / share / packagesdir-rrequirements.txt, where d / home / {appName} / share / packagesdir-rrequirements.txt is the local storage area.

[0208] exist Figure 6 In the embodiment, after the second container group 610 performs steps 601 to 607, the first container group 620 may perform steps 608 to 609 and step 611.

[0209] In step 608, a first image file is obtained.

[0210] In step 609, based on the first image file, a first dependent file of the first image file is determined from the shared storage area.

[0211] In step 611, the first dependent file is installed, and the first service of the first image file is started.

[0212] contrast Figure 5 and Figure 6 It can be seen that, for the stage of generating the image file, the image generation method provided in the embodiment of the present application does not need to package the dependent files into the image file, so the data volume of the image file can be reduced. After the image file is generated, the image file can be stored in the image storage area. Since the data volume of the image file is small, the efficiency of storing the image file can be improved.

[0213] In the service startup phase, since the image file does not include dependent files, the data volume of the first image file is small, the speed at which the first container group obtains the first image file can be increased, and the input / output occupancy corresponding to the container cluster system can be reduced.

[0214] Furthermore, the embodiment of the present application can obtain the first dependent file based on the first image file, thereby ensuring that the service corresponding to the first image file is started. Since the speed of obtaining the first image file can be improved, the speed of starting the first service corresponding to the first image file can also be improved, which is equivalent to saving the time of service startup and improving the startup efficiency of the service.

[0215] In addition, since the image file does not include dependent files, there is no need to check whether the dependent files in the image file are applicable, which is equivalent to saving the step of checking dependent files, and can further improve the speed of starting the service corresponding to the first image file, that is, it can improve the startup efficiency of the service.

[0216] Combine the following Figure 7 and Figure 8 The service startup method and image generation method provided in the embodiments of the present application are illustrated by examples. Figure 7 2 is a flow chart of the service startup method and the image generation method provided in the embodiment of the present application. Figure 8 This is a flow chart of the service startup method and image generation method provided in the embodiment of the present application. Figure 3 .

[0217] See also Figure 7 The third container group 701 can generate a second image file 703 based on the base image and the service code of the second service, and store the second image file 703 in the image storage area 705, wherein the instructions for generating the second image file 703 can be the above-mentioned instructions for generating the second image file, which will not be repeated here.

[0218] The third container group 701 may also search the local storage area 704 for a dependent file corresponding to the dependent information based on the dependent information. If the dependent file corresponding to the dependent information is not found, the third container group 701 downloads the second dependent file 702 of the dependent information and stores the second dependent file 702 in the local storage area 704 .

[0219] In some embodiments, the initial dependency information (requirement2.txt) of the dependency file stored in the local storage area 704 can be compared with the dependency information (requirement1.txt). If the dependency file corresponding to the dependency information is not found, the second dependency file 702 is downloaded from the dependency information and stored in the local storage area 704.

[0220] The second dependent file 702 stored in the local storage area 704 can then be synchronized to the shared storage area 706 (i.e., the storage area) by means of file synchronization. The fourth container group 707 can pull the second image file 703 from the image storage area 705, and can also determine the second dependent file 702 from the shared storage area 706 based on the second image file 703, and can then start the second service of the second image file 703 based on the second image file 703 and the second dependent file 702.

[0221] The fourth container group 707 may mount the location information of the shared storage area 706 , and the fourth container group 707 may read the second dependency file 702 stored in the shared storage area 706 through a storage command, thereby installing the second dependency file 702 and starting the second service of the second image file 703 .

[0222] See also Figure 8 The working node includes a third container group 801, a fourth container group 804, and a fourth container group 805, wherein the operating environment of the fourth container group 804 is different from the operating environment of the fourth container group 805, and the operating environment of the fourth container group 804 is arranged before the operating environment of the fourth container group 805.

[0223] The third container group 801 can store the second image file 802 in the image storage area 803, the fourth container group 804 can pull the second image file 802 from the image storage area 803, and determine the second dependent file of the second image file 802 from the shared storage area 807 based on the second image file 802, and then the fourth container group 804 can start the second service based on the second image file 802 and the second dependent file.

[0224] After the fourth container group 804 starts the service, the second image file 802 in the image storage area 803 may be synchronized to the image storage area 806 , and the second dependent file of the second image file 802 in the shared storage area 807 may be synchronized to the shared storage area 808 .

[0225] The fourth container group 805 can pull the second image file 802 from the image storage area 806, and based on the second image file 802, determine the second dependent file of the second image file 802 from the shared storage area 808, and then the fourth container group 805 can start the second service based on the second image file 802 and the second dependent file.

[0226] The following further describes an exemplary structure of the service startup device 455 provided in the embodiment of the present application as a software module. The service startup method is applied to the first container. In some embodiments, such as Figure 2A As shown, the software modules stored in the service starter 455 of the memory 450 may include:

[0227] An acquisition module 4551 is used to acquire an image file, where the image file is generated by a second container, and the first container and the second container belong to the same container cluster system;

[0228] A determination module 4552, used to determine dependent files of the image file;

[0229] The startup module 4553 is used to start the service corresponding to the image file based on the image file and the dependent file.

[0230] In some embodiments, the determination module 4552 is further used to determine the operating environment of the first container; based on the operating environment and the identifier of the image file, determine the dependent files of the image file from the storage area corresponding to the first container.

[0231] In some embodiments, the determination module 4552 is further used to determine the storage location of the dependent file based on the identification information of the application corresponding to the image file; and determine the dependent file of the image file based on the storage location of the dependent file and the identification of the image file.

[0232] The following further describes an exemplary structure of the image generation device 456 provided in the embodiment of the present application as a software module. The image generation method is applied to the second container. In some embodiments, such as Figure 2B As shown, the software modules stored in the image generation device 456 of the memory 450 may include:

[0233] The acquisition module 4561 is used to obtain the basic image and the service code of the service in response to the request for generating the image file for the service;

[0234] The generation module 4562 is used to generate an image file based on the base image and the service code of the service, so that the first container starts the service based on the image file and the dependent files after determining the dependent files of the image file, and the first container and the second container belong to the same container cluster system.

[0235] In some embodiments, the generation request carries dependency information, and the dependency information includes dependency identification information and dependency version information; the acquisition module 4561 is also used to download the dependency file corresponding to the dependency identification information if the dependency file corresponding to the dependency identification information is not found in the local storage area; if the dependency file corresponding to the dependency identification information is found in the local storage area, compare the initial dependency version information of the dependency file corresponding to the dependency identification information with the dependency version information; if the initial dependency version information and the dependency version information are inconsistent, download the dependency file corresponding to the dependency version information.

[0236] The embodiment of the present application provides a computer program product, which includes a computer program or a computer executable instruction, and the computer program or the computer executable instruction is stored in a computer-readable storage medium. The processor of the electronic device reads the computer executable instruction from the computer-readable storage medium, and the processor executes the computer executable instruction, so that the electronic device executes the service startup method described above in the embodiment of the present application, or executes the image generation method described above in the embodiment of the present application.

[0237] The present application embodiment provides a computer-readable storage medium, in which computer executable instructions or computer programs are stored. When the computer executable instructions or computer programs are executed by a processor, the processor will be caused to execute the service startup method provided by the present application embodiment, for example, Figure 3 Alternatively, when the computer executable instruction or computer program is executed by the processor, the processor will be caused to execute the image generation method provided in the embodiment of the present application.

[0238] In some embodiments, the computer-readable storage medium may be a memory such as RAM, ROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or may be various devices including one or any combination of the above memories.

[0239] In some embodiments, computer executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.

[0240] As an example, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).

[0241] As an example, computer executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed at multiple sites and interconnected by a communication network.

[0242] To sum up, the image generation method provided in the embodiment of the present application does not need to package dependent files into the image file, so the data volume of the image file can be reduced. After the image file is generated, the image file can be stored in the image storage area. Since the data volume of the image file is small, the efficiency of storing the image file can be improved.

[0243] In the service startup method provided in the embodiment of the present application, the first container obtains the image file generated by the second container, determines the dependent files of the image file, and based on the image file and the dependent files, the service corresponding to the image file can be started. It can be seen that in the service startup method provided in the embodiment of the present application, the dependent files of the image file can be determined in the process of starting the service, so as to ensure that the service corresponding to the image file is started, and the success rate of starting the service is improved. In addition, since the dependent files are determined in the process of starting the service, it is equivalent to not including the dependent files in the image file, so the data volume of the image file is small, and accordingly, the speed of obtaining the image file can be improved, and the speed of starting the service corresponding to the image file can also be improved, which is equivalent to saving the time of service startup and improving the startup efficiency of the service.

[0244] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.

Claims

1. A service startup method, characterized in that: The service startup method is applied to a first container, and the method includes: Obtain an image file, where the image file is generated by a second container, and the first container and the second container belong to the same container cluster system; Determine the dependent files of the image file; Based on the image file and the dependent files, a service corresponding to the image file is started.

2. The method according to claim 1, characterized in that The step of determining the dependent files of the image file includes: Determining an operating environment of the first container; Based on the operating environment and the identifier of the image file, a dependent file of the image file is determined from a storage area of ​​the first container.

3. The method according to claim 1, characterized in that The step of determining the dependent files of the image file includes: Determining the storage location of the dependent file based on the identification information of the application corresponding to the image file; Determine the dependent files of the image file based on the storage location of the dependent files and the identifier of the image file.

4. A mirror image generation method, characterized in that: The image generation method is applied to the second container, and the method includes: In response to a request for generating an image file for a service, obtaining a base image and a service code of the service; Based on the base image and the service code of the service, an image file is generated, so that after the first container determines the dependent files of the image file, the first container starts the service based on the image file and the dependent files, and the first container and the second container belong to the same container cluster system.

5. The method according to claim 4, characterized in that The generation request carries dependency information, and the dependency information includes dependency identification information and dependency version information; the method further includes: If the dependent file corresponding to the dependent identification information is not found in the local storage area, downloading the dependent file corresponding to the dependent identification information; If the dependent file corresponding to the dependent identification information is found in the local storage area, then the initial dependent version information of the dependent file corresponding to the dependent identification information is compared with the dependent version information; When the initial dependency version information and the dependency version information are inconsistent, the dependency file corresponding to the dependency version information is downloaded.

6. A service startup device, characterized in that: The service startup device is applied to the first container, and the device includes: An acquisition module, used to acquire an image file, where the image file is generated by a second container, and the first container and the second container belong to the same container cluster system; A determination module, used to determine dependent files of the image file; A startup module is used to start the service corresponding to the image file based on the image file and the dependent file.

7. A mirror image generation device, characterized in that: The image generation device is applied to the second container, and the device includes: An acquisition module, configured to acquire a base image and a service code of the service in response to a request for generating an image file for the service; A generation module is used to generate an image file based on the base image and the service code of the service, so that the first container starts the service based on the image file and the dependent file after determining the dependent file of the image file, and the first container and the second container belong to the same container cluster system.

8. An electronic device, characterized in that: The electronic device comprises: A memory for storing computer executable instructions or computer programs; The processor is used to implement the service startup method described in any one of claims 1 to 3, or implement the image generation method described in any one of claims 4 to 5 when executing the computer executable instructions or computer programs stored in the memory.

9. A computer-readable storage medium storing computer-executable instructions or a computer program, characterized in that: When the computer executable instructions or computer programs are executed by a processor, the service startup method described in any one of claims 1 to 3 is implemented, or the image generation method described in any one of claims 4 to 5 is implemented.

10. A computer program product comprising computer executable instructions or a computer program, characterized in that: When the computer executable instructions or computer programs are executed by a processor, the service startup method described in any one of claims 1 to 3 is implemented, or the image generation method described in any one of claims 4 to 5 is implemented.

Citation Information

Cited By

  • Mirror image directional construction and domain division management system and method for cloud application

    CN120223708A