Container port management method, electronic device and storage medium

By predicting the port usage information of the container on the host and combining the host configuration information, dynamically allocating ports to the container, the problem of container port occupation in high-performance computing scenarios is solved, and the container operation stability and port utilization are improved.

CN119225910BActive Publication Date: 2025-02-25TIANJIN TIANHE COMPUTER TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411722447.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2025-02-25
Estimated Expiration
2044-11-28

AI Technical Summary

Technical Problem

In high-performance computing scenarios, although the host mode of the container can improve network performance, it will lead to host port occupation, resulting in efficient and automated port allocation solutions in automated deployment and large-scale container management.

Method used

By predicting future port usage information based on the historical operation data of the target container on the host, and determining the attribute information of the port to be allocated based on the configuration information of the host, the target container dynamically allocates appropriate ports.

Benefits of technology

Automatic and accurate port allocation of the target container is achieved, reasonable allocation of host ports is improved, and the operation stability of the target container is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000_ABST
    Figure 00000000_0000_ABST
Patent Text Reader

Abstract

The present application provides a container port management method, an electronic device and a storage medium, the container port management method comprising: predicting the use information of the target container for the target host port in the future according to the historical operation data of the target container on the target host; determining the attribute information of the port to be allocated according to the configuration information of the target host; allocating the port to the target container according to the attribute information of the port to be allocated and the usage information. This is conducive to the reasonable allocation of the ports of the target host and improving the operation stability of the target container.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a container port management method, an electronic device, and a storage medium. Background Art

[0002] With the popularization of HPC (High Performance Computing) scientific computing applications, more and more users from all walks of life are using HPC clusters for computing.

[0003] Existing HPC systems widely use containers to dynamically deploy services. In high-performance computing scenarios, there are high requirements for network performance. Therefore, some services need to use the host mode of the container (because using the host mode of the container can improve the network performance of the service to a certain extent), especially in scenarios that require higher network performance and lower latency. However, the host mode of the container will occupy the host port, so an efficient and automated port allocation solution is needed in automated deployment and large-scale container management.

[0004] Therefore, this application is specially filed. Summary of the invention

[0005] In view of this, the purpose of the present application is to propose a container port management method, an electronic device and a storage medium, which realizes the purpose of automatically allocating ports to the target container, is conducive to the reasonable allocation of ports of the target host machine, and improves the operating stability of the target container.

[0006] Based on the above objectives, in a first aspect, the present application provides a container port management method, comprising:

[0007] Predicting usage information of the target host port by the target container in the future according to historical running data of the target container on the target host;

[0008] Determining attribute information of the port to be allocated according to the configuration information of the target host machine;

[0009] A port is allocated to the target container according to the attribute information of the port to be allocated and the usage information.

[0010] Further, the future time includes multiple time points, and the prediction of usage information of the target host port by the target container at the future time based on the historical running data of the target container on the target host includes:

[0011] Predicting the number of ports occupied at each future time point based on historical running data of the target container on the target host;

[0012] Determine the maximum value of the number of ports occupied at each time point in the future as a target value;

[0013] determining the target value as the usage information;

[0014] Correspondingly, allocating a port to the target container according to the attribute information of the port to be allocated and the usage information includes:

[0015] A number of ports equal to the target value is allocated to the target container.

[0016] Further, the future time includes multiple time points, and the prediction of usage information of the target host port by the target container at the future time based on the historical running data of the target container on the target host includes:

[0017] Predicting the number of ports occupied at each future time point according to historical operation data of the target container on the target host, and determining the number of ports occupied at each future time point as the usage information;

[0018] Correspondingly, allocating a port to the target container according to the attribute information of the port to be allocated and the usage information includes:

[0019] According to the attribute information of the port to be allocated and the number of ports occupied at each time point, a port is dynamically allocated to the target container at a corresponding time point.

[0020] Furthermore, dynamically allocating ports to the target container at a corresponding time point according to the attribute information of the port to be allocated and the number of ports occupied at each time point includes:

[0021] In response to the attribute information of the to-be-allocated ports indicating that the to-be-allocated ports of the target host machine have been exhausted, determining the free ports of each service to which the ports have been allocated, wherein one service corresponds to one container;

[0022] The service with the most idle ports is determined as a candidate service;

[0023] Allocate the idle port of the candidate service to the target container.

[0024] Furthermore, it also includes:

[0025] Monitor the allocated ports;

