Container file downloading method and device, electronic equipment and storage medium

By utilizing a first service in a Kubernetes environment to receive download requests, identify the target application instance, and download container files using its interface, combined with authentication and mapping mechanisms, the problem of existing tools being unable to securely obtain container files is solved, thus achieving secure file acquisition and transmission.

CN119697177BActive Publication Date: 2026-04-10TRAVELSKY TECHNOLOGY LIMITED
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TRAVELSKY TECHNOLOGY LIMITED
Filing Date
2024-12-24
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

In a Kubernetes environment, existing tools cannot directly obtain files generated by application containers, and there are security risks involved. Attackers can inject malicious code by exploiting command execution privileges.

Method used

The system receives download requests from clients through the first service, determines the target application instance from the application instances of the second service based on container information, downloads and sends the target file using the interface of the target application instance, employs an authentication mechanism to ensure security, and manages container files through a mapping table and a data sharing mechanism.

Benefits of technology

This allows for the acquisition of files generated by the container while ensuring security, reducing the risk of direct attacks on the second service and ensuring the security and integrity of file transfers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119697177B_ABST
    Figure CN119697177B_ABST
Patent Text Reader

Abstract

The application discloses a container file downloading method and device, electronic equipment and a storage medium. The method comprises the following steps: receiving a downloading request sent by a client through a first service, wherein the downloading request is used for requesting to download a target file generated by a target container; determining a target application instance from a plurality of application instances of a second service based on container information of the target container carried in the downloading 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 downloading request; and sending the target file to the client through a target interface corresponding to the target application instance. The application solves the technical problem that it is difficult to obtain a file generated by a container under the premise of ensuring security.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of containers, in particular to a container file downloading method and device, an electronic device and a storage medium. BACKGROUND

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

[0003] In the K8S environment, logs can be collected through Filebeat (a lightweight log file collector), Fluentd (an open-source data collector) and other tools, but these tools cannot directly obtain the original log files printed by the application or other files generated by the application container. Although the files in the container can be copied to an external system using a command, an attacker can inject attack code into the container by exploiting the execution authority of the command, resulting in security problems with this approach.

[0004] At present, no effective solution has been proposed to solve the above problems. SUMMARY

[0005] The embodiments of the present application provide a container file downloading method and device, an electronic device and a storage medium to at least solve the technical problem of being difficult to obtain files generated by a container while ensuring security.

[0006] According to an aspect of an embodiment of the present application, a container file downloading method is provided, comprising: receiving a download request sent by a client through a first service, wherein the download request is used to request to download a target file generated by a target container; determining a target application instance from a plurality of 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 an embodiment of the present application, downloading the target file through the target application instance based on the file information of the target file carried in the download request comprises: obtaining file classification information corresponding to the target application instance; determining a file download address based on the file information of the target file and the file classification information; and downloading the target file according to the file download address.

[0008] In an embodiment of the present application, the target file is sent to the client through a target interface corresponding to the target application instance, including: obtaining authentication information; determining whether the authentication information matches the target interface corresponding to the target application instance; and in the case that the authentication information matches the target interface, sending the target file to the client through the target interface.

[0009] In an embodiment of the present application, the first service receives the download request sent by the client, and further includes: deploying the second service on a plurality of nodes, the nodes being used for managing at least one container; mounting a plurality of files generated by the plurality of containers based on the second service; classifying and aggregating the plurality of mounted files to obtain a file directory; associating and mapping the plurality of containers and the second service based on identification information of the plurality of nodes through the first service to obtain a mapping relationship table; and storing the mapping relationship table in a database.

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

[0011] In an embodiment of the present application, the plurality of files generated by the second service mounting the plurality of containers includes: configuring a data sharing mechanism for the second service; determining a generation path of the plurality of files based on the data sharing mechanism; and mounting the plurality of files to a target path according to the generation path of the plurality of files.

