File downloading method and device of container, electronic equipment and storage medium

By designing the interactive mechanism between the first service and the second service in the K8S environment, the problem of obtaining container files while ensuring security is solved, and a safe and efficient file download process is achieved.

CN119697177AActive Publication Date: 2025-03-25TRAVELSKY TECHNOLOGY LIMITED
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411917947.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-03-25
Estimated Expiration
2044-12-24

AI Technical Summary

Technical Problem

In the K8S environment, existing tools are difficult to obtain the files generated by the container while ensuring security, and there are security problems.

Method used

The first service receives the download request from the client, determines the target application instance from the multiple application instances of the second service based on the container information, and downloads the target file through the target application instance, and finally sends the file to the client through the target interface.

Benefits of technology

It realizes the acquisition of files generated by the container while ensuring security, reducing the risk of direct attack on the second service.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119697177A_ABST
    Figure CN119697177A_ABST
Patent Text Reader

Abstract

The invention discloses a file downloading method and device of a container, electronic equipment and a storage medium. The method comprises the steps that a downloading request sent by a client side is received through a first service, and the downloading request is used for requesting to download a target file generated by a target container; based on container information of a target container carried in the downloading request, a target application instance is determined from multiple application instances of the second service, and different application instances are associated with different containers; downloading the target file through the target application instance based on file information of the target file carried in the downloading request; and sending the target file to the client through a target interface corresponding to the target application instance. The technical problem that it is difficult to obtain the file generated by the container on the premise that safety is guaranteed is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of containers, and in particular to a method, device, electronic device and storage medium for downloading files from a container. Background Art

[0002] A container is a lightweight, portable software runtime environment that allows developers to package applications and their dependencies together to ensure consistency of applications in different environments. K8S (Kubernetes, an open source container orchestration platform) provides a framework for running distributed systems for automating the deployment, expansion, and management of containerized applications.

[0003] In the K8S environment, logs can be collected through tools such as Filebeat (a lightweight log file collector) and Fluentd (an open source data collector), but these tools cannot directly obtain the original log files printed by the application or other files generated by the application container. Although commands can be used to copy files in the container to an external system, attackers can use the execution permissions of the command to inject attack code into the container, resulting in security issues with this approach.

[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0005] Embodiments of the present invention provide a method, device, electronic device and storage medium for downloading files from a container, so as to at least solve the technical problem that it is difficult to obtain files generated by a container while ensuring security.

[0006] According to one aspect of an embodiment of the present invention, a method for downloading a file of a container is provided, comprising: receiving a download request sent by a client through a first service, wherein the download request is used to request downloading a target file generated by a target container; determining a target application instance from multiple application instances of a second service based on container information of the target container carried in the download request, wherein different application instances are associated with different containers; downloading the target file through the target application instance based on file information of the target file carried in the download request; and sending the target file to the client through a target interface corresponding to the target application instance.

[0007] In one embodiment of the present application, based on the file information of the target file carried in the download request, the target file is downloaded through the target application instance, including: obtaining file classification information corresponding to the target application instance; determining a file download address based on the file information and file classification information of the target file; and downloading the target file according to the file download address.

[0008] In one implementation of the present application, a target file is sent to a client via a target interface corresponding to a target application instance, including: obtaining authentication information; determining whether the authentication information matches a target interface corresponding to the target application instance; and when the authentication information matches the target interface, sending the target file to the client via the target interface.

[0009] In one implementation of the present application, receiving a download request sent by a client through a first service also includes: deploying a second service on multiple nodes, where the nodes are used to manage at least one container; mounting multiple files generated by multiple containers based on the second service; classifying and aggregating the mounted multiple files to obtain a file directory; based on identification information of multiple nodes, associating and mapping multiple containers with the second service through the first service to obtain a mapping relationship table; and storing the mapping relationship table in a database.

[0010] In one implementation of the present application, the second service is deployed on multiple nodes, including: determining a template for an application instance of the second service; creating multiple application instances of the second service based on the template; and deploying the multiple application instances to multiple nodes according to resource affinity rules through a scheduler.