[0026] In response to determining that the allocated port has not received the request information within a preset time period, the allocated port is marked as a port to be allocated.

[0027] Furthermore, it also includes:

[0028] Determine, based on historical running data of each target container on the target host, an expected time and probability of exhaustion of ports to be allocated on the target host;

[0029] In response to the time interval between the expected moment and the current moment being less than a time threshold and the probability being greater than a probability threshold, an alarm is issued.

[0030] Furthermore, the target host machine runs multiple containers simultaneously, and the method further includes:

[0031] In response to detecting a conflicting port, processing the conflicting port based on a preset strategy;

[0032] Among them, ports occupied by multiple containers at the same time are conflicting ports.

[0033] Further, the processing of the conflicting port based on a preset strategy includes:

[0034] Close multiple containers that occupy conflicting ports;

[0035] Alternatively, according to respective priorities of multiple containers occupying the conflicting ports, the container with the highest priority is retained;

[0036] Or, control the restart of multiple containers occupying conflicting ports;

[0037] Alternatively, a conflict notification is sent to the associated administrator.

[0038] Based on the above purpose, in a second aspect, the present application also provides a container port management device, including:

[0039] A prediction module, used to predict usage information of the target container for the target host port in the future according to historical running data of the target container on the target host;

[0040] A determination module, used to determine the attribute information of the port to be allocated according to the configuration information of the target host machine;

[0041] The allocation module is used to allocate a port to the target container according to the attribute information of the port to be allocated and the usage information.

[0042] Based on the above purpose, in a third aspect, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the container port management method as described in the first aspect above is implemented.

[0043] Based on the above purpose, in a fourth aspect, the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the container port management method as described in any one of the first aspects above.

[0044] From the above, it can be seen that the container port management method provided by the present application can predict the usage information of the target container for the target host port in the future according to the historical operation data of the target container on the target host, and then allocate a port to the target container according to the usage information, thereby achieving the purpose of automatically and accurately allocating ports to the target container, which is conducive to the reasonable allocation of ports of the target host and improving the operation stability of the target container. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solutions in the present application or related technologies, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0046] Figure 1 A flow chart of a container port management method according to an embodiment of the present application Figure 1 ;

[0047] Figure 2 A flow chart of a container port management method according to an embodiment of the present application Figure 2 ;

[0048] Figure 3 A flow chart of a container port management method according to an embodiment of the present application Figure 3 ;

[0049] Figure 4 A flow chart of a container port management method according to an embodiment of the present application Figure 4 ;

[0050] Figure 5 A schematic diagram of a container port management device according to an embodiment of the present application Figure 1 ;

[0051] Figure 6 A schematic diagram of the working process of a port pre-allocation module according to an embodiment of the present application;

[0052] Figure 7 A schematic diagram of the workflow of a monitoring and early warning module according to an embodiment of the present application;

[0053] Figure 8 A schematic diagram of a container port management device according to an embodiment of the present application Figure 2 ;

[0054] Fig. 9 A schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0055] In order to make the objectives, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.

[0056] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should be the usual meanings understood by people with ordinary skills in the field to which the present application belongs. The "first", "second" and similar words used in the embodiments of the present application do not represent any order, quantity or importance, but are only used to distinguish different components. "Including" or "comprising" and similar words mean that the elements or objects appearing in front of the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0057] It should be noted that the method of the embodiment of the present application can be performed by a single device, such as a computer or server. The method of this embodiment can also be applied to a distributed scenario and completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices can only perform one or more steps in the method of the embodiment of the present application, and the multiple devices will interact with each other to complete the described method.

[0058] It should be noted that the above describes some embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the above embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0059] Embodiment 1

[0060] In some embodiments, Figure 1A flow chart of a container port management method is shown. The container port management method can be executed by a container port management device. The container port management device can be implemented in the form of software and / or hardware and can be integrated in a high-performance computer or used in a server for coordinating and managing a high-performance computer cluster. Figure 1 As shown, the container port management method includes the following steps:

[0061] S110: Predict usage information of the target container for the target host port in the future according to historical operation data of the target container on the target host.

[0062] Optionally, a machine learning or statistical analysis method is used to predict usage information of the target host port by the target container in the future based on historical operation data of the target container on the target host.