[0012] In an embodiment of the present application, the plurality of mounted files are classified and aggregated to obtain a file directory, including: determining a directory structure of the plurality of mounted files; obtaining a name of an application instance of the second service and a namespace to which a container belongs; naming the plurality of mounted files based on the name of the application instance of the second service and the namespace to which the container belongs to obtain a file name of the plurality of mounted files; and filling the directory structure based on the file name of the plurality of mounted files to obtain the file directory.

[0013] According to another aspect of the embodiment of the present application, a container file downloading device is also provided, including: 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 to download a target file generated by a target container; a determining module, configured to determine a target application instance from a plurality of 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, configured 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, configured to send the target file to the client through a target interface corresponding to the target application instance.

[0014] According to another aspect of the embodiments of the present application, an electronic device is provided, comprising: a memory storing an executable program; and a processor configured to execute the program, wherein the program, when executed, controls the device in which the memory is located to perform the file downloading method of the container.

[0015] According to another aspect of the embodiments of the present application, a computer readable storage medium is provided, comprising a stored executable program, wherein the program, when executed, controls the device in which the storage medium is located to perform the file downloading method of the container.

[0016] In the embodiments of the present application, the downloading request sent by the client is received through the first service, wherein the downloading request is used to request downloading of the target file generated by the target container; the target application instance is determined from the plurality of application instances of the second service based on the container information of the target container carried in the downloading request, wherein different application instances are associated with different containers; the target file is downloaded through the target application instance based on the file information of the target file carried in the downloading request; and the target file is sent to the client through the target interface corresponding to the target application instance. It is easy to note that the downloading request is received through the first service opened to the client, the target file is downloaded through the target application instance of the second service isolated from the client, the risk of direct attack on the second service is reduced, the target file is sent to the client through the target interface corresponding to the target application instance, the client can obtain the file generated by the container, the purpose of obtaining the file generated by the container is achieved under the premise of ensuring security, and the technical problem that it is difficult to obtain the file generated by the container under the premise of ensuring security is solved. BRIEF DESCRIPTION OF DRAWINGS

[0017] The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application. In the drawings:

[0018] Figure 1 is a flowchart of a file downloading method of a container according to an embodiment of the present application;

[0019] Figure 2 is a flowchart of an optional deployment of a first service according to an embodiment of the present application;

[0020] Figure 3 is a flowchart of an optional deployment of a second service according to an embodiment of the present application;

[0021] Figure 4 is a flowchart of an optional file downloading of a user according to an embodiment of the present application;

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

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

[0024] In order to make the personnel in the technical field better understand the present application scheme, the technical scheme in the embodiment of the present application will be described clearly and completely in the following with reference to the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, not all. Based on the embodiment in the present application, all other embodiments obtained by the person skilled in the art without creative labor should belong to the scope of protection of the present application.

[0025] It should be noted that the terms "first", "second" and the like in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not necessarily limit to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0026] Embodiment 1

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

[0028] Figure 1 is a flowchart of a file downloading method of a container according to an embodiment of the present application, as Figure 1 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 to download 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, which 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 a target file generated by a target container.

[0032] The target container in the above step is a container that generates a target file, and the target file is a file corresponding to the download request. A container is a lightweight and portable runtime environment that encapsulates an application and its dependencies within the container 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 capable of identifying the target container and file information capable of identifying the target file can be encapsulated in a download request, and the encapsulated download request can be sent to a query interface provided by the first service through the client.

[0034] The first service can listen to the download request, and when the download request sent by the client is listened to, the first service receives the download request sent by the client through the query interface.

[0035] In step S104, based on the container information of the target container carried in the download request, a target application instance is determined from a plurality of application instances of the second service, wherein different application instances are associated with different containers.

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

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

[0038] The target application instance in the above step is an application instance of the second service deployed on a target container corresponding node, and the target container corresponding node is used to manage one or more containers including the target container. The target application instance deployed on the target container corresponding node 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 containers on the corresponding node.