[0011] In one implementation of the present application, multiple files generated by multiple containers are mounted based on a second service, including: configuring a data sharing mechanism for the second service; determining a generation path of the multiple files based on the data sharing mechanism; and mounting the multiple files to a target path according to the generation path of the multiple files.

[0012] In one implementation of the present application, multiple files after mounting are classified and aggregated to obtain a file directory, including: determining the directory structure of the multiple files after mounting; obtaining the name of the application instance of the second service and the namespace to which the container belongs; naming the multiple files after mounting based on the name of the application instance of the second service and the namespace to which the container belongs to obtain file names of the multiple files after mounting; filling the directory structure based on the file names of the multiple files after mounting to obtain a file directory.

[0013] According to another aspect of an embodiment of the present invention, a file download device for a container is also provided, including: a receiving module, used to receive a download request sent by a client through a first service, wherein the download request is used to request downloading of a target file generated by a target container; a determining module, used to determine a target application instance from multiple application instances of a second service based on container information of the target container carried in the download request, wherein different application instances are associated with different containers; a downloading module, used to download the target file through the target application instance based on file information of the target file carried in the download request; and a sending module, used to send the target file to the client through a target interface corresponding to the target application instance.

[0014] According to another aspect of an embodiment of the present invention, an electronic device is provided, including: a memory storing an executable program; and a processor for running the program, wherein when the program is running, the device where the memory is located is controlled to execute the above-mentioned container file downloading method.

[0015] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored executable program, wherein when the executable program runs, the device where the storage medium is located is controlled to execute the above-mentioned container file downloading method.

[0016] In an embodiment of the present invention, a download request sent by a client is received through a first service, wherein the download request is used to request downloading of a target file generated by a target container; based on the container information of the target container carried in the download request, a target application instance is determined from multiple application instances of a second service, wherein different application instances are associated with different containers; based on the file information of the target file carried in the download request, the target file is downloaded through the target application instance; and the target file is sent to the client through a target interface corresponding to the target application instance. It is easy to notice that by receiving the download request through the first service open to the client, and downloading the target file through the target application instance of the second service isolated from the client, the risk of the second service being directly attacked is reduced, and the target file is sent to the client through the target interface corresponding to the target application instance, so that the client can obtain the file generated by the container, and the purpose of obtaining the file generated by the container is achieved under the premise of ensuring security, thereby solving the technical problem that it is difficult to obtain the file generated by the container under the premise of ensuring security. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0018] Figure 1 is a flow chart of a method for downloading files from a container according to an embodiment of the present invention;

[0019] Figure 2 is a flow chart of an optional deployment of a first service according to an embodiment of the present invention;

[0020] Figure 3 is a flow chart of an optional deployment of a second service according to an embodiment of the present invention;

[0021] Figure 4 is an optional flow chart of a user downloading a file according to an embodiment of the present invention;

[0022] Figure 5is a schematic diagram of an optional first service deployed on multiple nodes according to an embodiment of the present invention;

[0023] Figure 6 It is a schematic diagram of a file downloading device for a container according to an embodiment of the present invention. DETAILED DESCRIPTION

[0024] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0026] Example 1

[0027] According to an embodiment of the present invention, an embodiment of a file downloading method for a container is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0028] Figure 1 is a flowchart of a method for downloading a file from a container according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:

[0029] Step S102: receiving a download request sent by a client through a first service, wherein the download request is used to request downloading of a target file generated by a target container.

[0030] The first service in the above steps is a service that can be directly used by the client and is used to connect the client and the second service.

[0031] The download request in the above step is a request sent by the client to the first service for obtaining the target file generated by the target container. The download request may include container information of the target container and file information of the target file.

[0032] The target container in the above steps is the container that generates the target file, and the target file is the file corresponding to the download request. A container is a lightweight, portable operating environment that encapsulates an application and its dependencies to achieve consistency and isolation.