[0063] In some embodiments, the historical operation data includes usage information of the target host machine port when the target container is running on the target host machine. For example, starting from the time when the target container is first started on the target host machine, the number of ports occupied by it is recorded at a preset frequency (i.e., every certain period of time), and the number of ports occupied at different times is determined as the usage information of the target host machine port by the target container at different time points in the future.

[0064] Exemplarily, the future time includes multiple time points, and the predicting, based on the historical running data of the target container on the target host, usage information of the target host port by the target container at the future time includes:

[0065] According to the historical operation data of the target container on the target host, the number of ports occupied at each time point in the future is predicted; the maximum value of the number of ports occupied at each time point in the future is determined as the target value; the target value is determined as the usage information; correspondingly, the ports are allocated to the target container according to the attribute information of the ports to be allocated and the usage information, including: allocating ports with the target value to the target container. That is, a maximum value is first determined, and the ports with the maximum value are pre-allocated to the target container. By pre-allocating the ports with the maximum value of the number of ports occupied at different time points to the target container, it can be ensured that the container has sufficient ports available at any time point, thereby improving the performance of the container. By referring to the historical operation data of the target container on the target host, the number of ports occupied at each time point in the future is predicted, and the accuracy of determining the number of ports can be improved. Compared with allocating the number of ports based on experience, this method is more objective, more explainable, and more suitable for the automatic allocation of ports scenario.

[0066] In other embodiments, the future time includes multiple time points, and the target container is predicted to use the target host port in the future time according to the historical operation data of the target container on the target host, including: predicting the number of ports occupied at each time point in the future according to the historical operation data of the target container on the target host, and determining the number of ports occupied at each time point in the future as the usage information; correspondingly, allocating ports to the target container according to the attribute information of the port to be allocated and the usage information, including: dynamically allocating ports to the target container at the corresponding time point according to the attribute information of the port to be allocated and the number of ports occupied at each time point, that is, not pre-allocating ports, but dynamically allocating ports. By adopting the method of dynamically allocating ports, the flexibility of each port can be improved, the utilization rate of the port can be improved, and the port can be avoided from being pre-allocated by a container but not being used, that is, being allocated but in an idle state, which hinders other containers from continuing to use, thereby causing the problem of low port utilization. By referring to the historical operation data of the target container on the target host, the number of ports occupied at each time point in the future can be predicted, and the accuracy of determining the number of ports can be improved.

[0067] Furthermore, dynamically allocating ports to the target container at a corresponding time point according to the attribute information of the port to be allocated and the number of ports occupied at each time point includes:

[0068] In response to the attribute information of the to-be-allocated ports indicating that the to-be-allocated ports of the target host machine have been exhausted, the idle ports of each service that has been allocated ports are determined, wherein one service corresponds to one container; the service with the most idle ports is determined as a candidate service; and the idle ports of the candidate service are allocated to the target container. That is, when the to-be-allocated ports of the target host machine are exhausted, the allocated ports of each service running on the target host machine are balanced. If there are many idle ports among the allocated ports of a service, some ports are allocated from the allocated ports of the service to the target container, which not only ensures that other services are not affected, but also strives for available ports for the target container, thereby improving the rationality of port allocation and port utilization.

[0069] It is understandable that a service will create containers for multiple users. These multiple containers all provide the same service, but because the users are different, the configuration inside the container is slightly different. Therefore, port allocation for the container is actually port allocation for the service in the container.

[0070] In some implementations, the historical operation data includes the usage information of the target host port by the service corresponding to the target container during the operation period and the network activity mode at that time, wherein the network activity mode includes host mode, bridge mode, overlay mode, macvlan mode, and none mode.

[0071] In host mode, the container does not have an independent network namespace, but directly uses the network namespace of the host. The container and the host share the network stack, including IP addresses, ports, network interfaces, etc. The container can directly use the network resources of the host and provide services to the outside world without performing operations such as port mapping.

[0072] In bridge mode, the container is connected to the host's network namespace through a Linux virtual bridge. Each container has an independent network stack. Containers can access each other through IP addresses and provide external services through the host's IP address and port mapping.

[0073] The overlay mode is usually used for cross-host container network communication. It creates a virtual network overlay between multiple hosts, allowing containers to communicate on different hosts. The macvlan mode connects the container directly to the physical network, and each container has an independent MAC address. In none mode, the container has no network connection and can only communicate with other containers on the same host through inter-process communication or other means.

