Container management method and related equipment based on cloud native platform
By obtaining container configuration information on the cloud native platform, determining the target image and adjusting the original container, the problem of low target container construction efficiency is solved, and a faster container construction process and image resource reuse are achieved.
Patent Information
- Application Number
- CN202311219425.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-20
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2043-09-20
AI Technical Summary
In cloud service applications, the construction efficiency of the target container required by users is low, especially when the amount of data in the transformed image file is large, causing the container construction process to take a long time.
By obtaining the container configuration information, determining the first target image among multiple preset candidate images based on the first data, adjusting the original container based on the second data, and using parallel or serial processing script commands to build the target container, saving Go ahead and import the image file into an empty container.
It significantly improves the construction efficiency of the target container, shortens the time of image scanning during container startup, and improves the reuse rate and construction efficiency of image resources.
Smart Images

Figure CN117251250B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of cloud services, and in particular to a container management method and related equipment based on a cloud native platform. Background Art
[0002] In cloud service applications, the services used by users rely on corresponding container implementations.
[0003] At present, when the container required by the user is generated based on relevant technologies, an empty container is first generated based on the empty image, and then the basic image is modified according to the image configuration input by the user, and finally the modified image file is pulled into the empty container, thereby obtaining the target container required by the user; it is found in the application that the process of pulling the modified image file into the empty container is time-consuming, especially when the data volume of the modified image file is too large, which will lead to extremely low construction efficiency of the target container required by the user. Summary of the invention
[0004] The purpose of the present disclosure is to provide a container management method and related devices based on a cloud native platform, so as to solve the technical problem of low construction efficiency of the target container required by the user.
[0005] In a first aspect, an embodiment of the present disclosure provides a container management method based on a cloud native platform, including:
[0006] Obtaining container configuration information, wherein the container configuration information includes first data and second data, wherein the first data is used to indicate an image on which container building depends, and the second data is used to indicate an adjustment requirement of the container;
[0007] Determine a first target image from a plurality of preset candidate images according to the first data, wherein the first target image is a candidate image that matches the first data from the plurality of candidate images;
[0008] Building an original container according to the first target image;
[0009] The original container is adjusted according to the second data to obtain a target container.
[0010] In one embodiment, the second data includes a plurality of mirror adjustment instructions;
[0011] The adjusting the original container according to the second data to obtain a target container includes:
[0012] Converting the multiple image adjustment instructions into multiple script commands for container adjustment;
[0013] Analyze the multiple script commands to determine an execution tag of each script command, wherein the execution tag is used to indicate whether the corresponding script command meets a condition for parallel processing or a condition for serial processing;
[0014] According to the execution tag of each script command, the multiple script commands are processed in parallel or serially in the original container to obtain the target container.
[0015] In one embodiment, the execution tag includes: a first tag, a second tag, and a third tag;
[0016] The script command corresponding to the first label is an asynchronous command, the script command corresponding to the second label is a synchronous command, and the script command corresponding to the third label is a waiting command;
[0017] Among them, the third tag is used to indicate at least one preceding command corresponding to the waiting command, the preceding command is a script command among the multiple script commands, and the execution trigger condition of the waiting command is: the at least one preceding command corresponding to the waiting command is executed.
[0018] In one embodiment, the third tag carries at least one index, the at least one index corresponds to the at least one preceding command in a one-to-one manner, and the index is the order of the corresponding preceding command in the plurality of script commands.
[0019] In one embodiment, analyzing the multiple script commands to determine the execution tag of each script command includes:
[0020] Obtaining multiple command keywords corresponding to the multiple script commands respectively;
[0021] The execution tag of each script command is determined according to a preset mapping relationship and the plurality of command keywords, wherein the mapping relationship is used to indicate the execution tag associated with the command keyword.
[0022] In one embodiment, according to the execution tag of each script command, the multiple script commands are processed in parallel or serially in the original container to obtain the target container, including:
[0023] Acquire a plurality of incremental snapshot data corresponding to the plurality of script commands, wherein the incremental snapshot data is used to indicate the adjustment of the data of the original container by the corresponding container configuration instruction;
[0024] Adjusting the first target image according to the multiple incremental snapshot data to obtain a second target image corresponding to the target container;
[0025] Add the second target image to the multiple candidate images.
[0026] In one embodiment, after adjusting the original container according to the second data to obtain the target container, the method further includes:
[0027] Obtaining an execution log of each script command among the multiple script commands, wherein the execution log includes a first sub-log when the corresponding script command is executed normally or a second sub-log when the corresponding script command is executed incorrectly;
[0028] An execution log of each of the plurality of script commands is displayed.
[0029] In one embodiment, the plurality of candidate images include at least one of the following:
[0030] The first image is preset;
[0031] The second image used in the historical period.
[0032] In a second aspect, an embodiment of the present disclosure provides a container management device based on a cloud native platform, including:
[0033] An acquisition module, used to acquire container configuration information, wherein the container configuration information includes first data and second data, wherein the first data is used to indicate the image on which the container building depends, and the second data is used to indicate the adjustment requirement of the container;
[0034] a determination module, configured to determine a first target image from a plurality of preset candidate images according to the first data, wherein the first target image is a candidate image that matches the first data from the plurality of candidate images;
[0035] A construction module, configured to construct an original container according to the first target image;
[0036] An adjustment module is used to adjust the original container according to the second data to obtain a target container.
[0037] In a third aspect, an embodiment of the present disclosure further provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the above-mentioned cloud-native platform-based container management method when executed by the processor.
[0038] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned container management method based on a cloud native platform are implemented.
[0039] In the disclosed embodiment, after the configuration information for container construction is obtained, the original container is first directly constructed according to the image indicated by the configuration information, and then the original container is adjusted accordingly based on the adjustment requirements carried in the configuration information to obtain the target container. The above container construction method not only shortens the time spent on scanning the image during container startup, but also eliminates the step of inputting the image file into the empty container, which can significantly improve the construction efficiency of the target container required by the user. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 is a schematic diagram of a container management method based on a cloud native platform provided by an embodiment of the present disclosure;
[0041] Figure 2 is a schematic diagram of another container management method based on a cloud native platform provided by an embodiment of the present disclosure;
[0042] Figure 3 is a schematic diagram of a command execution process provided by an embodiment of the present disclosure;
[0043] Figure 4 is a schematic diagram of a container management device based on a cloud native platform provided in an embodiment of the present disclosure;
[0044] Figure 5 It is a schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0045] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0046] The following is an explanation of the various names involved in the embodiments of the present disclosure.
[0047] Cloud native platform: A cloud computing platform that uses cloud native technologies, where cloud native technologies refer to technologies for building, deploying, and managing modern applications in a cloud computing environment.
[0048] Container: A lightweight, independent, executable software unit in a cloud-native platform.
[0049] Image: A lightweight, executable, independent software package used to package a software runtime environment and software developed based on the runtime environment. It contains everything needed to run a piece of software, including code, runtime, libraries, environment variables, and configuration files. The aforementioned containers can be generated in a cloud-native platform based on the image.
[0050] Docker: An application container engine used to generate and manage containers. Based on Docker, developers can package their applications and dependent packages into a portable image, and then publish it to any physical device through Docker. Through virtualization technology, Docker can generate corresponding containers on physical devices based on the images published by users.
[0051] Dockerfile: A build file used to build a Docker image (i.e. the aforementioned portable image), which is a script consisting of a series of command parameters.
[0052] The present disclosure provides a container management method based on a cloud native platform. Figure 1 As shown, the container management method based on the cloud native platform includes:
[0053] Step 101: Get container configuration information.
[0054] The container configuration information includes first data and second data, wherein the first data is used to indicate the image on which the container building depends, and the second data is used to indicate the adjustment requirements of the container.
[0055] The method disclosed herein is applied in a cloud-native scenario. For example, the method can be applied in a cloud-native platform.
[0056] Exemplarily, the process of obtaining the container configuration information may be:
[0057] The method is set to be applied in a cloud native platform. When a user accesses the cloud native platform, the cloud native platform will allocate a corresponding namespace (namespace) to the user. The namespace is pre-set with basic services for managing containers (for example, image service (imageServer)). The basic services in the namespace receive user input information and complete the startup of the container required by the user based on the user's input information. The input information received in the basic services of the namespace can be understood as the aforementioned container configuration information.
[0058] Exemplarily, when Docker is applied to manage containers, the container configuration information includes a dockerfile, the first data can be understood as the command located on the first line of the dockerfile, and the second data can be understood as other commands in the dockerfile except the first data.
[0059] Step 102: Determine a first target image from a plurality of preset candidate images according to the first data.
[0060] The first target image is a candidate image matching the first data among the multiple candidate images.
[0061] It should be noted that, among the multiple candidate images, containers built based on different candidate images are different.
[0062] In an example, the first data carries a unique number of the first target image, and the first target image can be determined from a plurality of preset candidate images based on the unique number.
[0063] In another example, the first data carries an acquisition link of the first target image (eg, an address of the first target image in an image repository storing multiple candidate images), and the first target image can be determined from multiple preset candidate images based on the acquisition link.
[0064] Step 103: Build an original container according to the first target image.
[0065] It should be noted that, in the application, the container configuration information also includes third data for indicating the container size. After determining the first target image, the corresponding container management service (for example: imageServer) will build the original container according to the first target image and the third data.
[0066] The third data includes sub-data indicating a CPU size occupied by the container and sub-data indicating a memory size occupied by the container.
[0067] Step 104: Adjust the original container according to the second data to obtain a target container.
[0068] Exemplarily, the aforementioned original container may be understood as a virtual machine loaded with only an operating system, and the target container may be understood as a virtual machine loaded with an operating system and various software for supporting user business services.
[0069] The above-mentioned target container is used to provide software support for the business services required by the user to ensure the normal operation of the business services required by the user. For example, after obtaining the target container, the user can run a storage service for realizing a data storage function, a communication service for realizing a message transmission function, or a game service for entertainment in the target container.
[0070] In the present disclosure, after obtaining the configuration information for container construction, the original container is first directly constructed according to the image indicated by the configuration information, and then the original container is adjusted accordingly based on the adjustment requirements carried in the configuration information to obtain the target container. The above container construction method not only shortens the time spent on scanning the image during container startup, but also eliminates the step of inputting the image file into the empty container, which can significantly improve the construction efficiency of the target container required by the user.
[0071] In addition, the container construction method described in the present disclosure does not involve the use of container privileges, that is, it does not involve the use of control permissions for the physical machine corresponding to the namespace. Therefore, it can match the disabling restrictions on container privileges in most cloud-native scenarios, which makes the container construction method described in the present disclosure more versatile.
[0072] In one embodiment, the plurality of candidate images include at least one of the following:
[0073] The first image is preset;
[0074] The second image used in the historical period.
[0075] In this embodiment, by providing multiple ways of obtaining candidate images to enrich the number of candidate images in the database, this can, on the one hand, expand the number of container construction schemes supported by the present disclosure and improve the versatility of the method described in the present disclosure; on the other hand, it can also improve the reuse rate of image resources, so that the construction efficiency of the container required by the user is further improved.
[0076] Among them, the pre-set first image may be: an image configured during initialization of the cloud native platform that applies the method described in the present disclosure, and / or an image imported via an external device during runtime of the cloud native platform that applies the method described in the present disclosure.
[0077] The second image used in the historical period may be: an image created by the user based on his / her own needs after the user accesses the cloud native platform to which the method described in the present disclosure is applied in the historical period.
[0078] It should be noted that, in the present disclosure, the multiple candidate images are stored in the image repository of the cloud native platform, and the image repository is used to manage the multiple candidate images. Users can add, delete or update the multiple candidate images based on actual needs.
[0079] In one embodiment, the second data includes a plurality of mirror adjustment instructions;
[0080] The adjusting the original container according to the second data to obtain a target container includes:
[0081] Converting the multiple image adjustment instructions into multiple script commands for container adjustment;
[0082] Analyze the multiple script commands to determine an execution tag of each script command, wherein the execution tag is used to indicate whether the corresponding script command meets a condition for parallel processing or a condition for serial processing;
[0083] According to the execution tag of each script command, the multiple script commands are processed in parallel or serially in the original container to obtain the target container.
[0084] Compared with the method of serially processing the multiple script commands in the related art, in this embodiment, by analyzing the multiple script commands corresponding to the second data to determine the execution label of each script command, and processing at least part of the script commands in parallel in the original container based on the execution label, the execution time of multiple script commands can be shortened, and the construction efficiency of the target container can be further improved.
[0085] Exemplarily, according to the execution tag of each script command, the process of performing parallel processing or serial processing on the multiple script commands in the original container may be:
[0086] In the case where the execution tag of the target script command indicates that the target script command satisfies the parallel processing condition, when the container is executing the target script command, even if the target script command is not completely executed, the container will continue to execute the next command, wherein the target script command is one of the multiple script commands;
[0087] When the execution tag of the target script command indicates that the target script command meets the parallel processing condition, when the container is executing the target script command and the target script command has not been completed, the container will wait for the target script command to be completed before continuing to execute the next command.
[0088] Exemplarily, when the multiple image adjustment instructions are multiple instructions included in a dockerfile, the multiple script commands may be multiple Shell commands, and the multiple Shell commands constitute a command queue ShellList.
[0089] In one embodiment, the execution tag includes: a first tag, a second tag, and a third tag;
[0090] The script command corresponding to the first label is an asynchronous command, the script command corresponding to the second label is a synchronous command, and the script command corresponding to the third label is a waiting command;
[0091] Among them, the third tag is used to indicate at least one preceding command corresponding to the waiting command, the preceding command is a script command among the multiple script commands, and the execution trigger condition of the waiting command is: the at least one preceding command corresponding to the waiting command is executed.
[0092] In this embodiment, the execution restrictions of different script commands are matched by distinguishing the first label, the second label, and the third label, so as to ensure the smooth execution of multiple script commands while meeting the parallel processing requirements, avoid container failures caused by erroneous execution of script commands, and avoid the situation where the target container is delayed due to interference from the failure.
[0093] The execution logic of the asynchronous command is as follows: when the container is executing an asynchronous command, even if the asynchronous command is not completed, the container will continue to execute the next command.
[0094] Among the multiple script commands, the script command whose execution result does not affect the execution of other script commands can be determined as the asynchronous command, for example: a script command for deleting files or directories in a container, and the files or directories deleted by the script command no longer appear in subsequent script commands.
[0095] The execution logic of the synchronous command is: when the container is executing a synchronous command and the synchronous command has not been completed, the container will wait for the synchronous command to be completed before continuing to execute the next command.
[0096] Among the multiple script commands, the script command whose execution result is used for the execution of the next script command can be determined as the synchronization command. For example, for two adjacent script commands, if the previous script command A is used to download the target file and the next script command B is used to decompress the target file, since the execution of script command B depends on the execution of script command A, script command A will be marked as a synchronization command.
[0097] The execution logic of the waiting command is: when the at least one preceding command corresponding to the waiting command is executed, the container is run to execute the waiting command.
[0098] Among the multiple script commands, script commands that depend on the execution results of other script commands can be determined as the waiting command. For example, the execution of a script command for decompressing a target file depends on the execution result of a script command for downloading or copying the target file. At this time, the script command for decompressing the target file will be marked as the waiting command, and the script command for downloading or copying the target file is the predecessor command corresponding to the waiting command.
[0099] In one embodiment, the third tag carries at least one index, the at least one index corresponds to the at least one preceding command in a one-to-one manner, and the index is the order of the corresponding preceding command in the plurality of script commands.
[0100] In this embodiment, by storing at least one index of at least one preceding command that the waiting command depends on in the third tag, monitoring of the execution status of at least one preceding command corresponding to the waiting command is facilitated.
[0101] Exemplarily, when the multiple script commands are multiple Shell commands, and the multiple Shell commands constitute a command queue ShellList, the index is the number of the corresponding preceding command in ShellList.
[0102] In one embodiment, analyzing the multiple script commands to determine the execution tag of each script command includes:
[0103] Obtaining multiple command keywords corresponding to the multiple script commands respectively;
[0104] The execution tag of each script command is determined according to a preset mapping relationship and the plurality of command keywords, wherein the mapping relationship is used to indicate the execution tag associated with the command keyword.
[0105] In this embodiment, the command keyword corresponding to the script command is identified, and the execution label of each script command is quickly determined based on the execution label associated with the command keyword. This can improve the efficiency of distinguishing script commands while ensuring the accuracy of distinguishing script commands, thereby improving the efficiency of building the target container.
[0106] Exemplarily, the multiple command keywords may include: a first keyword corresponding to a decompression command, a second keyword corresponding to a copy command, a third keyword corresponding to a download command, a fourth keyword corresponding to a delete command, and a fifth keyword corresponding to an installation command.
[0107] In one embodiment, according to the execution tag of each script command, the multiple script commands are processed in parallel or serially in the original container to obtain the target container, including:
[0108] Acquire a plurality of incremental snapshot data corresponding to the plurality of script commands, wherein the incremental snapshot data is used to indicate the adjustment of the data of the original container by the corresponding container configuration instruction;
[0109] Adjusting the first target image according to the multiple incremental snapshot data to obtain a second target image corresponding to the target container;
[0110] Add the second target image to the multiple candidate images.
[0111] In this embodiment, after each script command is executed, the incremental snapshot data generated after the execution of the script command is obtained accordingly, and the first target image is adjusted based on the incremental snapshot data, so that when the target container is generated, the second target image corresponding to the target container is obtained accordingly, and the second target image is added to multiple candidate images to enrich the number of candidate images in the image library, and facilitate the container building operation when the corresponding user accesses again.
[0112] Exemplarily, the multiple candidate images are stored in an image repository of a cloud native platform, and adding the second target image to the multiple candidate images may include: uploading the second target image to the image repository.
[0113] In one embodiment, after adjusting the original container according to the second data to obtain the target container, the method further includes:
[0114] Obtaining an execution log of each script command among the multiple script commands, wherein the execution log includes a first sub-log when the corresponding script command is executed normally or a second sub-log when the corresponding script command is executed incorrectly;
[0115] An execution log of each of the plurality of script commands is displayed.
[0116] In this embodiment, by obtaining and displaying the execution log of each script command during the construction process of the target container, it is convenient for users to track the construction process of the target container, so that users can quickly identify abnormal conditions during the construction process of the target container and deal with them, thereby reducing the adverse effects of abnormal conditions and improving the user experience.
[0117] Exemplarily, two threads can be started in the cloud native platform, where one thread is used to monitor and record the data output of each of the multiple script commands during normal execution (i.e., the first sub-log), and the other thread is used to monitor and record the data output of each of the multiple script commands during normal execution (i.e., the second sub-log). When the target container is built, the above two threads can summarize and report the recorded data for users to view.
[0118] For ease of understanding, the following examples are provided:
[0119] like Figure 2 As shown, after the user accesses the cloud native platform, the cloud native platform allocates a corresponding namespace (namespace) to the user. The namespace is pre-set with an image service (imageServer) for managing containers. The imageServer receives the user's input information and completes the startup of the container required by the user based on the input information.
[0120] The user's input information includes dockerfile, CPU, and memory.
[0121] The process of imageServer starting the container required by the user based on the input information is as follows:
[0122] imageServer parses the base image baseImage (which can be understood as the first target image) from dockerfile, and uses baseImage as the container image, and starts the container imageContainer (which can be understood as the original container) through containerManager in combination with CPU and memory settings;
[0123] ImageContainer further parses the dockerfile to convert multiple instructions (which can be understood as the aforementioned image adjustment instructions) carried in the dockerfile into a ShellList command list (which can be understood as multiple script commands), and adds a corresponding execution tag to each command in the ShellList command list, and then executes the ShellList command list based on the execution tag to obtain a new imageContainer (which can be understood as the aforementioned target container) that matches the user's needs.
[0124] When imageContainer executes a Shell command, it will also record the newly added snapshot of the container, parse the snapshot file, and then convert the parsed file according to the format of the container image layer to generate an image layer file. When imageContainer is adjusted to a new imageContainer that matches user needs, the corresponding image layer file can be understood as the aforementioned second target image. The second target image will be pushed to the harbor private image warehouse (that is, the cloud native platform's image warehouse for storing the multiple candidate images), that is, the second target image will be added to the multiple candidate images.
[0125] The imageServer is specifically used to obtain and verify parameters, that is, to obtain the dockerfile, cpu, and memory parameters submitted by the user, encapsulate them into a request object, and then pass the request object to the containerManager;
[0126] After containerManager obtains the aforementioned request object, it extracts the baseImage, cpu, and memory in the first line from dockerfile as the basic properties of imageContainer, and calls the start container interface to start the container based on the basic properties. At the same time, containerManager monitors the status of the entire life cycle of the container and receives the container log to display the process of mirroring (referring to generating the target container). When an error occurs in the container or the mirroring is completed, containerManager recycles the resources of imageContainer and closes imageContainer.
[0127] like Figure 3 As shown, when imageContainer executes any Shell command, it will start a subprocess and two threads. The corresponding subprocess is responsible for the execution of the Shell command, and the corresponding two threads manage the standard output stream and error stream respectively. The standard output stream is used to output the normal execution log when the Shell command is executed (that is, the first sublog mentioned above), and the error stream is used for the error log of the Shell command execution (that is, the second sublog mentioned above). Then the standard output stream and error stream will report all the outputs to containerManager as log display.
[0128] Among them, when the aforementioned child process executes a Shell command and an exception occurs and an error is reported (that is, error is output), the child process will report the error result to containerManager so that the user can troubleshoot the exception problem based on the error result. At the same time, imageContainer will close the aforementioned child process and two threads to avoid the child process and two threads occupying system resources.
[0129] See also Figure 4 , Figure 4 A container management device based on a cloud native platform is provided in an embodiment of the present disclosure, such as Figure 4 As shown, the container management device 400 based on the cloud native platform includes:
[0130] An acquisition module 401 is used to acquire container configuration information, wherein the container configuration information includes first data and second data, wherein the first data is used to indicate the image on which the container building depends, and the second data is used to indicate the adjustment requirement of the container;
[0131] A determination module 402 is configured to determine a first target image from a plurality of preset candidate images according to the first data, wherein the first target image is a candidate image that matches the first data from the plurality of candidate images;
[0132] A construction module 403 is used to construct an original container according to the first target image;
[0133] The adjustment module 404 is configured to adjust the original container according to the second data to obtain a target container.
[0134] In one embodiment, the second data includes a plurality of mirror adjustment instructions;
[0135] The adjustment module 404 includes:
[0136] A conversion unit, configured to convert the plurality of image adjustment instructions into a plurality of script commands for container adjustment;
[0137] An analyzing unit, configured to analyze the plurality of script commands and determine an execution tag of each script command, wherein the execution tag is used to indicate whether the corresponding script command satisfies a condition for parallel processing or a condition for serial processing;
[0138] A processing unit is used to perform parallel processing or serial processing on the multiple script commands in the original container according to the execution tag of each script command to obtain the target container.
[0139] In one embodiment, the execution tag includes: a first tag, a second tag, and a third tag;
[0140] The script command corresponding to the first label is an asynchronous command, the script command corresponding to the second label is a synchronous command, and the script command corresponding to the third label is a waiting command;
[0141] Among them, the third tag is used to indicate at least one preceding command corresponding to the waiting command, the preceding command is a script command among the multiple script commands, and the execution trigger condition of the waiting command is: the at least one preceding command corresponding to the waiting command is executed.
[0142] In one embodiment, the third tag carries at least one index, the at least one index corresponds to the at least one preceding command in a one-to-one manner, and the index is the order of the corresponding preceding command in the plurality of script commands.
[0143] In one embodiment, the analysis unit is specifically used for:
[0144] Obtaining multiple command keywords corresponding to the multiple script commands respectively;
[0145] The execution tag of each script command is determined according to a preset mapping relationship and the plurality of command keywords, wherein the mapping relationship is used to indicate the execution tag associated with the command keyword.
[0146] In one embodiment, the processing unit is further configured to:
[0147] Acquire a plurality of incremental snapshot data corresponding to the plurality of script commands, wherein the incremental snapshot data is used to indicate the adjustment of the data of the original container by the corresponding container configuration instruction;
[0148] Adjusting the first target image according to the multiple incremental snapshot data to obtain a second target image corresponding to the target container;
[0149] Add the second target image to the multiple candidate images.
[0150] In one embodiment, the plurality of candidate images include at least one of the following:
[0151] The first image is preset;
[0152] The second image used in the historical period.
[0153] In one embodiment, the container management device 400 based on the cloud native platform further includes:
[0154] A log acquisition module, used to acquire an execution log of each script command among the multiple script commands, wherein the execution log includes a first sub-log when the corresponding script command is executed normally or a second sub-log when the corresponding script command is executed incorrectly;
[0155] The display module is used to display the execution log of each script command in the multiple script commands.
[0156] The cloud-native platform-based container management device 400 provided in the embodiment of the present disclosure can implement each process in the above-mentioned cloud-native platform-based container management method embodiment, and will not be described again here to avoid repetition.
[0157] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
[0158] Figure 5 A schematic block diagram of an example electronic device 500 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0159] like Figure 5As shown, the device 500 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 to a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the device 500 can also be stored. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0160] A number of components in the device 500 are connected to the I / O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the device 500 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0161] The computing unit 501 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSP), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 501 performs the various methods and processes described above, such as a container management method based on a cloud native platform. For example, in some embodiments, a container management method based on a cloud native platform may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the computing unit 501, one or more steps of the container management method based on the cloud native platform described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to execute the container management method based on the cloud native platform in any other appropriate manner (for example, by means of firmware).
[0162] Various embodiments of the systems and techniques described above herein may be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0163] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0164] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0165] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0166] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0167] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0168] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0169] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A container management method based on a cloud native platform, characterized in that: The method comprises: Obtaining container configuration information, wherein the container configuration information includes first data and second data, wherein the first data is used to indicate an image on which container building depends, and the second data is used to indicate an adjustment requirement of the container; Determine a first target image from a plurality of preset candidate images according to the first data, wherein the first target image is a candidate image that matches the first data from the plurality of candidate images; Building an original container according to the first target image; The original container is adjusted according to the second data to obtain a target container.
2. The method according to claim 1, characterized in that The second data includes a plurality of mirror adjustment instructions; The adjusting the original container according to the second data to obtain a target container includes: Converting the multiple image adjustment instructions into multiple script commands for container adjustment; Analyze the multiple script commands to determine an execution tag of each script command, wherein the execution tag is used to indicate whether the corresponding script command meets a condition for parallel processing or a condition for serial processing; According to the execution tag of each script command, the multiple script commands are processed in parallel or serially in the original container to obtain the target container.
3. The method according to claim 2, characterized in that The execution tag includes: a first tag, a second tag and a third tag; The script command corresponding to the first label is an asynchronous command, the script command corresponding to the second label is a synchronous command, and the script command corresponding to the third label is a waiting command; Among them, the third tag is used to indicate at least one preceding command corresponding to the waiting command, the preceding command is a script command among the multiple script commands, and the execution trigger condition of the waiting command is: the at least one preceding command corresponding to the waiting command is executed.
4. The method according to claim 3, characterized in that The third tag carries at least one index, the at least one index corresponds to the at least one preceding command in a one-to-one manner, and the index is the order of the corresponding preceding command in the plurality of script commands.
5. The method according to claim 2, characterized in that: Analyzing the multiple script commands to determine the execution tag of each script command includes: Obtaining multiple command keywords corresponding to the multiple script commands respectively; The execution tag of each script command is determined according to a preset mapping relationship and the plurality of command keywords, wherein the mapping relationship is used to indicate the execution tag associated with the command keyword.
6. The method according to any one of claims 2 to 5, characterized in that The step of performing parallel processing or serial processing on the multiple script commands in the original container according to the execution tag of each script command to obtain the target container includes: Acquire a plurality of incremental snapshot data corresponding to the plurality of script commands, wherein the incremental snapshot data is used to indicate the adjustment of the data of the original container by the corresponding container configuration instruction; Adjusting the first target image according to the multiple incremental snapshot data to obtain a second target image corresponding to the target container; Add the second target image to the multiple candidate images.
7. The method according to any one of claims 2 to 5, characterized in that After adjusting the original container according to the second data to obtain the target container, the method further includes: Obtaining an execution log of each script command among the multiple script commands, wherein the execution log includes a first sub-log when the corresponding script command is executed normally or a second sub-log when the corresponding script command is executed incorrectly; An execution log of each of the plurality of script commands is displayed.
8. The method according to any one of claims 1 to 5, characterized in that The multiple candidate images include at least one of the following: The first image is preset; The second image used in the historical period.
9. A container management device based on a cloud native platform, characterized in that: The device comprises: An acquisition module, used to acquire container configuration information, wherein the container configuration information includes first data and second data, wherein the first data is used to indicate the image on which the container building depends, and the second data is used to indicate the adjustment requirement of the container; a determination module, configured to determine a first target image from a plurality of preset candidate images according to the first data, wherein the first target image is a candidate image that matches the first data from the plurality of candidate images; A construction module, configured to construct an original container according to the first target image; An adjustment module is used to adjust the original container according to the second data to obtain a target container.
10. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the method according to any one of claims 1 to 8 when executed by the processor.