[0033] In an optional embodiment, when a user needs to obtain a target file generated by a target container, container information that can identify the target container and file information that can identify the target file can be encapsulated in a download request, and the encapsulated download request is sent through the client to a query interface provided by the first service.

[0034] The first service may monitor the download request. When monitoring the download request sent by the client, the first service receives the download request sent by the client through the query interface.

[0035] Step S104: determining a target application instance from multiple application instances of the second service based on the container information of the target container carried in the download request, wherein different application instances are associated with different containers.

[0036] The container information in the above steps is data used to uniquely identify and locate the target container, and may be the Pod (container group) name of the target container, the name of the target container, and the identifier of the target container, but is not limited thereto.

[0037] The second service in the above steps provides a download interface for the target file, which is used to actually perform the task of downloading the target file. The second service is not a service that the client can use directly, and the client needs to use the second service through the first service.

[0038] The target application instance in the above steps is an application instance of the second service deployed on the node corresponding to the target container. The node corresponding to the target container is used to manage one or more containers including the target container. The target application instance deployed on the node corresponding to the target container can directly access and download the target file. The application instance is an instance of the second service deployed on different nodes, and each application instance is used to manage the files of the container on the corresponding node.

[0039] In an optional embodiment, the first service determines the target container from multiple containers according to the container information carried in the download request. Then, the IP (Internet Protocol) address of the node corresponding to the target container is obtained through a monitoring tool. The monitoring tool can be Prometheus (an open source monitoring tool suite), but is not limited thereto. Then, the mapping relationship between the node IP and the application instance of the second service is obtained from the database, and the target application instance associated with the node is searched from the mapping relationship according to the IP of the node corresponding to the target container.

[0040] Step S106: based on the file information of the target file carried in the download request, download the target file through the target application instance.

[0041] The file information in the above steps is data used to uniquely identify the target file, and may be the name of the target file, the number of the target file, the identifier of the target file, etc., but is not limited thereto.

[0042] In an optional embodiment, the storage path of the target file is determined according to the file information and the file directory provided by the second service. The second service determines whether the target file exists according to the storage path of the target file, and if the target file exists, the target file is downloaded. Since the target application instance is used to manage files of the target container, if the target file exists, the target application instance can be directly used to download the target file.

[0043] Step S108: sending the target file to the client through the target interface corresponding to the target application instance.

[0044] The target interface in the above steps is provided by the second service and is used to send the target file to the client.

[0045] In an optional embodiment, the second service can use a data transmission protocol to send the target file to the client through the target interface corresponding to the target application instance. The data transmission protocol used can be HTTP (Hypertext Transfer Protocol) or HTTPS (Hypertext Transfer Protocol Secure).

[0046] In another optional embodiment, after downloading the target file, the target interface can be fed back to the client. After the client sends a request to obtain the target file to the target interface, the second service constructs an HTTP response and sends the target file as part of the response body to the client through the target interface.

[0047] In an embodiment of the present invention, a download request sent by a client is received through a first service, wherein the download request is used to request downloading of a target file generated by a target container; based on the container information of the target container carried in the download request, a target application instance is determined from multiple application instances of a second service, wherein different application instances are associated with different containers; based on the file information of the target file carried in the download request, the target file is downloaded through the target application instance; and the target file is sent to the client through a target interface corresponding to the target application instance. It is easy to notice that by receiving the download request through the first service open to the client, and downloading the target file through the target application instance of the second service isolated from the client, the risk of the second service being directly attacked is reduced, and the target file is sent to the client through the target interface corresponding to the target application instance, so that the client can obtain the file generated by the container, and the purpose of obtaining the file generated by the container is achieved under the premise of ensuring security, thereby solving the technical problem that it is difficult to obtain the file generated by the container under the premise of ensuring security.

[0048] In one embodiment of the present application, based on the file information of the target file carried in the download request, the target file is downloaded through the target application instance, including: obtaining file classification information corresponding to the target application instance; determining a file download address based on the file information and file classification information of the target file; and downloading the target file according to the file download address.