[0074] Different network activity modes have different port usage rules and laws. Therefore, by analyzing the usage information of the target host port by the service corresponding to the target container during the operation cycle and the network activity mode at that time, the association between the network activity mode and the port usage information can be determined. Further, when predicting the usage information of the target host port by the target container in the future time based on the historical operation data of the target container on the target host, the network activity mode of the target container in the future time can be determined first, and then the corresponding port usage information can be determined based on the association between the network activity mode and the port usage information. Among them, the port usage information can specifically be the number of occupied ports, the range of port segments, etc. Correspondingly, the port is allocated to the target container according to the attribute information of the port to be allocated and the usage information, including: allocating the number of ports and port types that match the current network activity mode to the target container. The port type is, for example, a TCP (Transmission Control Protocol) port or a UDP (User Datagram Protocol) port.

[0075] S120. Determine attribute information of the port to be allocated according to the configuration information of the target host machine.

[0076] Among them, the configuration information of the target host is used to indicate which ports and port types the target host has, which ports are dedicated to special services, and which ports are freely assignable by users. For example, port 80 is usually used for HTTP and is the standard port for communication between Web servers and browsers. Port 443 is used for HTTPS, which provides encrypted Web communications, and port 22 is used for SSH, which is used for remote login and management of servers. This information all belongs to the category of configuration information. By referring to the configuration information of the target host, the attribute information of the port to be assigned can be determined, such as the port number, port segment, and port type.

[0077] S130: Allocate a port to the target container according to the attribute information of the port to be allocated and the usage information.

[0078] For example, the attribute information of the ports to be allocated indicates that the ports in the port segment 49152-65535 are the ports to be allocated, and the usage information indicates that 10 ports are needed, so 10 ports are determined from 49152-65535 to be allocated to the target container.

[0079] A general HPC system will contain multiple services, so it is necessary to pre-allocate the host's port range to these services so that each service can obtain the required port within its own port range. This can greatly reduce conflicts, as follows: First, define a series of available port segments based on the host's network configuration and the existing service port usage. These port segments can be continuous or discrete and are configured according to actual needs. Secondly, use machine learning and statistical analysis methods, combined with historical deployment data (because HPC systems are often deployed privately, historical data will be accumulated when the same system is deployed again) and current network activity patterns to predict the type and number of ports that may be needed in the future. This predictive capability helps to more reasonably plan the allocation of port segments to meet the upcoming container deployment needs.

[0080] The container port management method provided in the embodiment of the present application can predict the usage information of the target container for the target host port in the future according to the historical operation data of the target container on the target host, and then allocate a port to the target container according to the usage information, thereby achieving the purpose of automatically and accurately allocating ports to the target container, which is conducive to the reasonable allocation of ports of the target host and improving the operation stability of the target container.

[0081] Embodiment 2

[0082] Based on the above embodiment, this embodiment further optimizes the container port management method, specifically by adding a step of monitoring the allocated ports, so that when it is determined that the allocated ports are idle for a long time, the allocated ports are released in time for use by other containers, which can further improve the port utilization rate and the rationality of port allocation. Figure 2 As shown, the container port management method includes the following steps:

[0083] S210: Predict usage information of the target container for the target host port in the future based on historical operation data of the target container on the target host.

[0084] S220. Determine attribute information of the port to be allocated according to the configuration information of the target host machine.

[0085] S230: Allocate a port to the target container according to the attribute information of the port to be allocated and the usage information.

[0086] S240: Monitor the allocated port, and in response to determining that the allocated port does not receive request information within a preset time period, mark the allocated port as a port to be allocated.

[0087] Specifically, if an allocated port is idle for a long period of time, the port is released so that other services that need ports can obtain the port, thereby improving port utilization.

[0088] In some implementations, after the port is allocated, the usage of the allocated port segment is tracked, including the running status of the container, the activity of the port, and the possible port release time. If a port of a service does not receive requests for a long time, exceeding the set default time threshold, an alarm will be sent to the administrator, and the administrator can determine whether to close the container and release the port based on the alarm and the actual situation.

[0089] Based on the above embodiment, this embodiment adds a step of monitoring the allocated port, so that when it is determined that the allocated port is idle for a long time, the allocated port is released in time for use by other containers, which can further improve the port utilization rate and the rationality of port allocation.

[0090] Embodiment 3

[0091] Based on the above embodiment, this embodiment further optimizes the container port management method, specifically by adding a port conflict handling step to solve the port conflict problem, improve the rationality of port allocation, and improve the operation stability of each container. Figure 3 As shown, the container port management method includes the following steps:

