IP address allocation method and device of container unit, equipment and medium
By allocating fixed IP addresses to container units in a cloud-native network and dispatching them to designated nodes, the communication problems caused by dynamic changes in container units' IP addresses are solved, and stability and resource utilization efficiency in containerized environments are achieved.
Patent Information
- Application Number
- CN202510504726.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-21
- Publication Date
- 2025-07-01
AI Technical Summary
In large-scale containerized environments, dynamic changes in the IP address of container units often lead to communication problems with upstream systems and external services, affecting the stability of business processes.
Add a first fixed identifier and a second fixed identifier to the application configuration file of the cloud native network, assign a fixed IP address to the container unit using a designated IP pool, and determine the target computing node based on the available fixed IP addresses to realize the fixed IP address allocation and scheduling of the container unit.
Through the allocation and scheduling of fixed IP addresses, the container unit is ensured to run on the designated node, the rational utilization of node resources is realized, and the stability of business processes and network stability is improved.
Smart Images

Figure CN120238519A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of cloud computing, and particularly to a method, device, equipment and medium for allocating IP addresses of container units. Background Art
[0002] With the wide application of containerization technology, the number of containers and resource requirements are constantly changing, which requires network resources to be dynamically allocated according to the real-time needs of containers to avoid network congestion or resource waste. Generally, container units use IP addresses to identify devices or users. By managing the IP addresses of container units, network connection and data transmission can be achieved. Without reasonable IP address allocation, container units cannot be recognized and accessed in the cloud-native network, and their functions cannot be realized.
[0003] In related technologies, in a large-scale containerized environment, the IP address allocation of container units depends on a predefined IP pool. Here, the predefined IP pool usually determines the allocation strategy of container units when the network is deployed. However, the network topology in the containerized environment is complex and changeable, and the dynamic change of the IP address of the application system often causes communication problems with upstream systems and external services, affecting the stability of the business process. Summary of the Invention
[0004] The present invention provides a method, device, computer equipment and medium for allocating IP addresses of container units to solve the technical problem that the dynamic change of the IP address of the application system in related technologies often causes communication problems with upstream systems and external services, affecting the stability of the business process.
[0005] In a first aspect, a method for allocating IP addresses of container units is provided, including:
[0006] Adding a first fixed identifier and a second fixed identifier to the application configuration file in the cloud-native network, where the first fixed identifier is used to allocate a fixed IP address for the container unit, and the second fixed identifier is used to allocate a fixed IP address for the container unit in a specified IP pool. Different IP address segments corresponding to computing nodes are pre-stored in the specified IP pool, and the fixed IP address is started on the computing node;
[0007] When the cloud-native network creates an application program for the first time, selecting an available fixed IP address from the specified IP pool and allocating it to the newly created container unit of the application program;
[0008] Determining the target computing node for deploying the application program according to the available fixed IP address, so as to schedule the newly created container unit to the target computing node, and the available fixed IP address is located in the IP address segment corresponding to the target computing node.
[0009] In a second aspect, there is provided an IP address allocation device for a container unit, including:
[0010] An adding module, configured to add a first fixed identifier and a second fixed identifier to an application configuration file in a cloud-native network, where the first fixed identifier is used to allocate a fixed IP address for the container unit, and the second fixed identifier is used to allocate a fixed IP address for the container unit in a specified IP pool. Different IP address segments corresponding to different computing nodes are pre-stored in the specified IP pool, and the fixed IP address is started on the computing node.
[0011] An allocating module, configured to select an available fixed IP address from the specified IP pool and allocate it to a newly created container unit of an application when the cloud-native network creates an application for the first time.
[0012] A determining module, configured to determine a target computing node for deploying the application according to the available fixed IP address, so as to schedule the newly created container unit to the target computing node, where the available fixed IP address is located in the IP address segment corresponding to the target computing node.
[0013] In a third aspect, there is provided a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above-mentioned IP address allocation method for a container unit are implemented.
[0014] In a fourth aspect, there is provided a computer-readable storage medium storing a computer program, where when the computer program is executed by a processor, the steps of the above-mentioned IP address allocation method for a container unit are implemented.
[0015] In the solution implemented by the above IP address allocation method, device, computer device, and storage medium for container units, the first fixed identifier and the second fixed identifier can be added to the application configuration file of the cloud-native network. The first fixed identifier is used to allocate a fixed IP address for the container unit, and the second fixed identifier is used to allocate a fixed IP address for the container unit in the specified IP pool. Different IP address segments corresponding to different computing nodes are pre-stored in the specified IP pool, and the fixed IP address is started on the computing node. When the cloud-native network creates an application for the first time, an available fixed IP address is selected from the specified IP pool and allocated to the newly created container unit of the application. The target computing node for the application deployment is determined according to the available fixed IP address, so as to schedule the newly created container unit to the target computing node. The available fixed IP address is located in the IP address segment corresponding to the target computing node. In the present invention, the IP address of the container unit in the cloud-native network is allocated through the specified IP pool, and the fixed IP address allocation of the container unit is realized. The container unit can be scheduled to the specified node through the fixed IP address, so that the node resources are reasonably utilized to better meet the requirements of the large-scale containerized environment and ensure the stability of the business process. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0017] Figure 1 is a schematic diagram of an application environment of the IP address allocation method for container units in an embodiment of the present invention;
[0018] Figure 2 is a schematic flowchart of the IP address allocation method for container units in an embodiment of the present invention;
[0019] Figure 3 is Figure 1 a schematic flowchart of a specific implementation manner of step S10 in
[0020] Figure 4 is a schematic flowchart of the IP address allocation method for container units in another embodiment of the present invention;
[0021] Figure 5 is a schematic flowchart of the IP address allocation method for container units in another embodiment of the present invention;
[0022] Figure 6 is a schematic flowchart of the IP address allocation method for container units in another embodiment of the present invention;
[0023] Figure 7 It is a schematic flowchart of a method for allocating IP addresses of container units in another embodiment of the present invention;
[0024] Figure 8 It is a schematic structural diagram of an apparatus for allocating IP addresses of container units in an embodiment of the present invention;
[0025] Figure 9 It is a schematic structural diagram of a computer device in an embodiment of the present invention;
[0026] Figure 10 It is another schematic structural diagram of a computer device in an embodiment of the present invention. Detailed implementation manners
[0027] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0028] The method for allocating IP addresses of container units provided in the embodiments of the present invention can be applied to an application environment such as Figure 1 . Among them, the client adds a first fixed identifier and a second fixed identifier to the application configuration file of the cloud-native network. The first fixed identifier is used to allocate a fixed IP address for the container unit, and the second fixed identifier is used to allocate a fixed IP address for the container unit in a specified IP pool. Different IP address segments corresponding to computing nodes are pre-stored in the specified IP pool, and the fixed IP address is started on the computing node. When the cloud-native network creates an application for the first time, an available fixed IP address is selected from the specified IP pool and allocated to the newly created container unit of the application. The target computing node for deploying the application is determined according to the available fixed IP address, so as to schedule the newly created container unit to the server side of the target computing node. Here, the available fixed IP address is located in the IP address segment corresponding to the target computing node. In the present invention, the IP addresses of container units in the cloud-native network are allocated through a specified IP pool to achieve the allocation of fixed IP addresses for container units. Through the fixed IP address, the container unit can be scheduled to a specified node, so that the node resources can be reasonably utilized to better meet the requirements of a large-scale containerized environment and ensure the stability of the business process. Among them, the client may include, but is not limited to, various personal computers, laptop computers, smart phones, tablet computers, and portable wearable devices. The server side can be implemented by an independent server or a server cluster composed of multiple servers. The present invention will be described in detail through specific embodiments below.
[0029] Please refer toFigure 2 As shown Figure 2 This is a schematic flowchart of a method for allocating IP addresses for container units provided by an embodiment of the present invention, including the following steps:
[0030] S10: Add a first fixed identifier and a second fixed identifier to the application configuration file of the cloud-native network.
[0031] The method for allocating IP addresses for container units provided by the present invention can be applied in a containerized application environment. Each container unit may run different microservices or application components. For example, an e-commerce application may be split into multiple microservices such as user service, order service, and payment service, and each microservice is deployed in a container unit. To enable these container units to communicate with each other, independent IP addresses need to be allocated to each container unit so that different microservices can perform network communication through the IP addresses to ensure the normal operation of the entire application system. Here, a container unit is the smallest deployable computing unit in a node cluster, including one or more closely related containers. These containers usually share resources such as the same network namespace and storage volume and run on the same computing unit to achieve more efficient resource sharing and collaborative work. For example, a container unit contains a web application container and a database container, and the two containers communicate through the local network and share the storage volume to store data.
[0032] Among them, the first fixed identifier is used to allocate a fixed IP address for the container unit, and the second fixed identifier is used to allocate a fixed IP address for the container unit in a specified IP pool. Different IP address segments corresponding to computing nodes are pre-stored in the specified IP pool, and the fixed IP address is started on the computing node. Here, the computing node is a unit in the cloud-native network used to undertake computing tasks and can be a physical machine, a virtual machine, or a container, etc. A fixed IP address refers to an IP address that is allocated to a container unit in a network environment for a long term and remains stable. Compared with a dynamic IP address, a fixed IP address will not be automatically changed due to device restart, network connection change, or other factors.
[0033] Generally speaking, in order to adapt to changes in the network environment and meet system availability, the IP address of an application system may change dynamically, and the dynamic change of the IP address of the application system often causes communication problems with upstream systems and external services. For example, when the egress gateway application runs in a cloud environment, the dynamic change of its IP address will cause frequent adjustment of firewall policies. For example, when the container unit of the egress gateway is rebuilt or expanded, the new IP address needs to be updated to the firewall policy in a timely manner, otherwise it may cause network communication interruption or security policy failure. Such frequent IP address changes will increase the maintenance complexity of the firewall and even become a bottleneck in system performance, affecting overall availability. Also, for example, in some distributed systems, applications communicate with each other through IP addresses. If the IP address of the downstream application changes frequently, the upstream application needs to continuously update the configuration file or service discovery mechanism, increasing the complexity and maintenance cost of the system. In addition, some core applications are called by multiple systems, and the dynamic change of the IP address will affect the stable access of the upstream system, resulting in service interruption or performance degradation. In the embodiments of the present invention, a fixed IP deployment of the application system is performed by specifying an IP pool to ensure network stability and security.
[0034] In this embodiment, the address segment in the specified IP pool is usually associated with a specific computing node or node group, and each computing node has its corresponding IP address range, so as to ensure that the container units running on the computing node can obtain a fixed IP address from the corresponding address segment.
[0035] In a specific implementation scenario, the fixed IP assignment provides a fixed IP address for the container unit, ensuring that each container unit has a unique and stable identifier in the network, which is convenient for other devices to communicate. Among them, as Figure 3 shown, in step S10, that is, adding a first fixed identifier and a second fixed identifier to the application configuration file in the cloud native network, includes the following steps:
[0036] S11: Determine the metadata of the container unit in the application configuration file of the cloud native network.
[0037] S12: For the metadata of the container unit, identify that the container unit requires a fixed IP address and the container unit is assigned a fixed IP address in the specified IP pool by customizing and adding annotations and / or labels.
[0038] In this embodiment, the application configuration file of the cloud-native network is a file used to define how the cloud-native network operates and is configured in a container environment. It is usually written in a set format and contains configuration information in multiple parts. In the application configuration file, global parameters of the cloud-native network can be configured, such as network mode, IP address management method, and encryption options, etc. Parameters related to network proxies can also be configured, including the enabled state and working mode of the proxy. At the same time, network policies for the node cluster can be configured to determine whether to enable and whether to support custom policy resources.
[0039] Specifically, the application configuration file of the cloud-native network records the configuration information for connecting to the node cluster, enabling the cloud-native network to connect to the interface server of the node cluster. This is the basis for obtaining the metadata of the container unit. Then, the metadata of the specified container unit is obtained through the selector in the application configuration file. Here, filtering can be performed according to information such as the label and namespace of the container unit. For example, by setting a specific label selector, the cloud-native network can identify the container unit with a specific label and obtain the metadata of this container unit. This metadata includes information such as the name and creation time of the container unit. For the metadata of the container unit that needs to be assigned a fixed IP address, annotations and / or labels can be added customarily. For example, create a label named fixed-ip.requirement and set its value to true to indicate that this container unit requires a fixed IP address. Also, for example, create another label or annotation fixed-ip.pool and set its value to the specified IP pool name to indicate that this container unit is to obtain a fixed IP address from the specified IP pool. It should be noted that the annotations and / or labels here meet the format requirements of the cloud-native network.
[0040] S20: When the cloud-native network creates an application for the first time, select an available fixed IP address from the specified IP pool and assign it to the newly created container unit of the application.
[0041] In this embodiment, the designated IP pool is a pre-set one containing a series of IP addresses available for allocation. When the cloud-native network receives a request to create an application, it will check the IP addresses in the designated IP pool. At this time, the cloud-native network will maintain a record to track the allocation status of the IP addresses in the designated IP pool in order to check for available IPs. Usually, the cloud-native network selects them sequentially, or uses a certain random algorithm to select an available IP. Once a fixed available IP address is determined, the cloud-native network will bind this IP address to the newly created container unit of the application. After the binding, the cloud-native network will update its internal IP address usage record, marking this IP address as allocated, so that it will not be re-allocated when creating new container units later, and ensure that this container unit always uses this fixed IP address throughout its life cycle. If the container unit is rescheduled or restarted, the cloud-native network will ensure that it still uses the fixed IP address allocated previously.
[0042] It can be understood that considering the existing IP allocation situation in the current network and future possible expansion requirements, in order to ensure that the selected IP address range can meet the quantity requirements of the container units in the application, it is necessary to construct the designated IP address pool according to the actual requirements and network environment. Further, as Figure 4 shown, before step S20, the method further includes the following steps:
[0043] S40: Determine the fixed IP address range of the container unit according to the IP address architecture of the node cluster in the cloud-native network.
[0044] S50: Split the fixed IP address range of the container unit into IP address segments, and establish a mapping relationship between the IP address segments and different computing nodes.
[0045] S60: Construct a designated IP pool according to the mapping relationship between the IP address segments and different computing nodes, so that the container units can be scheduled to the corresponding computing nodes through the IP addresses in the designated IP pool.
[0046] In this embodiment, the IP address architecture of the node cluster in the cloud-native network is a multi-level structure. By reasonably allocating and managing different types of IP addresses, and configuring corresponding routing rules and network plugins, efficient communication and network isolation between the nodes, container units and services in the cluster are achieved.
[0047] As an implementable approach, the network policies of cloud-native networks define the rules and restrictions for network traffic. By viewing the network policy configurations, one can understand the network isolation and communication rules between different nodes and container units, and thereby infer the IP address architecture of the node clusters in the cloud-native network. For example, the network policy may specify that communication is allowed between container units within a specific IP address range or with specific labels. By analyzing these rules, one can determine the division and usage of IP addresses.
[0048] As another implementable approach, during the operation of cloud-native networks, logs are generated that record network-related operations and events. By analyzing these logs, information about IP address allocation, network connection establishment, etc. can be obtained, and thus the IP address architecture of the node clusters in the cloud-native network can be inferred. For example, the logs may record that a specific container unit is assigned a particular IP address, or the IP addresses used when network connections are established between nodes.
[0049] Specifically, based on the scale of the entire cluster and the resource situation of each computing node, the range of fixed IP addresses to be assigned to container units can be determined. For example, assume that the entire node cluster needs to support 1000 container units, and a relatively large IP address range of 192.168.1.0 / 24 needs to be planned.
[0050] Furthermore, after splitting the range of fixed IP addresses for container units into IP address segments, one or more IP address segments can be assigned to each computing node based on factors such as the performance of the computing node and the expected number of container units it will host. For example, a computing node with stronger performance and expected to run more container units can be assigned two IP address segments, while a physical machine with slightly weaker performance is assigned one IP address segment. Then, a mapping record of each IP address segment to the computing node is created, either by creating a table or recording in a configuration file the computing node corresponding to the IP address segment. For example, the IP address segment 192.168.1.0 - 192.168.1.99 corresponds to computing node A, and the IP address segment 192.168.1.100 - 192.168.1.199 corresponds to computing node B, etc.
[0051] Correspondingly, during the process of constructing a specified IP pool, based on the mapping relationship between IP address segments and different computing nodes, the configuration of the specified IP pool is carried out in the cloud-native network. Each address segment is added as an independent allocable resource to the specified IP pool, and the corresponding computing node information is associated with it.
[0052] It should be noted that when configuring the specified IP pool, some other relevant parameters need to be set, such as subnet mask, gateway, etc., to ensure that these parameters match the network configuration of the entire cluster, so as to ensure that the container unit can normally connect to the cluster network and other external networks through the specified IP address. After the configuration is completed, the specified IP pool can clarify the computing nodes corresponding to each IP address segment. When a newly created container unit needs to be assigned an IP address, an available IP address can be selected from the specified IP pool according to the scheduling policy, and the container unit can be scheduled to the corresponding computing node. For example, when a new container unit is created, the system will select an available computing node according to the resource requirements and scheduling algorithm of the container unit, and then select an available IP address from the IP address segment corresponding to the computing node and assign it to the container unit, so that the container unit can be scheduled to the corresponding computing node through the IP address in the specified IP pool.
[0053] Specifically, an address resource object can be created according to the mapping relationship between the IP address segment and different computing nodes, and the configuration information of the specified IP pool of the container unit is defined in the address resource object. Here, the configuration information includes the fixed IP address range of the container unit and the mapping relationship between different computing nodes and the IP address segment; the address resource object is referenced in the configuration file of the cloud-native network, so that the cloud-native network can read the configuration information of the specified IP pool of the container unit in the address resource object through the reference field.
[0054] In this embodiment, the address resource object is equivalent to a container for storing important configuration information related to the specified IP pool. The fixed IP address range of the container unit is recorded in detail in the address resource object, so that the system clearly knows the IP address range available for allocation. At the same time, the mapping relationship between different computing nodes and the IP address segment is clearly defined, so that the system can determine the allocable IP address segment corresponding to each computing node for subsequent IP address allocation and scheduling of the container unit. Further, a reference to the address resource object is added to the configuration file of the cloud-native network, which is equivalent to establishing an association between the configuration file and the address resource object, so that the cloud-native network can read the configuration information of the specified IP pool of the container unit in the address resource object through the reference field during startup or operation, including the fixed IP address range and the mapping relationship between the computing node and the IP address segment.
[0055] It can be understood that in order to keep the data consistent between different computing nodes, when the computing nodes in the node cluster need to obtain or update the IP address, the distributed key-value storage system can be used to record the IP address allocation information of the container unit to avoid network configuration errors caused by data inconsistency.
[0056] Furthermore, as Figure 5As shown, after step S20, the method further includes the following steps:
[0057] S70: Pack the available IP address and the network configuration information of the newly created container unit into a key-value pair and send it to the distributed key-value storage system to record the IP address allocation information of the container unit through the distributed key-value storage system;
[0058] Correspondingly, S80: When the node cluster in the cloud-native network triggers the reconstruction of the container unit, allocate the original fixed IP address to the corresponding container unit according to the IP address allocation information recorded in the distributed key-value storage system.
[0059] In this embodiment, the distributed key-value storage system is used for sharing and configuring service discovery, providing reliable data storage and coordination services for the node cluster. When a new container unit is created in the node cluster, the network plugin of the node cluster is responsible for allocating an available IP address to it. The allocation of this IP address is based on the pre-set network policies and address pool to ensure that the IP addresses in the node cluster do not conflict and comply with the network isolation. Once the IP address allocation is completed, the relevant IP address information, such as the IP address itself, subnet mask, gateway, etc., and other network configuration information related to the container unit will be organized together. Then these information will be packed into the form of a key-value pair. The key is usually a string that uniquely identifies the container unit, such as a name or UID, and the value is a data structure containing all the IP addresses and network configuration information. The generated key-value pair is sent to the distributed key-value storage system through the internal mechanism of the node cluster to record the IP address allocation information of the container unit and maintain the IP address allocation information of the container unit.
[0060] It can be understood that due to certain reasons, such as container unit failure, configuration change, etc., it is necessary to reconstruct the container unit. The relevant components in the node cluster will detect this reconstruction requirement. At this time, the system will immediately start the process of obtaining the original IP address allocation information of the container unit.
[0061] Next, the system will access the distributed key-value storage system. As a reliable distributed key-value storage system, the distributed key-value storage system has previously recorded the IP address allocation information of each container unit. The system will query in the distributed key-value storage system based on the unique identifier of the reconstructed container unit, such as the container unit name, UID, etc. Through this unique identifier, the system can accurately find the key-value pair corresponding to the reconstructed container unit, and the "value" part stored in this key-value pair contains the fixed IP address previously assigned to this container unit and related network configuration information, such as subnet mask, gateway, etc. After obtaining this information, the system will pass this network configuration information to the component responsible for allocating IP addresses to the reconstructed container unit, usually the network plugin of the cloud-native network. This network plugin will perform a series of operations at the network level based on the received information and configure the original fixed IP address to the reconstructed container unit.
[0062] During the configuration process, the network plugin will interact with network devices in the cluster, such as switches, to ensure that the newly configured IP address can be correctly identified and routed in the network. At the same time, it will also update the network connections and security policies related to this container unit to ensure that the reconstructed container unit can communicate normally with other container units and services with its previous network identity.
[0063] After the above operations, the reconstructed container unit will be assigned the original fixed IP address, so that it can continue to play its due role in the node cluster and will not affect the communication and cooperation between other components due to the change of the IP address.
[0064] In the actual application scenario, considering the continuous expansion of business requirements, the node cluster needs to newly create container units to meet the increasing business requirements. This requires allocating IP addresses for the newly created container units on the basis of the original IP address allocation. Further, as Figure 6 shown, after step S70, the method further includes the following steps:
[0065] S90: When the application needs to be scaled out, select an unused fixed IP address from the specified IP pool according to the IP address allocation information recorded in the distributed key-value storage system, and assign the unused fixed IP address to the container unit created by the scale-out.
[0066] In this embodiment, when the application needs to be scaled out, new container units need to be created. At this time, the component responsible for IP address allocation will start to work. It first queries the IP address information already allocated in the distributed key-value storage system. Since the distributed key-value storage system records the IP address information already allocated in the node cluster, including the IP address corresponding to each container unit and the relevant network configuration details, then, the IP address information already allocated in the distributed key-value storage system checks the IP addresses in the specified IP pool, selects unused fixed IP addresses in the specified IP pool. The unused fixed IP addresses are equivalent to unallocated IP addresses, and further allocates the unallocated IP addresses to the container units created by the scale-out.
[0067] In the actual application scenario, computing nodes may fail, which will affect the normal operation of the container units running on them. To avoid data loss, it is necessary to remove the container units from the computing nodes.
[0068] Further, as Figure 7 shown, after step S70, the method further includes the following steps:
[0069] S100: When the container unit is removed from the computing node, release the fixed IP address of the container unit back to the specified IP pool, and update the IP address allocation information corresponding to the released fixed IP address in the distributed key-value storage system, so that the released fixed IP address can be reused by other container units.
[0070] In this embodiment, when the container unit is removed from the computing node, the relevant network management component will identify the fixed IP address occupied by the container unit and unbind this IP address from the network configuration of the container unit. This released fixed IP address will be returned to the specified IP pool. The specified IP pool is a warehouse for storing available IP address segments, and all released IP addresses will return here to wait for reallocation. Next, the system will update the allocation information of this IP address in the distributed key-value storage system. Correspondingly, the system finds the key-value pair of the IP address allocation information corresponding to the previously removed container unit and updates the status therein to "unallocated" or "available", indicating that this IP address can be used by other container units.
[0071] Through the above steps, the released fixed IP address can re-enter the IP address allocation process. When a newly created container unit needs to be allocated an IP address subsequently, the system will query the distributed key-value storage system and the specified IP pool. If this released IP address is in an available state, it can be allocated to the new container unit, realizing the recycling of IP address resources, improving the resource utilization rate, and ensuring the reasonable allocation of IP addresses in the node cluster.
[0072] S30: Determine the target computing node for application deployment based on the available fixed IP addresses, so as to schedule the newly created container unit to the target computing node.
[0073] In this embodiment, the available fixed IP addresses are located in the IP address segment corresponding to the target computing node. That is to say, each available fixed IP address corresponds to a target computing node, so that the container unit can be scheduled to the target computing node. Specifically, there is a mapping relationship between the fixed IP address segment and the target computing node. Through this mapping relationship, the target computing node corresponding to the available IP address segment can be queried. If the available IP address segment corresponds to multiple target computing nodes, the target computing node with relatively lower load can be selected from the multiple target computing nodes according to the load balancing principle. For example, select the node with lower CPU usage and memory usage. Further, the newly created container unit is scheduled to the target computing node through the scheduler of the node cluster.
[0074] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The order of execution of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
[0075] In one embodiment, an IP address allocation device for a container unit is provided. The IP address allocation device for the container unit corresponds one-to-one with the IP address allocation method for the container unit in the above embodiment. As Figure 8 shown, the IP address allocation device for the container unit includes an adding module 101, an allocating module 102, and a scheduling module 103. The detailed descriptions of each functional module are as follows:
[0076] The adding module 101 is used to add a first fixed identifier and a second fixed identifier to the application configuration file in the cloud native network. The first fixed identifier is used to allocate a fixed IP address for the container unit, and the second fixed identifier is used to allocate a fixed IP address for the container unit in the specified IP pool. Different IP address segments corresponding to computing nodes are pre-stored in the specified IP pool, and the fixed IP address is started on the computing node;
[0077] The allocating module 102 is used to select available fixed IP addresses from the specified IP pool and allocate them to the newly created container units of the application when the cloud native network creates an application for the first time;
[0078] The scheduling module 103 is used to determine the target computing node for application deployment based on the available fixed IP addresses, so as to schedule the newly created container unit to the target computing node. The available fixed IP addresses are located in the IP address segment corresponding to the target computing node.
[0079] In one embodiment, the adding module is specifically configured to:
[0080] Determine the metadata of the container unit in the application configuration file of the cloud-native network;
[0081] For the metadata of the container unit, identify the requirement for a fixed IP address of the container unit and allocate a fixed IP address in the specified IP pool for the container unit by customizing and adding annotations and / or labels, where the annotations and / or labels meet the format requirements of the cloud-native network.
[0082] In one embodiment, the apparatus further includes:
[0083] A determining module, configured to determine the range of fixed IP addresses of the container unit according to the IP address architecture of the node cluster in the cloud-native network;
[0084] A establishing module, configured to split the range of fixed IP addresses of the container unit into IP address segments and establish a mapping relationship between the IP address segments and different computing nodes;
[0085] A constructing module, configured to construct a specified IP pool according to the mapping relationship between the IP address segments and different computing nodes, so that the container unit is scheduled to the corresponding computing node through the IP addresses in the specified IP pool.
[0086] In one embodiment, the constructing module is specifically configured to:
[0087] Create an address resource object according to the mapping relationship between the IP address segments and different computing nodes, and define the configuration information of the specified IP pool of the container unit in the address resource object, where the configuration information includes the range of fixed IP addresses of the container unit and the mapping relationship between different computing nodes and the IP address segments;
[0088] Reference the address resource object in the configuration file of the cloud-native network, so that the cloud-native network reads the configuration information of the specified IP pool of the container unit in the address resource object through the reference field.
[0089] In one embodiment, the apparatus further includes:
[0090] A storage module, configured to, when the cloud-native network creates an application for the first time, after selecting an available fixed IP address from the specified IP pool and allocating it to the container unit of the application, pack the available IP address and the network configuration information of the newly created container unit into a key-value pair and send it to the distributed key-value storage system, so as to record the IP address allocation information of the container unit through the distributed key-value storage system;
[0091] Correspondingly, the allocation unit is further configured to, when the node cluster in the cloud-native network triggers the reconstruction of the container unit, allocate the original fixed IP address to the corresponding container unit according to the IP address allocation information recorded in the distributed key-value storage system.
[0092] In one embodiment, the device further includes:
[0093] The scaling module is configured to, after sending the available IP address and the network configuration information of the newly created container unit to the distributed key-value storage system in a key-value pair, when the application needs to be scaled, select unused fixed IP addresses from the specified IP pool according to the IP address allocation information recorded in the distributed key-value storage system, and allocate the unused fixed IP addresses to the container units created by scaling.
[0094] In one embodiment, the device further includes:
[0095] The release module is configured to, after sending the available IP address and the network configuration information of the newly created container unit to the distributed key-value storage system in a key-value pair, when the container unit is removed from the computing node, release the fixed IP address of the container unit back to the specified IP pool, and update the IP address allocation information corresponding to the released fixed IP address in the distributed key-value storage system, so that the released fixed IP address can be reused by other container units.
[0096] The present invention provides an IP address allocation device for container units, which allocates IP addresses to container units in a cloud-native network through a specified IP pool, realizes the allocation of fixed IP addresses for container units, and can schedule container units to specified nodes through fixed IP addresses, so that node resources are reasonably utilized to better meet the requirements of a large-scale containerized environment and ensure the stability of business processes.
[0097] For the specific limitations on the IP address allocation device for container units, reference can be made to the limitations on the method in the above intelligent question and answer section, which will not be elaborated here. Each module in the above IP address allocation device for container units can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor of the computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.
[0098] In one embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 9As shown in the figure. The computer device includes a processor, a memory, a network interface, and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client through a network connection. When the computer program is executed by the processor, it realizes the functions or steps on the server side of an IP address allocation method for container units.
[0099] In one embodiment, a computer device is provided. The computer device can be a client, and its internal structure diagram can be as Figure 10 shown. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server through a network connection. When the computer program is executed by the processor, it realizes the functions or steps on the client side of an IP address allocation method for container units.
[0100] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the following steps are realized:
[0101] Add a first fixed identifier and a second fixed identifier to the application configuration file in the cloud-native network. The first fixed identifier is used to allocate a fixed IP address for a container unit, and the second fixed identifier is used to allocate a fixed IP address for the container unit in a specified IP pool. Different IP address segments corresponding to computing nodes are pre-stored in the specified IP pool, and the fixed IP address is started on the computing node.
[0102] When the cloud-native network creates an application for the first time, select an available fixed IP address from the specified IP pool and allocate it to the newly created container unit of the application.
[0103] Determine the target computing node for the deployment of the application according to the available fixed IP address, so as to schedule the newly created container unit to the target computing node. The available fixed IP address is located in the IP address segment corresponding to the target computing node.
[0104] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0105] Add a first fixed identifier and a second fixed identifier to the application configuration file of the cloud-native network. The first fixed identifier is used to assign a fixed IP address to a container unit, and the second fixed identifier is used to assign a fixed IP address to the container unit in a specified IP pool. Different IP address segments corresponding to computing nodes are pre-stored in the specified IP pool, and the fixed IP address is started on the computing node.
[0106] When the cloud-native network creates an application for the first time, select an available fixed IP address from the specified IP pool and assign it to the newly created container unit of the application.
[0107] Determine the target computing node for the deployment of the application according to the available fixed IP address, so as to schedule the newly created container unit to the target computing node. The available fixed IP address is located in the IP address segment corresponding to the target computing node.
[0108] It should be noted that for the functions or steps that can be implemented by the above computer-readable storage medium or computer device, reference can be made to the relevant descriptions on the server side and the client side in the foregoing method embodiments. To avoid repetition, they will not be described in detail here.
[0109] Those of ordinary skill in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the above method embodiments. Among them, any reference to a memory, storage, database, or other medium used in the various embodiments provided in the present application can include non-volatile and / or volatile memories. Non-volatile memories can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memories can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.
[0110] Those skilled in the art can clearly understand that, for the convenience and conciseness of description, only the above division of each functional unit and module is used as an example. In actual applications, the above functions can be assigned to different functional units and modules according to needs, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0111] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A method for allocating IP addresses to a container unit, characterized in that: include: Adding a first fixed identifier and a second fixed identifier to an application configuration file of the cloud native network, wherein the first fixed identifier is used to assign a fixed IP address to the container unit, and the second fixed identifier is used to assign a fixed IP address to the container unit in a specified IP pool, wherein the specified IP pool pre-stores IP address segments corresponding to different computing nodes, and the fixed IP address is started on the computing node; When the cloud native network creates an application for the first time, an available fixed IP address is selected from the specified IP pool and allocated to a newly created container unit of the application; The target computing node for application deployment is determined according to the available fixed IP address, so as to schedule the newly created container unit to the target computing node, wherein the available fixed IP address is located in the IP address segment corresponding to the target computing node.
2. The method for allocating IP addresses of container units according to claim 1, characterized in that: The adding the first fixed identifier and the second fixed identifier in the application configuration file of the cloud native network includes: Determine the metadata of the container unit in the application configuration file of the cloud native network; For the metadata of the container unit, annotations and / or labels are added by customization to identify that the container unit requires a fixed IP address and that the container unit allocates a fixed IP address in a specified IP pool, and the annotations and / or labels meet the format requirements of the cloud native network.
3. The method for allocating IP addresses of container units according to claim 1, characterized in that: Before selecting an available fixed IP address from the designated IP pool and allocating it to the container unit of the application when the cloud native network creates the application for the first time, the method further includes: Determine the fixed IP address range of the container unit based on the IP address architecture of the node cluster in the cloud native network; Splitting the fixed IP address range of the container unit into IP address segments, and establishing a mapping relationship between the IP address segments and different computing nodes; According to the mapping relationship between the IP address segments and different computing nodes, a designated IP pool is constructed so that the container unit is dispatched to the corresponding computing node through the IP address in the designated IP pool.
4. The method for allocating IP addresses of container units according to claim 3, characterized in that: The step of constructing a designated IP pool according to the mapping relationship between the IP address segments and different computing nodes includes: Creating an address resource object according to the mapping relationship between the IP address segment and different computing nodes, defining configuration information of the designated IP pool of the container unit in the address resource object, wherein the configuration information includes the fixed IP address range of the container unit and the mapping relationship between different computing nodes and the IP address segment; The address resource object is referenced in a configuration file of the cloud native network, so that the cloud native network reads the configuration information of the specified IP pool of the container unit in the address resource object through the reference field.
5. The method for allocating an IP address of a container unit according to any one of claims 1 to 4, characterized in that: After selecting an available fixed IP address from the designated IP pool and allocating it to the container unit of the application when the cloud native network creates the application for the first time, the method further includes: Packing the available IP address and the network configuration information of the newly created container unit into a key-value pair and sending the pair to the distributed key-value storage system, so as to record the IP address allocation information of the container unit through the distributed key-value storage system; Correspondingly, when the node cluster in the cloud native network triggers the reconstruction of the container unit, the original fixed IP address is allocated to the corresponding container unit according to the IP address allocation information recorded in the distributed key-value storage system.
6. The method for allocating IP addresses of container units according to claim 5, characterized in that: After packaging the available IP address and the network configuration information of the newly created container unit to form a key-value pair and sending it to the distributed key-value storage system, the method further includes: When the application needs to be expanded, an unused fixed IP address is selected from the designated IP pool according to the IP address allocation information recorded in the distributed key-value storage system, and the unused fixed IP address is allocated to the container unit created for the expansion.
7. The method for allocating IP addresses of container units according to claim 5, characterized in that: After packaging the available IP address and the network configuration information of the newly created container unit to form a key-value pair and sending it to the distributed key-value storage system, the method further includes: When a container unit is removed from a computing node, the fixed IP address of the container unit is released back to the designated IP pool, and the IP address allocation information corresponding to the released fixed IP address is updated in the distributed key-value storage system so that the released fixed IP address can be reused by other container units.
8. An IP address allocation device for a container unit, characterized in that: include: An adding module is used to add a first fixed identifier and a second fixed identifier in an application configuration file of a cloud native network, wherein the first fixed identifier is used to assign a fixed IP address to a container unit, and the second fixed identifier is used to assign a fixed IP address to the container unit in a specified IP pool, wherein the specified IP pool pre-stores IP address segments corresponding to different computing nodes, and the fixed IP address is started on the computing node; An allocation module, configured to select an available fixed IP address from the designated IP pool and allocate it to a newly created container unit of the application when the cloud native network creates an application for the first time; A scheduling module is used to determine a target computing node for application deployment based on the available fixed IP address so as to schedule the newly created container unit to the target computing node, wherein the available fixed IP address is located in an IP address segment corresponding to the target computing node.
9. A computer 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 computer program, the steps of the method for allocating an IP address for a container unit according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method for allocating an IP address of a container unit according to any one of claims 1 to 7 are implemented.