[0049] The file classification information in the above steps is metadata used by the second service to organize and manage files generated by different containers, including but not limited to file storage location, file type, creation time, container namespace to which the file belongs, and application entity name corresponding to the file.

[0050] The file download address in the above step is a URL (Uniform Resource Locator) or an API (Application Programming Interface) endpoint for downloading a target file provided by the second service.

[0051] In an optional embodiment, pre-stored file classification information can be obtained from a database, and then based on the file identifier in the file information of the target file, the file storage location corresponding to the target file can be determined from the file classification information. A URL is constructed based on the file storage location and the file identifier to obtain a file download address. The target file is then downloaded based on the file download address.

[0052] In one implementation of the present application, a target file is sent to a client via a target interface corresponding to a target application instance, including: obtaining authentication information; determining whether the authentication information matches a target interface corresponding to the target application instance; and when the authentication information matches the target interface, sending the target file to the client via the target interface.

[0053] The authentication information in the above steps can be data used to verify the user's identity, which can be an API key, a digital certificate, etc., to ensure that only authorized user accounts or clients can access the target file.

[0054] In an optional embodiment, the authentication information is an API key. After the target interface is determined, the target interface can be returned to the client, and the user can be prompted to upload the authentication information through the client. The user can send the API key to the target interface, and the second service authenticates the API key. Specifically, the second service compares the API key with the key corresponding to the preset target interface. If the API key is consistent with the key corresponding to the preset target interface, it is determined that the API key verification is successful. If the API key verification is successful, the second service sends the target file to the client through the target interface; if the API key verification is not successful, the second service does not send the target file to the client, and sends a prompt message to the client, indicating that the authentication information is incorrect.

[0055] In one implementation of the present application, receiving a download request sent by a client through a first service also includes: deploying a second service on multiple nodes, where the nodes are used to manage at least one container; mounting multiple files generated by multiple containers based on the second service; classifying and aggregating the mounted multiple files to obtain a file directory; based on identification information of multiple nodes, associating and mapping multiple containers with the second service through the first service to obtain a mapping relationship table; and storing the mapping relationship table in a database.

[0056] The node in the above steps is a physical or virtual machine in the K8S environment, which has the resources required to run containers, is used to deploy the second service and manage one or more containers.

[0057] The above steps are used to classify and organize the mounted files, which are constructed by the second service.

[0058] The identification information in the above steps is information used to uniquely identify and locate the node, and may be a node IP, but is not limited thereto.

[0059] The mapping relationship table in the above steps is used to associate multiple containers with multiple application instances of the second service, and records the mapping relationship between the node IP, the container, and the application instance of the second service.

[0060] In an optional example, before executing the download task, the second service needs to be deployed on multiple nodes, and the container and the second service need to be associated through the first service to ensure smooth execution of the download task.

[0061] When deploying the second service, the second service can be deployed on multiple nodes through the DaemonSet (a controller in K8S) controller so that an application instance of the second service is deployed on each node. When mounting multiple files generated by multiple containers based on the second service, the files of the container running on the node can be mounted to a preset path based on the second service through the Volume (a package interface for managing resources in K8S) mounting mechanism. When classifying and aggregating the mounted multiple files, the file names managed by the application instance of the second service are summarized under the name of the application instance of the second service, so that the mounted multiple files are classified according to the application instance of the second service to obtain a file directory.

[0062] When multiple containers and the second service are associated and mapped through the first service, the node identification information is taken as the node IP as an example. According to the node IP, the application instance of the second service deployed on the node and one or more containers managed by the node are determined, and the application instance of the second service deployed on the node is associated with the one or more containers managed by the node to obtain a mapping relationship table, and the mapping relationship table is stored in the K8S database.

[0063] In one implementation of the present application, the second service is deployed on multiple nodes, including: determining a template for an application instance of the second service; creating multiple application instances of the second service based on the template; and deploying the multiple application instances to multiple nodes according to resource affinity rules through a scheduler.

[0064] The template of the application instance of the second service in the above step is configuration information for creating the application instance of the second service, and may include, but is not limited to, container images, resource restrictions, environment variables, etc.