[0039] In an optional embodiment, the first service determines the target container from the plurality of 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 by the monitoring tool, which can be Prometheus, but is not limited thereto. Subsequently, 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] In step S106, the target file is downloaded by the target application instance based on the file information of the target file carried in the download request.

[0041] The file information in the above steps is data used to uniquely identify the target file, which can 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. Whether the target file exists is determined by the second service according to the storage path of the target file, and the target file is downloaded in the case that the target file exists. Since the target application instance is used to manage the files of the target container, the target file can be directly downloaded by the target application instance in the case that the target file exists.

[0043] In step S108, the target file is sent 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, and after the client sends a target file acquisition request to the target interface, the second service constructs an HTTP response, takes the target file as part of the response body, and sends it to the client through the target interface.

[0047] In the embodiments of the present application, the first service receives a download request sent by the client, wherein the download request is used to request to download a target file generated by a target container; based on container information of the target container carried in the download request, a target application instance is determined from a plurality of application instances of the second service, wherein different application instances are associated with different containers; based on file information of the target file carried in the download request, the target file is downloaded by 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 note that the download request is received by the first service open to the client, the target file is downloaded by the target application instance of the second service isolated from the client, the risk of direct attack on the second service is reduced, the target file is sent to the client through the target interface corresponding to the target application instance, the client can obtain the file generated by the container, the purpose of obtaining the file generated by the container is achieved under the premise of ensuring security, and the technical problem that it is difficult to obtain the file generated by the container under the premise of ensuring security is solved.

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

[0049] The file classification information in the above step is metadata for organizing and managing the files generated by different containers by the second service. It can include but is 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, Uniform Resource Locator) or API (Application Programming Interface, Application Programming Interface) endpoint provided by the second service for downloading the target file.

[0051] In an optional embodiment, the 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 is determined from the file classification information. The URL is constructed based on the file storage location and the file identifier to obtain the file download address. Then the target file is downloaded based on the file download address.

[0052] In an embodiment of the present application, the target file is sent to the client through the target interface corresponding to the target application instance, comprising: obtaining authentication information; determining whether the authentication information matches the target interface corresponding to the target application instance; and in the case that the authentication information matches the target interface, sending the target file to the client through the target interface.

[0053] The authentication information in the above step can be data for verifying the identity of a user, which can be an API key, a digital certificate, etc., for ensuring that only authorized user accounts or clients can access the target file.

[0054] In an optional embodiment, taking the authentication information as an API key as an example, after determining the target interface, the target interface can be returned to the client, and the user is 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 preset key corresponding to the target interface, and if the API key and the preset key corresponding to the target interface are consistent, it is determined that the API key authentication is passed. In the case that the API key authentication is passed, the second service sends the target file to the client through the target interface; in the case that the API key authentication is not passed, the second service does not send the target file to the client, and sends a prompt information to the client, prompting that the authentication information is incorrect.

[0055] In an embodiment of the present application, the first service receives the download request sent by the client, and further comprises: deploying the second service on a plurality of nodes, the nodes being used for managing at least one container; based on the second service mounting a plurality of files generated by the plurality of containers; classifying and aggregating the mounted plurality of files to obtain a file directory; based on the identification information of the plurality of nodes, associating and mapping the plurality of containers and the second service through the first service to obtain a mapping relationship table; and storing the mapping relationship table in a database.

[0056] The nodes in the above step are physical or virtual machines in a K8S environment, which have resources required for running containers and are used for deploying the second service and managing one or more containers.

[0057] The step of classifying and organizing the mounted files is constructed by the second service.

[0058] The identification information in the above step is information for uniquely identifying and positioning the nodes, which can be a node IP, but is not limited thereto.

[0059] The mapping relationship table in the above step is used to associate the plurality of containers and the plurality of 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 performing the download task, the second service needs to be deployed on the plurality of nodes, and the container and the second service are associated through the first service to ensure the smooth execution of the download task.

