A method, apparatus, electronic device, and storage medium for allocating IP addresses.

By dynamically managing cluster network segments through the IP address allocation and management system, the problem of uneven IP address allocation in the cluster is solved, and the efficient allocation of IP addresses for newly added nodes and the efficient utilization of resources are achieved, thereby improving the efficiency of IP address allocation.

CN116366606BActive Publication Date: 2025-10-31BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310341208.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-31
Publication Date
2025-10-31
Estimated Expiration
2043-03-31

AI Technical Summary

Technical Problem

In a cluster consisting of a group of nodes running containerized applications, existing technologies cannot effectively manage IP address allocation, resulting in problems such as new nodes being unable to be assigned IP addresses, resource waste, and uneven allocation.

Method used

The system creates network segments through the IP address allocation management system, receives IP address allocation requests from the cluster, parses the requests, and allocates target IP addresses from the network segments. It supports different container groups on the same node having IP addresses belonging to different or the same network segments, uses multiple worker threads to accelerate the allocation process, and reclaims unused IP addresses.

Benefits of technology

It enables the allocation of IP addresses for newly added nodes in the cluster, avoiding resource waste, improving the efficiency and balance of IP address allocation, and supporting IP address management in dynamic cluster environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116366606B_ABST
    Figure CN116366606B_ABST
Patent Text Reader

Abstract

This invention provides a method, apparatus, electronic device, and storage medium for allocating IP addresses. The method includes: creating a network segment to be allocated to a target cluster; the network segment including multiple IP addresses to be allocated; receiving an IP address allocation request sent by the target cluster, the IP address allocation request being generated by the node component when creating a container group under any node in the target cluster; determining the target IP address corresponding to the IP address allocation request from the network segment, and allocating the target IP address to the container group, wherein, between different container groups belonging to the same node, the target IP addresses allocated to the container groups belong to different network segments or belong to the same network segment. Through this invention, even if a new node is added to the target cluster, IP addresses can still be allocated to the container groups under the new node; moreover, each IP address contained in the network segment can be allocated to a container group, avoiding resource waste.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a method, apparatus, electronic device, and storage medium for allocating IP addresses. Background Technology

[0002] In a cluster consisting of a group of nodes running containerized applications (such as a Kubernetes cluster), IP addresses of container groups under each node in the cluster can be managed through node components (such as Cilium components), which typically manage IP addresses at the cluster node level.

[0003] The method for allocating IP addresses to node components in the target cluster is as follows: A node component in the cluster first needs to split the network segment of the target cluster into multiple smaller network segments according to the number of nodes in the current cluster. Then, each smaller network segment is assigned to a corresponding node in the target cluster. When a container group is created under that node, the node component assigns the IP address in the smaller network segment corresponding to that node to the corresponding container group.

[0004] However, the data volume of nodes and container groups in the target cluster is variable, which leads to certain limitations in node-level IP address management within the target component. In one scenario, with a fixed network segment, if a new node is added after all subnets have been allocated for the target cluster, it is impossible to allocate a corresponding subnet to the new node, and consequently, the container groups created under that node cannot be assigned corresponding IP addresses. In another scenario, since the number of container groups created on each node is different, the required number of IP addresses also varies. Because the node component pre-allocates subnets to the nodes, some nodes may have unused IP addresses, while others may not have enough, resulting in resource waste. Summary of the Invention

[0005] In view of the above problems, a method, apparatus, electronic device, and storage medium for allocating IP addresses are proposed to overcome or at least partially solve the above problems, including:

[0006] An IP address allocation method is applied to an IP address allocation management system. The IP address allocation system manages IP addresses for a target cluster, which consists of a group of nodes running containerized applications. Each node in the target cluster can create or delete one or more container groups. The target cluster also includes node components for creating or deleting container groups. The method includes:

[0007] Create a network segment to be assigned to the target cluster; the network segment includes multiple IP addresses to be assigned.

[0008] Receive an IP address allocation request sent by the target cluster, wherein the IP address allocation request is generated by the node component when creating a container group under any node in the target cluster;

[0009] The target IP address corresponding to the IP address allocation request is determined from the network segment, and the target IP address is allocated to the container group; wherein, between different container groups belonging to the same node, the target IP addresses allocated to the container groups belong to different network segments or belong to the same network segment.

[0010] Optionally, the IP address allocation management system determines the target IP address corresponding to the IP address allocation request from the network segment, including:

[0011] The IP address allocation request is parsed to determine the network segment configuration information for the container group;

[0012] Determine the target IP address from the network segment that matches the network segment configuration information.

[0013] Optionally, before receiving the IP address allocation request sent by the target cluster, the method further includes:

[0014] Create multiple worker threads for assigning IP addresses;