[0065] The scheduler in the above steps is a component in K8S, which is used to decide to deploy the application instance of the second service on a node that has a higher match with the application instance.

[0066] The resource affinity rules in the above steps are used to quantify the affinity relationship between the application instance and the node of the second service, which is a mechanism provided by K8S.

[0067] In an optional embodiment, the template of the application instance of the second service can be determined according to the YAML (a data serialization format) configuration file of DaemonSet. The content of the template may include but is not limited to container images, resource requests, environment variables, etc. Then, by instantiating the template, multiple application instances of the second service corresponding to multiple nodes are created. Subsequently, the application instance is scheduled to a suitable node by the scheduler according to the resource affinity rules. Specifically, the scheduler determines whether the resources of the node meet the requirements of the application instance of the second service, whether the labels and annotations of the node match the affinity rules, and whether there are affinity and anti-affinity rules related to the application instance according to the resource affinity rules. Based on the above judgment, the node with the highest match with the application instance is screened out from multiple nodes, and the application instance is deployed on the node.

[0068] In one implementation of the present application, multiple files generated by multiple containers are mounted based on a second service, including: configuring a data sharing mechanism for the second service; determining a generation path of the multiple files based on the data sharing mechanism; and mounting the multiple files to a target path according to the generation path of the multiple files.

[0069] The data sharing mechanism in the above steps is used to enable each application instance of the second service to obtain files generated by containers on different nodes.

[0070] The build path in the preceding steps is the specific location of the container build file.

[0071] The target path in the above step is a path inside the second service for storing and managing files from multiple containers.

[0072] In an optional embodiment, Volume and PersistentVo l ume (a storage resource in K8S) can be configured in the application instance configuration of the second service, and then VolumeMount (a field in the application instance configuration file) can be configured to complete the configuration of the data sharing mechanism of the second service. This allows the application instance of the second service to share access to files of containers of multiple nodes, rather than just being limited to the node where the application instance itself is located. Based on the data sharing mechanism, the second service can obtain the generation path of the container generation file under multiple nodes. Multiple files are obtained according to the generation path of the multiple files, and the multiple files are mounted to a preset target path to complete the mounting of the multiple files.

[0073] In one implementation of the present application, multiple files after mounting are classified and aggregated to obtain a file directory, including: determining the directory structure of the multiple files after mounting; obtaining the name of the application instance of the second service and the namespace to which the container belongs; naming the multiple files after mounting based on the name of the application instance of the second service and the namespace to which the container belongs to obtain file names of the multiple files after mounting; filling the directory structure based on the file names of the multiple files after mounting to obtain a file directory.

[0074] The directory structure in the above steps is the structural design of the file directory inside the second service.

[0075] The namespace to which the container belongs in the above steps is used to avoid conflicts in file names. Within the namespace to which the container belongs, the names of files generated by the container are unique.

[0076] In an optional embodiment, the directory structure of the mounted multiple files may be determined as follows:

[0077] / mnt / logs / namespace / podname / fi lename;

[0078] Among them, mnt and logs are existing system folders in K8S, namespace is the name of the namespace to which the container belongs, podname is the name of the application instance of the second service, and filename is the file name.

[0079] You can use the query command in K8S to query the name of the application instance of the second service and the namespace to which the container belongs, and then name the multiple files after mounting based on the name of the application instance of the second service and the namespace to which the container belongs. Specifically, use the name of the namespace to which the container belongs and the name of the application instance of the second service as the prefix of the file name, and use the name in the namespace to which the container belongs to name the file to obtain the file name. Then use the file name to fill the directory structure to obtain the file directory.

[0080] The following is a description of a preferred embodiment. Figure 2 is a flowchart of an optional deployment of a first service according to an embodiment of the present invention, such as Figure 2 As shown, the following steps may be included:

[0081] Step S202, query the monitoring tool to obtain the Internet Protocol address of the node.

[0082] Step S204: Associating the container with the second service based on the Internet Protocol address of the node.

[0083] Step S206: providing a query interface.