[0061] In the deployment of the second service, the second service can be deployed on the plurality of nodes through a DaemonSet (a controller in K8S) controller, so that an application instance of the second service is deployed on each node. In the mounting of the plurality of files generated by the plurality of containers based on the second service, the files of the container running on the node can be mounted on a preset path based on the second service through a Volume (a management resource encapsulation interface in K8S) mounting mechanism of K8S. In the classification and aggregation of the plurality of mounted 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 plurality of mounted files are classified according to the application instance of the second service, and a file directory is obtained.

[0062] In the association and mapping of the plurality of containers and the second service through the first service, the identification information of the node is taken as an example for illustration. 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, the application instance of the second service deployed on the node and the one or more containers managed by the node are associated, a mapping relationship table is obtained, and the mapping relationship table is stored in the database of K8S.

[0063] In an embodiment of the present application, the second service is deployed on the plurality of nodes, including: determining a template of an application instance of the second service; creating a plurality of application instances of the second service based on the template; and deploying the plurality of application instances to the plurality of nodes according to a resource affinity rule 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, which can include an image of a container, resource limits, environment variables, etc., but is not limited thereto.

[0065] The scheduler in the above step is a component in K8S, which is used to determine to deploy the application instance of the second service on a node with a higher matching degree.

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

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

[0068] In an embodiment of the present application, based on the plurality of files generated by the plurality of containers mounted by the second service, the method comprises: configuring a data sharing mechanism for the second service; determining a generation path of the plurality of files based on the data sharing mechanism; and mounting the plurality of files to a target path according to the generation path of the plurality of files.

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

[0070] The generation path in the above step is a specific location where the files are generated by the containers.

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

[0072] In an optional embodiment, a Volume and a PersistentVolume (a block of storage resources in K8S) can be configured in the application instance configuration of the second service, and then a VolumeMount (a field in the application instance configuration file) is configured to complete the configuration of the data sharing mechanism of the second service. This enables the application instance of the second service to share access to the files of the containers on a plurality of nodes, rather than 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 files generated by the containers on a plurality of nodes. According to the generation path of the plurality of files, the plurality of files are mounted to a predetermined target path to complete the mounting of the plurality of files.

[0073] In an embodiment of the present application, the plurality of mounted files are classified and aggregated to obtain a file directory, including: determining a directory structure of the plurality of mounted files; obtaining a name of an application instance of the second service and a namespace to which a container belongs; naming the plurality of mounted 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 plurality of mounted files; and filling the directory structure based on the file names of the plurality of mounted files to obtain the file directory.

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

[0075] The namespace to which the container belongs in the above step is used to avoid conflicts of file names, and the name of a file generated by the container is unique in the namespace to which the container belongs.

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

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

[0078] Wherein, mnt and logs are system folders already existing 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] The name of the application instance of the second service and the namespace to which the container belongs can be queried using a query command in K8S, and then the plurality of mounted files are named based on the name of the application instance of the second service and the namespace to which the container belongs. Specifically, the name of the namespace to which the container belongs and the name of the application instance of the second service are used as prefixes of the file names, and the names in the namespace to which the container belongs are used to name the files to obtain the file names. Then the directory structure is filled with the file names to obtain the file directory.

[0080] In the following, a preferred embodiment is taken as an example for description, Figure 2 is a flowchart of an optional deployment of the first service according to an embodiment of the present application, as Figure 2 shown, can include the following steps:

[0081] In step S202, the monitoring tool is queried to obtain an Internet protocol address of the node.

[0082] In step S204, the container and the second service are associated based on the Internet protocol address of the node.

[0083] In step S206, a query interface is provided.

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

[0085] Figure 3 is a flowchart of an optional process of deploying the second service according to an embodiment of the present application, as shown in Figure 3

[0086] In step S302, the files generated by the containers are mounted and classified and aggregated according to the namespace and the name of the application entity.

[0087] In step S304, a download interface is provided.