[0015] The network segment is divided into multiple sub-network segments based on the number of the multiple worker threads;

[0016] Determining the target IP address corresponding to the IP address allocation request from the network segment includes:

[0017] The multiple worker threads are started to perform the step of determining the target IP address corresponding to the IP address allocation request from the network segment, wherein each worker thread is responsible for IP address allocation in a sub-network segment.

[0018] Optionally, it also includes:

[0019] When a change in the number of created worker threads is detected, multiple subnets are re-divided based on the changed number of worker threads.

[0020] Alternatively, when a change in the range of the network segment is detected, the changed network segment is re-divided into multiple sub-network segments based on the number of the multiple worker threads.

[0021] Optionally, the IP address allocation management system determines the target IP address corresponding to the IP address allocation request from the network segment and allocates the target IP address to the container group, including:

[0022] From the plurality of worker threads, determine the target worker thread for processing the IP address allocation request;

[0023] The target IP address is determined from the target subnet corresponding to the target worker thread, and the target IP address is allocated to the container group through the target worker thread.

[0024] Optionally, after determining the target worker thread for processing the IP address allocation request from the plurality of worker threads, the method further includes:

[0025] Determine whether the target subnet segment contains any unassigned IP addresses;

[0026] If no unassigned IP address exists in the target subnet segment, the target working thread is paused.

[0027] Optionally, it also includes:

[0028] Receive an IP address reclamation request sent by the target cluster, wherein the IP address reclamation request is generated by the node component when deleting a container group under any node in the target cluster;

[0029] Identify the IP address to be reclaimed corresponding to the IP address reclamation request, and reclaim the IP address to be reclaimed.

[0030] An IP address allocation device based on a target cluster is applied to an IP address allocation management system. The IP address allocation system manages IP addresses for the target cluster, which consists of a group of nodes running containerized applications. Each node in the target cluster can create or delete one or more container groups. The target cluster also includes node components for creating or deleting container groups. The device includes:

[0031] The network segment configuration module is used to create network segments to be assigned to the target cluster; the network segment includes multiple IP addresses to be assigned.

[0032] The allocation request module is used to receive IP address allocation requests sent by the target cluster. The IP address allocation request is generated when the node component creates a container group under any node in the target cluster.

[0033] The IP address allocation module is used to determine the target IP address corresponding to the IP address allocation request from the network segment and allocate the target IP address to the container group; wherein, between different container groups belonging to the same node, the target IP addresses allocated to the container groups belong to different network segments or belong to the same network segment.

[0034] An electronic device includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0035] Memory, used to store computer programs;

[0036] When a processor executes a program stored in memory, it implements the method steps described above.

[0037] A computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the method described above.

[0038] The embodiments of the present invention have the following advantages:

[0039] This invention provides an embodiment of an IP address allocation management system that creates network segments to be allocated to a target cluster. These network segments include multiple IP addresses to be allocated. The system receives IP address allocation requests sent by the target cluster, which are generated by the node component when creating a container group on any node in the target cluster. It then determines the target IP address corresponding to the IP address allocation request from the network segments and allocates the target IP address to the container group. Specifically, for different container groups belonging to the same node, the target IP addresses allocated to the container groups may belong to different network segments or the same network segment.

[0040] In this embodiment of the invention, when a container group is created in the target cluster, the IP address allocation management system outside the target cluster is used to allocate the corresponding IP address from the entire network segment for the newly created container group. Even if a new node is added to the target cluster, an IP address can be directly allocated to the container group under the new node. Moreover, the target cluster allocates the corresponding IP address from the entire network segment for the created container group in sequence. Each IP address in the network segment can be allocated to the container group, avoiding resource waste. Attached Figure Description

[0041] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0042] Figure 1 This is a flowchart illustrating the steps of an IP address allocation method according to an embodiment of the present invention;

[0043] Figure 2 This is a flowchart of another IP address allocation method provided in an embodiment of the present invention;

[0044] Figure 3a This is a flowchart of another IP address allocation method provided in an embodiment of the present invention;

[0045] Figure 3bThis is a schematic diagram of the structure of an IP address allocation management system and cluster provided in an embodiment of the present invention;

[0046] Figure 4 This is a flowchart of another IP address allocation method provided in an embodiment of the present invention;

[0047] Figure 5a This is a schematic diagram of the structure of an IP address allocation device provided in an embodiment of the present invention;

[0048] Figure 5b This is a schematic diagram of a substructure of an IP address allocation device according to an embodiment of the present invention;

[0049] Figure 5c This is a schematic diagram of a substructure of an IP address allocation device according to an embodiment of the present invention;

[0050] Figure 5d This is a schematic diagram of a substructure of an IP address allocation device according to an embodiment of the present invention;