[0084] The query interface is an interface for receiving a download request sent by a client, and is provided by the first service.

[0085] Figure 3 is a flow chart of an optional deployment of a second service according to an embodiment of the present invention, such as Figure 3 As shown:

[0086] Step S302, mount the files generated by the container, and classify and aggregate them according to the namespace and the name of the application entity.

[0087] Step S304, providing a download interface.

[0088] The download interface is the target interface mentioned above, and is provided by the second service. The second service can directly send the target file to the client through the download interface, or return the download interface to the server, and after the user sends a file acquisition request to the download interface, the second service will send the target file to the client through the download interface.

[0089] Figure 4 is an optional flow chart of a user downloading a file according to an embodiment of the present invention, such as Figure 4 As shown:

[0090] Step S402: calling the query interface of the first service and sending the container name and file name to be downloaded.

[0091] Step S404: calling the download interface of the second service to download the file.

[0092] Figure 5 is a schematic diagram of an optional first service deployed on multiple nodes according to an embodiment of the present invention, such as Figure 5 As shown, node 11 is responsible for managing container 1, container 2, container 3, and container 4, and node 12 is responsible for managing container 5, container 6, container 7, and container 8. The application entity 21 of the second service is deployed on node 11, and can directly access the files generated by container 1, container 2, container 3, and container 4. The application entity 22 of the second service is deployed on node 12, and can directly access the files generated by container 5, container 6, container 7, and container 8.

[0093] Example 2

[0094] According to an embodiment of the present invention, an embodiment of a file downloading device for a container is provided. The device can execute the file downloading method for a container provided in the above embodiment 1. The specific implementation method and preferred application scenario are the same as those of the above embodiment 1 and are not described in detail here.

[0095] Figure 6is a schematic diagram of a file downloading device for a container according to an embodiment of the present invention. Figure 6 As shown, the file downloading device of the container includes:

[0096] A receiving module 60, configured to receive a download request sent by a client through a first service, wherein the download request is used to request downloading of a target file generated by a target container;

[0097] A determination module 62, configured to determine a target application instance from a plurality of application instances of the second service based on the container information of the target container carried in the download request, wherein different application instances are associated with different containers;

[0098] A download module 64, configured to download a target file through a target application instance based on file information of the target file carried in the download request;

[0099] The sending module 66 is used to send the target file to the client through the target interface corresponding to the target application instance.

[0100] The download module includes: a first acquisition unit, used to acquire file classification information corresponding to the target application instance; a first determination unit, used to determine the file download address based on the file information and file classification information of the target file; and a download unit, used to download the target file according to the file download address.

[0101] The sending module includes: a second acquisition unit for acquiring authentication information; a second determination unit for determining whether the authentication information matches the target interface corresponding to the target application instance; and a sending unit for sending the target file to the client through the target interface when the authentication information matches the target interface.

[0102] The receiving module also includes: a deployment unit, which is used to deploy the second service on multiple nodes, and the nodes are used to manage at least one container; a mounting unit, which is used to mount multiple files generated by multiple containers based on the second service; a classification and aggregation unit, which is used to classify and aggregate the multiple mounted files to obtain a file directory; a relationship mapping unit, which is used to associate and map multiple containers and the second service through the first service based on the identification information of multiple nodes to obtain a mapping relationship table; and a storage unit, which is used to store the mapping relationship table in a database.

[0103] The deployment unit is also used to: determine a template of an application instance of the second service; create multiple application instances of the second service based on the template; and deploy the multiple application instances to multiple nodes according to resource affinity rules through a scheduler.

[0104] The mounting unit is also used to configure a data sharing mechanism for the second service; determine a generation path of multiple files based on the data sharing mechanism; and mount the multiple files to a target path according to the generation path of the multiple files.

[0105] The classification aggregation unit is also used to determine the directory structure of multiple files after mounting; obtain the name of the application instance of the second service and the namespace to which the container belongs; name the multiple files after mounting based on the name of the application instance of the second service and the namespace to which the container belongs to obtain file names of the multiple files after mounting; fill the directory structure based on the file names of the multiple files after mounting to obtain a file directory.