[0088] The download interface is the target interface in the above, provided by the second service. The target file can be sent to the client by the second service directly through the download interface, or the download interface can be returned to the server, and then the target file is sent to the client by the second service through the download interface after the user sends a file acquisition request to the download interface.

[0089] Figure 4 is a flowchart of an optional process of downloading a file by a user according to an embodiment of the present application, as shown in Figure 4

[0090] In step S402, the query interface of the first service is called, and the container name and the file name to be downloaded are sent.

[0091] In step S404, the download interface of the second service is called, and the file is downloaded.

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

[0093] Embodiment 2

[0094] According to an embodiment of the present application, an embodiment of a file download device of a container is provided, which can execute the file download method of the container provided in Embodiment 1, and the specific implementation manner and preferred application scenario are the same as those of Embodiment 1, which will not be described here.

[0095] Figure 6 ​​is a schematic diagram of a container file downloading apparatus according to an embodiment of the present application, as shown in Figure 6 The container file downloading apparatus comprises:

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

[0097] The determining module 62 is configured to determine a target application instance from a plurality of application instances of the second service based on container information of the target container carried in the downloading request, wherein different application instances are associated with different containers.

[0098] The downloading module 64 is configured to download the target file through the target application instance based on file information of the target file carried in the downloading request.

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

[0100] The downloading module comprises: a first obtaining unit configured to obtain file classification information corresponding to the target application instance; a first determining unit configured to determine a file downloading address based on the file information of the target file and the file classification information; and a downloading unit configured to download the target file according to the file downloading address.

[0101] The sending module comprises: a second obtaining unit configured to obtain authentication information; a second determining unit configured to determine whether the authentication information matches a target interface corresponding to the target application instance; and a sending unit configured to send the target file to the client through the target interface in a case where the authentication information matches the target interface.

[0102] The receiving module further comprises: a deploying unit configured to deploy the second service on a plurality of nodes, wherein the nodes are used to manage at least one container; a mounting unit configured to mount a plurality of files generated by a plurality of containers based on the second service; a classification and aggregation unit configured to perform classification and aggregation on the plurality of mounted files to obtain a file directory; a relationship mapping unit configured to associate and map the plurality of containers and the second service through the first service based on identification information of the plurality of nodes to obtain a mapping relationship table; and a storage unit configured to store the mapping relationship table in a database.

[0103] The deploying unit is further configured to: determine a template of an application instance of the second service; create a plurality of application instances of the second service based on the template; and deploy the plurality of application instances to the plurality of nodes according to a resource affinity rule through a scheduler.

[0104] The mounting unit is further configured to configure a data sharing mechanism for the second service; determine generation paths of the plurality of files based on the data sharing mechanism; and mount the plurality of files to target paths according to the generation paths of the plurality of files.

[0105] The classification aggregation unit is further configured to determine a directory structure of the plurality of mounted files; obtain a name of the application instance of the second service and a namespace to which the container belongs; name the plurality of mounted 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 plurality of mounted files; and fill the directory structure based on the file names of the plurality of mounted files, to obtain a file directory.

[0106] Embodiment 3

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

[0108] Embodiment 4

[0109] According to the embodiments of the present application, a computer readable storage medium is further provided, comprising a stored executable program, wherein the executable program is configured to control a device where the computer readable storage medium is located to execute the file downloading method of the container in the embodiments of the present application when executed.

[0110] The above-mentioned embodiment numbers of the present application are only for description, and do not represent the advantages or disadvantages of the embodiments.

[0111] In the above-mentioned embodiments of the present application, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.

[0112] In several embodiments provided in the present application, it should be understood that the disclosed technical contents can be implemented by other manners. Among them, the above-mentioned device embodiments are only schematic, for example, the division of the units can be a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed units can be indirect coupling or communication connection through some interfaces, units or modules, which can be electrical or other forms.