[0051] Figure 5e This is a schematic diagram of a substructure of an IP address allocation device according to an embodiment of the present invention;

[0052] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0053] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0054] This invention relates to an IP address allocation management system and a target cluster. The IP address allocation management system manages the IP addresses of one or more target clusters. The system may include microservices for IP address management, which manage the cluster's IP addresses by calling these microservices. This management of IP addresses for container groups within the cluster may include, but is not limited to, allocating and reclaiming IP addresses for container groups. The target cluster may consist of a group of nodes running containerized applications. The number of nodes in the cluster can be increased or decreased according to cluster requirements. One or more container groups can be created under each node, serving as the smallest unit in the cluster. Communication between container groups depends on their IP addresses. The IP address allocation management system calls the microservices to allocate or reclaim IP addresses for container groups. The target cluster may also include node components, which can be used to create or delete container groups. The cluster communicates with the IP address allocation management system through these node components to allocate or reclaim IP addresses for the cluster's container groups. For example, when a node component creates a container group, it generates an IP allocation request for that container group and sends it to the IP address allocation management system to request the IP address allocation management system to allocate the corresponding IP address to the created container group; when a node component deletes a container group, it generates an IP reclamation request for that container group and sends it to the IP address allocation management system to request the IP address allocation management system to reclaim the IP address corresponding to the deleted container group.

[0055] Reference Figure 1 This diagram illustrates a flowchart of an IP address allocation method according to an embodiment of the present invention, involving an IP address allocation management system and a target cluster, and specifically includes the following steps:

[0056] Step 101: Create a network segment to be assigned to the target cluster; the network segment includes multiple IP addresses to be assigned.

[0057] In the target cluster, two container groups on any node can communicate with each other. Therefore, each container group created in the target cluster needs to be assigned a corresponding IP address to support communication between container groups.

[0058] The IP address allocation and management system can manage the IP addresses of one or more target clusters simultaneously. The IP address management methods can include IP address allocation and IP address recycling.

[0059] The IP address allocation and management system can pre-configure network segments to be assigned to one or more target clusters. These network segments can include multiple IP addresses to be assigned. Thus, when a container group is created by a target cluster, IP addresses can be assigned to the container group through the IP address allocation and management system. When a container group is deleted by a target cluster, the IP addresses corresponding to the container group can be reclaimed to the IP address allocation and management system, thereby enabling IP address management of the target cluster within the IP address allocation and management system.

[0060] Step 102: Receive the IP address allocation request sent by the target cluster. The IP address allocation request is generated when the node component creates a container group under any node in the target cluster.

[0061] In the target cluster, container groups on nodes can be created or deleted as needed. For each container group on any node in the target cluster, an IP address needs to be assigned when the container group is created so that communication between container groups can be achieved based on the IP address. Thus, when a node component creates a new container group on any node in the target cluster, it can generate an IP address allocation request. This IP address allocation request is used to request the IP address allocation management system to allocate the corresponding IP address for the newly generated container group.

[0062] After generating an IP address allocation request, the node component can send the generated IP address allocation request to the IP address allocation management system connected to the target cluster. In the IP address allocation management system, an IP address is allocated to the container group created by the target cluster based on the received IP address allocation request.

[0063] In one example, the target cluster can be a Kubernetes (K8s) cluster. The Cilium component (i.e., the node component) in the Kubernetes (K8s) cluster is a component tool used to create or delete pods (i.e., container groups). When creating a pod, the Cilium component can also configure corresponding attributes for the created pod so that the created pod can run with specific attributes in the K8s cluster. Among them, specific tagging information can be added to the pod's metadata (i.e., annotation or label) to mark the IP range to be used. That is, when no tag is added to the pod's metadata, the IP range of the pod is determined to be the default IP range.

[0064] In a Kubernetes cluster, when a Cilium component (such as cilium-agent) creates a pod, it needs to assign an IP address to the pod in order to enable communication between pods. Therefore, the Cilium component can generate an IP address allocation request, which is used to request the IP address allocation management system to assign a corresponding IP address to the pod.

[0065] After the Cilium component generates an IP address allocation request, it can send the IP address allocation request to the IP address allocation management system to request the IP address allocation management system to allocate an IP address to the pod.

[0066] Step 103: Determine the target IP address corresponding to the IP address allocation request from the network segment, and allocate the target IP address to the container group; wherein, between different container groups belonging to the same node, the target IP address allocated to the container group belongs to different network segments or belongs to the same network segment.

[0067] Upon receiving an IP address allocation request, the IP address allocation management system can parse the request, determine an unallocated IP address from the configured network segment as the target IP address for the request, and allocate the target IP address to the container group.

[0068] In this embodiment of the invention, when assigning IP addresses to container groups created under a node, it is not necessary to consider the node where the container group is located. Thus, different container groups under the same node can be in the same network segment or in different network segments.