[0092] S310: Predict usage information of the target container for the target host port in the future based on historical operation data of the target container on the target host.

[0093] S320. Determine attribute information of the port to be allocated according to the configuration information of the target host machine.

[0094] S330: Allocate a port to the target container according to the attribute information of the port to be allocated and the usage information.

[0095] S340: In response to detecting a conflicting port, process the conflicting port based on a preset policy.

[0096] Wherein, multiple containers are running on the target host machine at the same time, and ports occupied by multiple containers at the same time are conflicting ports.

[0097] Exemplarily, the processing of the conflicting port based on a preset strategy includes:

[0098] Shut down all the multiple containers occupying the conflicting ports; or, retain the container with the highest priority according to the respective priorities of the multiple containers occupying the conflicting ports; or, control the multiple containers occupying the conflicting ports to restart; or, send a conflict notification to the associated administrator.

[0099] Based on the above embodiments, this embodiment adds a port conflict processing step, solves the port conflict problem, and improves the intelligence and rationality of port allocation, as well as the operation stability of each container.

[0100] Embodiment 4

[0101] Based on the above embodiment, this embodiment further optimizes the container port management method, specifically by adding a port alarm step to promptly alarm when the port is about to be exhausted, reminding relevant personnel to intervene, thereby ensuring the normal operation of each container service. Figure 4 As shown, the container port management method includes the following steps:

[0102] S410: Predict usage information of the target container for the target host port in the future based on historical operation data of the target container on the target host.

[0103] S420: Determine attribute information of the port to be allocated according to the configuration information of the target host machine.

[0104] S430: Allocate a port to the target container according to the attribute information of the port to be allocated and the usage information.

[0105] S440. Determine the expected time and probability of exhaustion of the ports to be allocated on the target host machine according to the historical operation data of each target container on the target host machine; and issue an alarm in response to the time interval between the expected time and the current time being less than a time threshold and the probability being greater than a probability threshold.

[0106] Specifically, based on the historical running data of each target container on the target host, the number of ports required by each target container at each future time point is predicted, and the number of ports required by each target container is added to obtain the total number of required ports. If the total number of ports corresponding to a certain time point is greater than the total number of allocable ports of the target host, the certain time point is determined as the expected moment when the to-be-allocated ports on the target host are exhausted.

[0107] Optionally, use machine learning and statistical analysis methods in combination with historical operation data to analyze the port occupancy frequency and future trends of each service, determine the expected time and probability of exhaustion of the number of available ports, and send relevant alarms to administrators. Administrators can manually adjust the number of available ports for each service based on the alarms, thereby achieving reasonable allocation of ports and improving container operation stability.

[0108] In some implementations, for a target container, based on its historical operation data, the number of ports occupied at different times is counted to generate a port number change curve, and based on the port number change curve, a cyclically appearing curve segment is determined, or a periodic curve segment is determined, and the periodic curve segment is used as a regular curve of the port occupation of the target container. The above operation is performed for each target container, so that the regular curve of the port occupation of each target container can be obtained. Based on the regular curve, combined with the number of ports occupied at the current moment, the number of ports occupied at the next moment can be predicted, thereby realizing a port exhaustion alarm.

[0109] Furthermore, when generating the target container's port occupation regularity curve, the target container's operating status at each moment can be synchronously recorded, and then the operating status of a target container at the current moment is matched with the recorded historical operating status, and the historical operating status closest to the operating status at the current moment is found. According to the closest historical operating status and the number of ports occupied at the current moment, a reference point is located from the occupation regularity curve, and the curve segment after the reference point in the occupation regularity curve is used as the trend of the number of ports occupied by the target container in the future period after the current moment. According to the above method, the number of ports occupied by each target container in the future period can be predicted, and when the sum of the number of ports occupied by each target container is greater than the number of ports to be allocated on the target host, an alarm is issued.

[0110] Embodiment 5

[0111] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a container port management device.

[0112] refer to Figure 5 , the container port management device comprises:

[0113] The prediction module 510 is used to predict the usage information of the target container for the target host port in the future based on the historical operation data of the target container on the target host; the determination module 520 is used to determine the attribute information of the port to be allocated based on the configuration information of the target host; the allocation module 530 is used to allocate the port to the target container based on the attribute information of the port to be allocated and the usage information. Figure 6 The workflow diagram of a port pre-allocation module shown specifically includes: 610, obtaining basic information of the host machine; 620, obtaining all available idle ports and classifying them; 630, analyzing the port usage of each sub-service in combination with historical data; 640, predicting the number and type of ports required in the future; 650, planning and allocating port segments.