[0113] The units described as separate components can or can not be physically separated, and the components displayed as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of units. According to actual needs, part or all of the units can be selected to achieve the purpose of the embodiment scheme.

[0114] In addition, each function unit in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software function unit.

[0115] When the integrated unit is realized in the form of a software function 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 solutions of the present application, essentially or the part that contributes to the prior art, or all or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application. The foregoing storage medium includes: a U disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store program codes.

[0116] The above is only the preferred embodiment of the present application, and it should be pointed out that for those skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, and these improvements and refinements should be considered as the protection scope of the present application.

Claims

1. A method of downloading a file of a container, characterized by, The method comprises: receiving a download request sent by a client through a first service, wherein the download request is used to request to download a target file generated by a target container; determining a target application instance from a plurality of 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, the second service provides an interface for downloading the target file, and the second service connects the client through the first service; downloading the target file through the target application instance based on file information of the target file carried in the download request; sending the target file to the client through a target interface corresponding to the target application instance; sending the target file to the client through a target interface corresponding to the target application instance, comprising: obtaining authentication information; the second service determines whether the authentication information matches the target interface corresponding to the target application instance using a key; in the case that the authentication information matches the target interface, sending the target file to the client through the target interface.

2. The container's file download method according to claim 1, wherein downloading the target file through the target application instance based on file information of the target file carried in the download request, comprising: obtaining file classification information corresponding to the target application instance; determining a file download address based on the file information of the target file and the file classification information; downloading the target file according to the file download address.

3. The container file download method of claim 1, wherein The method further comprises: deploying the second service on a plurality of nodes, wherein the nodes are used to manage at least one container; mounting a plurality of files generated by a plurality of containers based on the second service; classifying and aggregating the mounted plurality of files to obtain a file directory; associating and mapping the plurality of containers and the second service based on identification information of the plurality of nodes through the first service to obtain a mapping relationship table; storing the mapping relationship table in a database.

4. The container file download method of claim 3, wherein Deploying the second service on a plurality of nodes, comprising: determining a template of an application instance of the second service; creating a plurality of application instances of the second service based on the template; deploying the plurality of application instances to the plurality of nodes according to resource affinity rules through a scheduler.

5. The container file download method of claim 3, wherein Mounting a plurality of files generated by a plurality of containers based on the second service, comprising: configuring a data sharing mechanism for the second service; determining generation paths of the plurality of files based on the data sharing mechanism; mounting the plurality of files to target paths according to the generation paths of the plurality of files.

6. The container file download method of claim 3, wherein Classifying and aggregating the mounted plurality of files to obtain a file directory, comprising: determining a directory structure of the mounted plurality of files; obtaining a name of an application instance of the second service and a namespace to which the container belongs; naming the mounted plurality of 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 plurality of files; The directory structure is filled based on file names of the plurality of files after the mounting, and a file directory is obtained.

7. A container file downloading apparatus characterized by comprising: The method comprises the steps of: The receiving module is configured to receive a download request sent by a client through a first service, wherein the download request is used to request to download a target file generated by a target container; The determining module is configured to determine a target application instance from a plurality of 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, the second service provides an interface for downloading the target file, and the second service connects the client through the first service; The downloading module is configured to download the target file through the target application instance based on file information of the target file carried in the download request; The sending module is configured to send the target file to the client through a target interface corresponding to the target application instance. The sending module is further configured to obtain authentication information, and the second service determines whether the authentication information matches a target interface corresponding to the target application instance by using a key; and in a case where the authentication information matches the target interface, the target file is sent to the client through the target interface.

8. An electronic device, comprising: The memory stores an executable program. The processor is configured to run the program, and the program performs the container file downloading method in any one of claims 1 to 6 when running. The computer readable storage medium includes a stored executable program, wherein the executable program controls the device where the storage medium is located to perform the container file downloading method in any one of claims 1 to 6 when running.

9. A computer-readable storage medium, characterized in that, ​

Citation Information

Patent Citations

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

    CN117609161A