[0069] In this embodiment of the invention, a network segment to be allocated to a target cluster is created; the network segment includes multiple IP addresses to be allocated; an IP address allocation request sent by the target cluster is received, the IP address allocation request being generated when a node component creates a container group under any node in the target cluster; the target IP address corresponding to the IP address allocation request is determined from the network segment, and the target IP address is allocated to the container group. Thus, even if a new node is added to the target cluster, an IP address can be directly allocated to the container group under the new node; moreover, the corresponding IP address for each container group created in the target cluster is allocated sequentially from the entire network segment, so that each IP address contained in the network segment can be allocated to the container group, avoiding resource waste.

[0070] Reference Figure 2 This diagram illustrates a flowchart of another IP address allocation method according to an embodiment of the present invention, applied to an IP address allocation management system. The IP address allocation system is used to manage IP addresses of a target cluster. The target cluster consists of a group of nodes running containerized applications. Each node in the target cluster can create or delete one or more container groups. The target cluster also includes node components for creating or deleting container groups, specifically including the following steps:

[0071] Step 201: Create a network segment to be assigned to the target cluster; the network segment includes multiple IP addresses to be assigned.

[0072] Step 202: Receive the IP address allocation request sent by the target cluster. The IP address allocation request is generated when the node component creates a container group under any node in the target cluster.

[0073] Step 203: Parse the IP address allocation request to determine the network segment configuration information for the container group;

[0074] The IP address allocation request may include the identity of the container group, the network segment configuration information of the container group, etc. When the IP address allocation management system receives the IP address allocation request sent by the target cluster, it can parse the IP address allocation request to obtain the identity of the container group and the network segment configuration information of the container group. The network segment configuration information of the container group can indicate whether the container group has a specified network segment.

[0075] When a node component creates a container group in the target cluster, it can store the creation information of the container group in the cluster database. The creation information of the container group can include the metadata of the container group. The metadata of the container group can add the specified network segment configuration information. The network segment configuration information of the container group can indicate that the container group has the specified network segment. If the specified network segment information is not added to the metadata of the container group, the network segment configuration information of the container group can indicate that the specified network segment does not exist in the container group. The IP address can be randomly assigned.

[0076] Step 204: Determine the target IP address that matches the network segment configuration information from the network segment, and assign the target IP address to the container group; wherein, between different container groups belonging to the same node, the target IP address assigned to the container group belongs to different network segments or belongs to the same network segment.

[0077] After resolving the network segment configuration information of the container group, the IP address allocation and management system can determine the target IP address within the network segment based on this information. When the network segment configuration information of the container group indicates a specific network segment, it identifies unassigned IP addresses that match the specified network segment, determines the target IP address from among these unassigned IP addresses, and assigns the target IP address to the container group.

[0078] In one example, the IP address allocation management system may include a database that stores allocation details for network segments, including allocated and unallocated IP addresses within those segments. Each time the IP address allocation management system allocates an address according to an IP address allocation request, it synchronously updates the allocation details of the network segments in the database. When another IP address allocation request is received, the allocation details of the network segments can be retrieved from the database to determine the currently unallocated IP addresses. If the IP address allocation request includes network segment configuration information, then an unallocated IP address matching the specified network segment can be determined from the currently unallocated IP addresses based on the network segment configuration information.

[0079] In this embodiment of the invention, a network segment to be allocated to a target cluster is created; the network segment includes multiple IP addresses to be allocated; an IP address allocation request sent by the target cluster is received, the IP address allocation request being generated when a node component creates a container group under any node in the target cluster; the IP address allocation request is parsed to determine the network segment configuration information for the container group; a target IP address matching the network segment configuration information is determined from the network segment, and the target IP address is allocated to the container group. Thus, even if a new node is added to the target cluster, an IP address can be directly allocated to the container group under the new node; moreover, the corresponding IP address for each container group created in the target cluster is allocated sequentially from the entire network segment, so that each IP address contained in the network segment can be allocated to the container group, avoiding resource waste; at the same time, the network segment configuration information requested by the container group can be determined according to the IP address allocation request of the container group, thereby realizing the allocation of a specified network segment to the container group.

[0080] Reference Figure 3a This diagram illustrates a flowchart of an IP address allocation method according to an embodiment of the present invention. The method is applied to an IP address allocation management system, which manages IP addresses for a target cluster. The target cluster consists of a group of nodes running containerized applications. Each node in the target cluster can create or delete one or more container groups. The target cluster also includes node components for creating or deleting container groups, specifically including the following steps:

[0081] Step 301: Create a network segment to be assigned to the target cluster; the network segment includes multiple IP addresses to be assigned.

[0082] Step 302: Create multiple worker threads for assigning IP addresses;