[0114] Furthermore, the container port management device also includes: a port conflict detection module: responsible for the conflict detection processing of the target port and obtaining the free port. Specifically, a conflict resolution policy library is established, which contains a variety of strategies for resolving port conflicts, such as automatic retry, notification to users, stopping conflicting services, etc. Users can also add custom policies, such as self-set priorities for conflicting services, etc. According to the specific circumstances of the conflict, the most appropriate solution is selected from the policy library. If a port conflict occurs and the free ports are exhausted, if the current service priority is higher, then according to the service priority policy in the policy library, the low-priority container service is closed and the port is released for use by the high-priority container service; if the service priority is lower, then according to the service priority policy in the policy library, it is necessary to wait for the high-priority service to release the port before deployment. If there is a custom policy, the conflict is handled according to the custom policy.

[0115] Dynamic firewall rule update module: After the port mapping is adjusted, the firewall rules of the host are automatically updated to ensure that the new port mapping can be correctly identified and allowed. Use tools such as iptables to add or modify firewall rules to allow or deny access to specific ports. Logging module: Records the specific operations of other modules for problem tracing and optimization. User interaction interface: Provides a user interaction interface that allows users to view the current port usage of the host, the port mapping status of the container, and the progress of conflict resolution. Users can manually adjust port mappings, select conflict resolution strategies, or view detailed conflict logs through the interface. Provide standardized external interfaces: Publish the platform with RESTful standardized and normalized interfaces to provide high-performance and stable port management services for HPC application development platforms.

[0116] Before deploying the container, the port detection script will be executed to check the occupancy of the host target port. If it is found to be occupied, the port occupancy record in the database will be updated, and the available ports will continue to be obtained and detected. The container can be deployed only after a free port is detected.

[0117] Dynamic adjustment module: responsible for the dynamic adjustment of port segments. If an emergency causes the available ports of a service to be exhausted, the module will select some ports from the unallocated free port range to add to the available port range of the service. If all ports have been allocated to other services, it will scan the available port ranges of each service, select the service with the most free ports, and select some ports from the ports of the service to use. At the same time, the operation will be recorded in the log to facilitate the subsequent optimization of the operation process.

[0118] Monitoring and early warning module, the specific composition of this module can be found in Figure 7, specifically including available port warning 710, scheduled scanning of port occupancy 720, updating database data 730, machine learning and statistical analysis 740, analyzing the port occupancy frequency of each sub-service 750, predicting the time when the number of available ports will be exhausted 760, reminding the occupied ports to be inactive 770, tracking the usage of the allocated port segments 780, whether the time when the port does not receive requests exceeds the threshold 790, and administrator 800. The specific process includes scheduled scanning of port occupancy, updating the port usage records of each service in the database. According to the updated port usage records, using machine learning and statistical analysis methods, combined with historical data, analyze the port occupancy frequency and future trends of each service, determine the expected time and probability of the number of available ports being exhausted, and send relevant alarms to the administrator, who can manually adjust the number of available ports of each sub-service according to the alarm. At the same time, the usage of the allocated port segments will be tracked, including the running status of the container, the activity of the port, and the possible port release time. If a port of a service does not receive requests for a long time, exceeding the default time threshold, an alarm will be sent to the administrator, who can determine whether to close the container and release the port based on the alarm and the actual situation.

[0119] Based on the above modules, refer to Figure 8 The schematic diagram of the structure of a container port management device is shown. Specifically, it includes: a monitoring and warning module 810, the functions of which specifically include occupied inactive port reminders 820, available port exhaustion alarms 830, and administrator processing 840; a port pre-allocation module 850; a port conflict detection module 860, which is implemented based on a conflict resolution strategy library 870; creating a container service 880, specifically, obtaining a port from a port segment 890, updating firewall rules 900, service creation success 910, and a dynamic firewall rule update module 920.

[0120] For the convenience of description, the above device is described in terms of functions divided into various modules. Of course, when implementing the present application, the functions of each module can be implemented in the same or multiple software and / or hardware.

[0121] The device of the above embodiment is used to implement the corresponding container port management method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.