[0106] Example 3

[0107] According to an embodiment of the present invention, an electronic device is further provided, comprising: a memory storing an executable program; and a processor for running the program, wherein the file downloading method for the container in Embodiment 1 is executed when the program is running.

[0108] Example 4

[0109] An embodiment of the present application further provides a computer-readable storage medium, which includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the container file download method in each embodiment of the present invention.

[0110] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0111] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0112] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0113] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0114] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0115] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0116] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A container file download method, characterized in that: include: Receiving, through the first service, a download request sent by a client, wherein the download request is used to request downloading of a target file generated by a target container; Determine a target application instance from a plurality of application instances of a second service based on the container information of the target container carried in the download request, wherein different application instances are associated with different containers; Based on the file information of the target file carried in the download request, downloading the target file through the target application instance; The target file is sent to the client through the target interface corresponding to the target application instance.

2. The container file download method according to claim 1, characterized in that: Downloading the target file through the target application instance based on the file information of the target file carried in the download request includes: Obtaining file classification information corresponding to the target application instance; Determine a file download address based on the file information of the target file and the file classification information; The target file is downloaded according to the file download address.

3. The container file download method according to claim 1, characterized in that: Sending the target file to the client through a target interface corresponding to the target application instance includes: Get authentication information; Determining whether the authentication information matches a target interface corresponding to the target application instance; In a case where the authentication information matches the target interface, the target file is sent to the client through the target interface.

4. The container file download method according to claim 1, characterized in that: Receiving, by the first service, a download request sent by the client, the method further comprising: Deploy the second service on multiple nodes, where the nodes are used to manage at least one container; Mounting multiple files generated by multiple containers based on the second service; Classify and aggregate multiple mounted files to obtain a file directory; Based on the identification information of the multiple nodes, the multiple containers and the second service are associated and mapped by the first service to obtain a mapping relationship table; The mapping relationship table is stored in a database.

5. The container file download method according to claim 4, characterized in that: Deploy the second service on multiple nodes, including: Determining a template for an application instance of the second service; Creating a plurality of application instances of the second service based on the template; The multiple application instances are deployed to the multiple nodes through a scheduler according to resource affinity rules.

6. The container file downloading method according to claim 4, characterized in that: The multiple files generated by mounting multiple containers based on the second service include: configuring a data sharing mechanism for the second service; Based on the data sharing mechanism, determining generation paths of the multiple files; Mount the multiple files to a target path according to the generation paths of the multiple files.

7. The container file download method according to claim 4, characterized in that: Classify and aggregate multiple mounted files to obtain a file directory, including: Determine the directory structure of the plurality of files after mounting; Obtaining a name of the application instance of the second service and a namespace to which the container belongs; Naming the mounted multiple files based on the name of the application instance of the second service and the namespace to which the container belongs, to obtain file names of the mounted multiple files; The directory structure is filled based on the file names of the mounted multiple files to obtain the file directory.

8. A container file download device, characterized in that: include: A receiving module, configured to receive a download request sent by a client through a first service, wherein the download request is used to request downloading of a target file generated by a target container; a determination module, configured to determine a target application instance from a plurality of application instances of a second service based on the container information of the target container carried in the download request, wherein different application instances are associated with different containers; A download module, configured to download the target file through the target application instance based on the file information of the target file carried in the download request; The sending module is used to send the target file to the client through the target interface corresponding to the target application instance.

9. An electronic device, characterized in that: include: A memory storing an executable program; A processor, configured to run the program, wherein the program, when running, executes the container file download method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is executed, the device where the storage medium is located is controlled to execute the container file download method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • File operating method, device and system

    CN106844489A

  • Combined container deployment method and device, equipment and storage medium

    CN111324419A

  • Method and system for managing container files in cloud native environment

    CN116501449A

  • File management method and device based on kubernetes, electronic equipment and storage medium

    CN117609161A

  • Method and device for executing file operation in container

    CN118331934A