[0083] In an IP address allocation and management system, multiple worker threads can be configured to allocate IP addresses in order to speed up the allocation process. These multiple worker threads can be started simultaneously to allocate IP addresses.

[0084] Step 303: Divide the network segment into multiple sub-network segments according to the number of multiple worker threads;

[0085] After configuring worker threads, the network segment is divided according to the number of worker threads in the system, resulting in multiple sub-network segments. Each worker thread corresponds to one sub-network segment. The IP addresses contained in the sub-network segment are the IP addresses managed by that worker thread.

[0086] In one example, the IP address allocation management system can divide network segments equally. For instance, if there are 100 IP addresses to be allocated in a network segment, and the IP address allocation management system creates 10 worker threads, then the 100 IP addresses to be allocated can be divided into 10 sub-network segments, each containing 10 IP addresses to be allocated.

[0087] Reference Figure 3b This diagram illustrates the structure of an IP address allocation management system and cluster provided by an embodiment of the present invention. Figure 3b In the IP address allocation management system, there can be two network segments: network segment 1 and network segment 2. Each network segment can be divided into multiple logical subnets according to the number of worker threads created for each cluster. Each worker thread is responsible for allocating multiple IP addresses in a logical subnet. For example, network segment 1 can include logical subnet 11, logical subnet 12, etc., and network segment 2 can include logical subnet 21, logical subnet 22, etc.

[0088] exist Figure 3b The system comprises two clusters: Cluster 1 and Cluster 2. Cluster 1 includes nodes 1-1 and 1-2, as well as node component 1, which creates or deletes container groups within Cluster 1. Cluster 2 includes nodes 2-1 and 2-2, as well as node component 2, which creates or deletes container groups within Cluster 2. Cluster 1 communicates with the IP address allocation management system through node component 1 to manage the IP addresses of Cluster 1; Cluster 2 communicates with the IP address allocation management system through node component 2 to manage the IP addresses of Cluster 2.

[0089] For example, when node component 1 creates a container group, it can send an IP address allocation request (which can be an HTTP request) to the IP address allocation management system. The IP address allocation management system calls a preset microservice to select an IP address from network segment 1 corresponding to cluster 1, and feeds back the selected IP address to node component 1 to realize the allocation of IP addresses for the container group.

[0090] In one embodiment of the present invention, the method may further include: when a change in the configured number of worker threads is detected, re-dividing multiple sub-network segments based on the changed number of worker threads.

[0091] In practical applications, the IP address allocation management system can configure new worker threads or delete existing worker threads as needed, which will cause changes in the number of worker threads configured in the IP address allocation management system. When the network segment range is fixed (i.e., the number of IP addresses contained in the network segment remains unchanged) but the number of worker threads changes, the number of IP addresses that each worker thread needs to allocate changes. This can trigger the reallocation of subnets in the IP address allocation management system. In a specific example, the IP address allocation management system can re-divide the subnets based on the number of worker threads after the change, so that each worker thread corresponds to a subnet. At the same time, re-dividing the subnets also facilitates the centralized management of the subnets.

[0092] For example, when the IP address allocation and management system needs to manage a total of 100 IP addresses in the network segment, it was originally managed by 10 working threads, with each working thread managing a subnet segment consisting of 10 IP addresses. When the number of working threads is increased to 20, each working thread manages a subnet segment consisting of 5 IP addresses.

[0093] In one embodiment of the present invention, the method may further include: when a change in the range of a network segment is detected, re-dividing the changed network segment into multiple sub-network segments according to the number of multiple working threads.

[0094] In practical applications, the range of a network segment may also change (i.e., the IP addresses contained in the network segment may change). When the range of a network segment changes, it may cause the number of IP addresses to be managed within the network segment to increase or decrease. When a change in the range of a network segment is detected, the IP address allocation management system can trigger the reallocation of sub-network segments. Specifically, the changed range of a network segment can be divided into multiple sub-network segments based on the number of worker threads, so that each worker thread corresponds to one sub-network segment.

[0095] For example, if the IP address allocation and management system needs to manage a network segment containing 100 IP addresses, and originally there were 10 working threads managing the IP addresses, with each working thread managing a subnet segment consisting of 10 IP addresses, when the network segment expands to include 100 more IP addresses, then the changed network segment now includes 200 IP addresses. The changed network segment can then be readjusted with 10 working processes, each responsible for managing a subnet segment consisting of 20 IP addresses.

[0096] Step 304: Receive the IP address allocation request sent by the target cluster and start multiple worker threads. The IP address allocation request is generated when the node component creates a container group under any node in the target cluster; each worker thread is responsible for the IP address allocation in a subnet segment.