[0122] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the container port management method described in any of the above embodiments is implemented.

[0123] Fig. 9A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, and the device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other through the bus 1050 in the device.

[0124] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0125] The memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.

[0126] The input / output interface 1030 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.

[0127] The communication interface 1040 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0128] The bus 1050 includes a path that transmits information between the various components of the device (eg, the processor 1010 , the memory 1020 , the input / output interface 1030 , and the communication interface 1040 ).

[0129] It should be noted that, although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.

[0130] The electronic device of the above embodiment is used to implement the corresponding container port management method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.

[0131] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, the present application also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the container port management method described in any of the above embodiments.

[0132] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.

[0133] The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the container port management method described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0134] A person skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present application (including the claims) is limited to these examples. In line with the concept of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.

[0135] In addition, to simplify the description and discussion, and in order not to make the embodiments of the present application difficult to understand, the known power / ground connections to the integrated circuit (IC) chip and other components may or may not be shown in the provided drawings. In addition, the device may be shown in the form of a block diagram to avoid making the embodiments of the present application difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform on which the embodiments of the present application are to be implemented (that is, these details should be fully within the scope of understanding of those skilled in the art). Where specific details (e.g., circuits) are set forth to describe exemplary embodiments of the present application, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details or with changes in these specific details. Therefore, these descriptions should be considered illustrative rather than restrictive.

[0136] Although the present application has been described in conjunction with specific embodiments of the present application, many alternatives, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the discussed embodiments.

[0137] The embodiments of the present application are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the scope of protection of the present application.

Claims

1. A container port management method, characterized in that: include: Predicting usage information of the target host port by the target container in the future according to historical running data of the target container on the target host; Determining attribute information of the port to be allocated according to the configuration information of the target host machine; Allocating a port to the target container according to the attribute information of the port to be allocated and the usage information; The future time includes multiple time points, and the prediction of usage information of the target host port by the target container at the future time based on the historical running data of the target container on the target host includes: Predicting the number of ports occupied at each future time point based on historical running data of the target container on the target host; Determine the maximum value of the number of ports occupied at each time point in the future as a target value; determining the target value as the usage information; Correspondingly, allocating a port to the target container according to the attribute information of the port to be allocated and the usage information includes: Allocating a number of ports equal to the target value to the target container; Alternatively, based on historical operation data of the target container on the target host, the number of ports occupied at each time point in the future is predicted, and the number of ports occupied at each time point in the future is determined as the usage information; Correspondingly, allocating a port to the target container according to the attribute information of the port to be allocated and the usage information includes: Dynamically allocating ports to the target container at a corresponding time point according to the attribute information of the port to be allocated and the number of ports occupied at each time point; Determine, based on historical running data of each target container on the target host, an expected time and probability of exhaustion of ports to be allocated on the target host; In response to the time interval between the expected moment and the current moment being less than a time threshold and the probability being greater than a probability threshold, an alarm is issued.

2. The container port management method according to claim 1, characterized in that: The dynamically allocating ports to the target container at a corresponding time point according to the attribute information of the port to be allocated and the number of ports occupied at each time point includes: In response to the attribute information of the to-be-allocated ports indicating that the to-be-allocated ports of the target host machine have been exhausted, determining the free ports of each service to which the ports have been allocated, wherein one service corresponds to one container; The service with the most idle ports is determined as a candidate service; Allocate the idle port of the candidate service to the target container.

3. The container port management method according to claim 1, characterized in that: Also includes: Monitor the allocated ports; In response to determining that the allocated port has not received the request information within a preset time period, the allocated port is marked as a port to be allocated.

4. The container port management method according to claim 1, characterized in that: The target host machine runs multiple containers simultaneously, and the method further includes: In response to detecting a conflicting port, processing the conflicting port based on a preset strategy; Among them, ports occupied by multiple containers at the same time are conflicting ports.

5. The container port management method according to claim 4, characterized in that: The processing of the conflicting ports based on a preset strategy includes: Close multiple containers that occupy conflicting ports; Alternatively, according to respective priorities of multiple containers occupying the conflicting ports, the container with the highest priority is retained; Or, control the restart of multiple containers occupying conflicting ports; Alternatively, send a conflict notification to the associated administrator.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the container port management method according to any one of claims 1 to 5 is implemented.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the container port management method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Port resource allocation method and device, equipment, storage medium and program product

    CN118426937A