[0097] In the target cluster, container groups on nodes can be created or deleted as needed. For each container group in the target cluster, an IP address needs to be assigned to enable communication between container groups. Thus, when the target cluster creates a new container group, an IP address allocation request can be generated. This IP address allocation request is used to request the IP address allocation management system to assign a corresponding IP address to the newly generated container group.

[0098] The node component can send the generated IP address allocation request to the IP address allocation management system. When the IP address allocation management system receives the IP address allocation request from the target cluster, it can start multiple worker threads to perform IP address allocation.

[0099] By having multiple worker threads work together to process IP address allocation requests, the efficiency of IP address allocation can be improved.

[0100] Step 305: Determine the target worker thread from among multiple worker threads to handle the IP address allocation request;

[0101] After the IP address allocation management system starts multiple worker threads, the target worker thread corresponding to the IP address allocation request can be determined among these multiple worker threads.

[0102] Step 306: Determine the target IP address from the target subnet corresponding to the target worker thread, and assign the target IP address to the container group through the target worker thread.

[0103] After determining the target worker thread, an unassigned IP address is selected from the target subnet corresponding to the target worker thread as the target IP address. Then, the target IP address is assigned to the container group via the target worker thread.

[0104] In one embodiment of the present invention, after determining the target worker thread for processing the IP address allocation request from multiple worker threads, the method may further include: determining whether there are unallocated IP addresses in the target subnet; and pausing the target worker thread when there are no unallocated IP addresses in the target subnet.

[0105] In practical applications, the IP address allocation and management system can monitor the IP address allocation status of each subnet in real time during the IP address management process, determine whether there are unallocated IP addresses in the target subnet, and pause the target worker thread when there are no unallocated IP addresses in the target subnet. The target worker thread will no longer process other IP address allocation requests to avoid IP addresses being allocated repeatedly.

[0106] In this embodiment of the invention, a network segment to be allocated to the target cluster is created, and multiple worker threads for allocating IP addresses are created. The network segment is divided into multiple sub-network segments according to the number of worker threads. The IP address allocation request sent by the target cluster is received, and multiple worker threads are started. The IP address allocation request is generated when the node component creates a container group under any node in the target cluster. Each worker thread is responsible for the IP address allocation in a sub-network segment. A target worker thread is determined from the multiple worker threads to handle the IP address allocation request. The target IP address is determined from the target sub-network segment corresponding to the target worker thread, and the target IP address is allocated to the container group through the target worker thread. By creating and starting multiple worker threads to handle the IP address allocation request, the IP address allocation speed can be improved.

[0107] Reference Figure 4 This diagram illustrates a flowchart of an IP address allocation method according to an embodiment of the present invention. The method is applied to an IP address allocation management system. The IP address allocation system manages IP addresses for a target cluster, which consists of a group of nodes running containerized applications. Each node in the target cluster can create or delete one or more container groups. The target cluster also includes node components for creating or deleting container groups, specifically including the following steps:

[0108] Step 401: Create a network segment to be assigned to the target cluster; the network segment includes multiple IP addresses to be assigned.

[0109] Step 402: Receive the IP address allocation request sent by the target cluster. The IP address allocation request is generated when the node component creates a container group under any node in the target cluster.

[0110] Step 403: Determine the target IP address corresponding to the IP address allocation request from the network segment, and allocate the target IP address to the container group.

[0111] Step 404: Receive the IP address reclamation request sent by the target cluster. The IP address reclamation request is generated when the node component deletes the container group under any node in the target cluster.

[0112] When deleting a container group in the target cluster, an IP address reclamation request can be generated. The IP address reclamation request can be used to request the IP address allocation and management system to reclaim the IP address of the container group. After generating the IP address reclamation request, the target cluster can send the IP address reclamation request to the IP address allocation and management system to request the reclamation of IP address resources.

[0113] In one example, within a Kubernetes cluster, the Cilium component can be used to delete container groups and generate IP address reclamation requests.

[0114] Step 405: Determine the IP address to be reclaimed corresponding to the IP address reclamation request, and reclaim the IP address to be reclaimed.

[0115] After the IP address allocation and management system receives the IP address reclamation request sent by the target cluster, it can determine the IP address to be reclaimed corresponding to the IP address reclamation request, and then reclaim the IP address to be reclaimed. After the IP address is reclaimed, it can be reassigned to other newly created container groups.

[0116] In one example, for the IP address reclamation operation, multiple worker threads can be started simultaneously to reclaim IP addresses.

[0117] In this embodiment of the invention, a network segment to be allocated to the target cluster is created; then, an IP address allocation request sent by the target cluster is received. The IP address allocation request is generated when a node component creates a container group under any node in the target cluster. The target IP address corresponding to the IP address allocation request is determined from the network segment, and the target IP address is allocated to the container group. An IP address reclamation request sent by the target cluster is received. The IP address reclamation request is generated when a node component deletes a container group under any node in the target cluster. The IP address to be reclaimed corresponding to the IP address reclamation request is determined, and the IP address to be reclaimed is reclaimed. Thus, the IP address allocation management system allocates or reclaims IP addresses for the container group, realizing convenient management of the target cluster's IP addresses.

[0118] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.

[0119] Reference Figure 5a This diagram illustrates a structural schematic of an IP address allocation device for a target cluster according to an embodiment of the present invention. The device is applied to an IP address allocation management system, which manages IP addresses for a target cluster. The target cluster consists of a group of nodes running containerized applications. Each node in the target cluster can create or delete one or more container groups. The target cluster also includes node components for creating or deleting container groups, specifically including the following modules:

[0120] The network segment configuration module 501 is used to create network segments to be assigned to the target cluster; the network segment includes multiple IP addresses to be assigned.

[0121] The allocation request module 502 is used to receive an IP address allocation request sent by the target cluster. The IP address allocation request is generated when the node component creates a container group under any node in the target cluster.

[0122] IP address allocation module 503 is used to determine the target IP address corresponding to the IP address allocation request from the network segment and allocate the target IP address to the container group; wherein, between different container groups belonging to the same node, the target IP addresses allocated to the container groups belong to different network segments or belong to the same network segment.

[0123] In one embodiment of the present invention, reference is made to... Figure 5b The diagram illustrates a substructure of an IP address allocation device for a target cluster according to an embodiment of the present invention, wherein the IP address allocation module 503 may include:

[0124] The submodule 11 for determining network segment configuration information is used to parse IP address allocation requests and determine the network segment configuration information for the container group.

[0125] The target IP address determination submodule 12 is used to determine the target IP address that matches the network segment configuration information from the network segment.

[0126] In one embodiment of the present invention, the apparatus may further include:

[0127] The worker thread configuration module 504 is used to configure multiple worker threads for allocating IP addresses.

[0128] Subnetting module 505 is used to divide a network segment into multiple subnets based on the number of multiple worker threads;

[0129] Reference Figure 5c The diagram illustrates a substructure of an IP address allocation device for a target cluster according to an embodiment of the present invention, wherein the IP address allocation module 503 may include:

[0130] The worker thread startup submodule 21 is used to start multiple worker threads to perform the steps of determining the target IP address corresponding to the IP address allocation request from the network segment. Each worker thread is responsible for the IP address allocation in a sub-network segment.

[0131] In one embodiment of the present invention, the apparatus may further include:

[0132] The first subnet segment re-division module 506 is used to re-divide multiple subnet segments based on the changed number of worker threads when a change in the configured number of worker threads is detected.

[0133] The second subnet re-division module 507 is used to re-divide the changed subnet into multiple subnets based on the number of multiple working threads when a change in the range of a subnet is detected.

[0134] In one embodiment of the present invention, reference is made to... Figure 5d The diagram illustrates a substructure of an IP address allocation device for a target cluster according to an embodiment of the present invention, wherein the IP address allocation module 503 may include:

[0135] The target worker thread determination submodule 31 is used to determine the target worker thread for processing the IP address allocation request from multiple worker threads;

[0136] IP address allocation submodule 32 is used to determine the target IP address from the target subnet corresponding to the target worker thread, and allocate the target IP address to the container group through the target worker thread.

[0137] In one embodiment of the present invention, reference is made to... Figure 5e The diagram illustrates a substructure of an IP address allocation device for a target cluster according to an embodiment of the present invention, wherein the IP address allocation module 503 further includes:

[0138] The unassigned IP address determination submodule 41 is used to determine whether there are unassigned IP addresses in the target subnet;

[0139] The target worker thread pause submodule 42 is used to pause the target worker thread when there is no unassigned IP address in the target subnet.

[0140] In one embodiment of the present invention, the apparatus may further include:

[0141] IP address recycling request receiving module 508 is used to receive IP address recycling requests sent by the target cluster. The IP address recycling request is generated when a node component deletes a container group under any node in the target cluster.

[0142] The IP address recycling module 509 is used to determine the IP address to be recycled corresponding to the IP address recycling request, and to recycle the IP address to be recycled.

[0143] This invention also provides an electronic device, such as... Figure 6 As shown, it includes a processor 601, a communication interface 602, a memory 603, and a communication bus 604, wherein the processor 601, the communication interface 602, and the memory 603 communicate with each other through the communication bus 604.

[0144] Memory 603 is used to store computer programs;

[0145] When processor 601 executes a program stored in memory 603, it performs the following steps:

[0146] Create a network segment to be assigned to the target cluster; the network segment includes multiple IP addresses to be assigned.

[0147] Receive IP address allocation requests sent by the target cluster. The IP address allocation requests are generated when the node component creates a container group under any node in the target cluster.

[0148] The target IP address corresponding to the IP address allocation request is determined from the network segment, and the target IP address is allocated to the container group; among different container groups belonging to the same node, the target IP addresses allocated to the container groups belong to different network segments or belong to the same network segment.

[0149] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.

[0150] The communication interface is used for communication between the aforementioned terminal and other devices.

[0151] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0152] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0153] In another embodiment of the present invention, a computer-readable storage medium is also provided, which stores instructions that, when executed on a computer, cause the computer to perform any of the IP address allocation methods described in the above embodiments.

[0154] In another embodiment of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the IP address allocation methods in the above embodiments.

[0155] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of the present invention is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., a solid-state disk (SSD)).

[0156] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.

[0157] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0158] The above are merely preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.

Claims

1. A method for allocating IP addresses, characterized in that, An IP address allocation management system is applied to manage IP addresses of a target cluster. The target cluster consists of a group of nodes running containerized applications. Each node in the target cluster can create or delete one or more container groups. The target cluster also includes node components for creating or deleting container groups. The method includes: Create a network segment to be assigned to the target cluster; the network segment includes multiple IP addresses to be assigned. Receive an IP address allocation request sent by the target cluster, wherein the IP address allocation request is generated by the node component when creating a container group under any node in the target cluster; The target IP address corresponding to the IP address allocation request is determined from the network segment, and the target IP address is allocated to the container group; wherein, between different container groups belonging to the same node, the target IP addresses allocated to the container groups belong to different network segments or belong to the same network segment; Prior to receiving the IP address allocation request sent by the target cluster, the method further includes: Create multiple worker threads for assigning IP addresses; The network segment is divided into multiple sub-network segments based on the number of the multiple worker threads; Determining the target IP address corresponding to the IP address allocation request from the network segment includes: The multiple worker threads are started to perform the step of determining the target IP address corresponding to the IP address allocation request from the network segment, wherein each worker thread is responsible for IP address allocation in a sub-network segment.

2. The method according to claim 1, characterized in that, Determining the target IP address corresponding to the IP address allocation request from the network segment includes: The IP address allocation request is parsed to determine the network segment configuration information for the container group; Determine the target IP address from the network segment that matches the network segment configuration information.

3. The method according to claim 1, characterized in that, Also includes: When a change in the number of created worker threads is detected, multiple subnets are re-divided based on the changed number of worker threads. Alternatively, when a change in the range of the network segment is detected, the changed network segment is re-divided into multiple sub-network segments based on the number of the multiple worker threads.

4. The method according to claim 1, characterized in that, Determining the target IP address corresponding to the IP address allocation request from the network segment, and allocating the target IP address to the container group, includes: From the plurality of worker threads, determine the target worker thread for processing the IP address allocation request; The target IP address is determined from the target subnet corresponding to the target worker thread, and the target IP address is allocated to the container group through the target worker thread.

5. The method according to claim 4, characterized in that, After determining the target worker thread for processing the IP address allocation request from the plurality of worker threads, the process further includes: Determine whether the target subnet segment contains any unassigned IP addresses; If no unassigned IP address exists in the target subnet segment, the target working thread is paused.

6. The method according to any one of claims 1 to 5, characterized in that, Also includes: Receive an IP address reclamation request sent by the target cluster, wherein the IP address reclamation request is generated by the node component when deleting a container group under any node in the target cluster; Identify the IP address to be reclaimed corresponding to the IP address reclamation request, and reclaim the IP address to be reclaimed.

7. An IP address allocation device, characterized in that, An IP address allocation management system is used to manage IP addresses of a target cluster. The target cluster consists of a group of nodes running containerized applications. Each node in the target cluster can create or delete one or more container groups. The target cluster also includes node components for creating or deleting container groups. The device includes: The network segment creation module is used to create network segments to be assigned to the target cluster; the network segment includes multiple IP addresses to be assigned. The allocation request module is used to receive IP address allocation requests sent by the target cluster. The IP address allocation request is generated when the node component creates a container group under any node in the target cluster. The IP address allocation module is used to determine the target IP address corresponding to the IP address allocation request from the network segment, and allocate the target IP address to the container group; The device further includes: The worker thread configuration module is used to configure multiple worker threads for assigning IP addresses. The subnetting module is used to divide a network segment into multiple subnets based on the number of multiple worker threads. The IP address allocation module includes: The worker thread startup submodule is used to start multiple worker threads to perform the steps of determining the target IP address corresponding to the IP address allocation request from the network segment. Each worker thread is responsible for the IP address allocation in a sub-network segment.

8. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Container network configuration method and device, computing node, main node and storage medium

    CN114172802A