Method and system for uniformly allocating IP addresses based on container cloud platform
By creating IP address pool resource files and binding relationships in the container cloud platform, the problems of inefficient IP address allocation and business interruption on the container cloud platform are solved, and refined management and flexible allocation of IP addresses are realized.
Patent Information
- Application Number
- CN202211591217.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-12
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2042-12-12
AI Technical Summary
In the prior art, container cloud platforms have inefficient, error-prone and affect business availability when allocating IP addresses, especially when application expansion or reduction, they need to manually modify resource files, resulting in business interruption.
By creating an IP address pool resource file in the container cloud platform, defining multiple IP address pools, and establishing a binding relationship between the application and the IP address pool, using the binding relationship to select an unassigned IP address from the target IP address pool for allocation, avoiding IP address preemption and conflict.
It realizes refined management and flexible allocation of IP addresses, improves management efficiency, reduces the risk of business interruption, and ensures the rationality and flexibility of IP address allocation.
Smart Images

Figure CN116016449B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of container cloud platforms, and in particular to a method, system, computer-readable storage medium, and electronic device for uniformly allocating IP addresses based on a container cloud platform. Background Art
[0002] In a container cloud platform, an application usually contains multiple application instances. Each application instance runs in a container group (Pod). The container cloud platform assigns a unique IP (Internet Protocol) address to the Pod to enable communication between the application instances.
[0003] Taking Kubernetes as an example, when a Pod is created, an IP address is usually assigned to it by the CNI (Container Network Interface) plug-in. Specifically, the CNI plug-in manages the entire IP address set consisting of all IP addresses in the Kubernetes cluster. When an IP address needs to be assigned to a Pod, the CNI plug-in randomly selects an unassigned IP address from the entire IP address set and assigns it to the Pod. In some application scenarios, relevant technologies allow application administrators to manually set several optional IP addresses as alternative IP addresses for a specified application from all IP addresses in the Kubernetes cluster. When allocating an IP address to the specified application, the CNI plug-in no longer randomly selects from the entire IP address set, but selects from the set alternative IP addresses, thereby achieving the purpose of setting several optional IP addresses for the specified application.
[0004] However, the above technical solution has the following shortcomings: First, specifying alternative IP addresses for applications requires manual configuration by application administrators, which is inefficient and error-prone. Second, for applications that don't have alternative IP addresses set, the CNI plugin still selects unassigned addresses from the IP address set, potentially preempting IP addresses specified by applications that already have alternative IP addresses, leaving applications with no available IP addresses. Furthermore, manually specifying several IP addresses as alternative IP addresses in the application's resource file means that if the alternative IP addresses are insufficient to meet application expansion requirements, the application's resource file must be manually modified and the application restarted for the modified resource file to take effect, significantly impacting the availability of the business system.
[0005] Therefore, it is necessary to provide an improved technical solution to the above-mentioned deficiencies in the prior art. Summary of the Invention
[0006] The purpose of this application is to provide a method, system, computer-readable storage medium and electronic device for uniformly allocating IP addresses based on a container cloud platform to solve or alleviate the problems existing in the above-mentioned prior art.
[0007] In order to achieve the above objectives, this application provides the following technical solutions:
[0008] This embodiment of the present application provides a method for uniformly allocating IP addresses based on a container cloud platform, including:
[0009] Creating at least one IP address pool based on a preset IP address pool resource file; the IP address pool resource file is used to define at least one IP address pool and the IP addresses contained in each IP address pool;
[0010] Establishing a binding relationship between a target application and a target IP address pool; the target application is any application in the container cloud platform, and the target IP address pool is any IP address pool defined in the IP address pool resource file;
[0011] In response to receiving a request to allocate an IP address to the application instance corresponding to the target application, based on the binding relationship between the target application and the target IP address pool, an IP address in an unallocated state is selected from the target IP address pool as the target IP address allocated to the application instance corresponding to the target application, and the state of the target IP address is marked as allocated.
[0012] In some implementations, the creating at least one IP address pool based on a preset IP address pool resource file is specifically:
[0013] In response to monitoring a change event of the IP address pool resource file, determining whether each IP address included in the IP address pool defined in the IP address pool resource file is in an available state;
[0014] If each IP address included in the IP address pool defined in the IP address pool resource file is in an available state, the IP address pool is created.
[0015] In some implementations, establishing a binding relationship between the target application and the target IP address pool is specifically:
[0016] An IP address pool label field is added to the resource file corresponding to the target application, and identification information of the target IP address pool is written into the IP address pool label field to establish the binding relationship.
[0017] In some implementations, establishing a binding relationship between the target application and the target IP address pool further includes:
[0018] An application affinity field of the target IP address pool is newly added in the IP address pool resource file, and identification information of the target application is written into the application affinity field of the target IP address pool to establish the binding relationship in both directions.
[0019] In some implementations, when the target application is bound to a plurality of the target IP address pools, each of the target IP address pools is set with a priority;
[0020] The step of selecting an unassigned IP address from the target IP address pool based on the binding relationship between the target application and the target IP address pool is as follows:
[0021] Based on the binding relationship between the target application and the target IP address pool, an IP address in an unallocated state is selected from a plurality of the target IP address pools in order of priority of the target IP address pools.
[0022] In some implementations, the method further includes:
[0023] If all IP addresses in the target IP address pool are in an allocated state, query the usage status of all IP addresses in the container cloud platform;
[0024] In response to the existence of an IP address in an available state in the container cloud platform, any of the IP addresses in the available state is assigned to the target IP address pool and written into the IP address pool resource file.
[0025] In some implementations, the method further includes:
[0026] In response to monitoring that the target IP address pool defined in the IP address pool resource file is deleted, the correspondence between the target IP address and the application instance corresponding to the target application remains unchanged.
[0027] The present invention provides a system for uniformly allocating IP addresses based on a container cloud platform, including:
[0028] A creating unit configured to create at least one IP address pool based on a preset IP address pool resource file; the IP address pool resource file is used to define at least one IP address pool and the IP addresses contained in each IP address pool;
[0029] A binding unit is configured to establish a binding relationship between a target application and a target IP address pool; the target application is any application in the container cloud platform, and the target IP address pool is any IP address pool defined in the IP address pool resource file;
[0030] An allocation unit is configured to, in response to receiving a request to allocate an IP address to an application instance corresponding to the target application, select an IP address in an unallocated state from the target IP address pool based on a binding relationship between the target application and the target IP address pool as the target IP address allocated to the application instance corresponding to the target application, and mark the state of the target IP address as allocated.
[0031] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is a method for uniformly allocating IP addresses based on a container cloud platform as described above.
[0032] An embodiment of the present application also provides an electronic device, comprising: a memory, a processor, and a program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for uniformly allocating IP addresses based on a container cloud platform as described above is implemented.
[0033] Beneficial effects:
[0034] In the technical solution of the present application, at least one IP address pool is created based on a preset IP address pool resource file; the IP address pool resource file is used to define at least one IP address pool, and the IP addresses contained in each IP address pool; then a binding relationship is established between the target application and the target IP address pool; when a request to allocate an IP address to an application instance corresponding to the target application is received, based on the binding relationship between the target application and the target IP address pool, an IP address in an unallocated state is selected from the target IP address pool as the target IP address allocated to the application instance corresponding to the target application, and the state of the target IP address is marked as allocated. In the above technical solution, all IP addresses in the container cloud platform are divided into multiple IP address pools, and the application is bound to the IP address pool, and an IP address in an unallocated state is selected from the target IP address pool that has a binding relationship with the target application and allocated to the target application, so that the target application will not preempt the IP addresses of other applications, nor will the bound IP addresses be preempted by other applications, thereby realizing the refined allocation of IP addresses and making the management and allocation of IP addresses more reasonable.
[0035] In addition, since the IP address pool is defined by the IP address pool resource file (address pool CRD), the definition of the IP address pool is unbound from the application's resource file. When deploying the target application, the application administrator only needs to establish a binding relationship between the target application and the target IP address pool. There is no need to manually specify alternative IPs one by one in the application's resource file. The target application can be allocated an IP address within the IP address range contained in the target IP address pool. When the IP address requirements of the target application change, the application administrator only needs to adjust the IP addresses contained in the target IP address pool in the IP address pool resource file. There is no need to modify the target application's resource file or restart the target application. The adjusted target IP address pool can meet the changed IP address requirements of the target application, thereby realizing flexible management of IP addresses, improving the efficiency of IP address management, and achieving high availability of the application. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The drawings and descriptions that constitute part of this application are intended to provide a further understanding of this application. The exemplary embodiments and descriptions of this application are intended to explain this application and do not constitute an improper limitation on this application. Among them:
[0037] Figure 1 A schematic diagram of IP address allocation in related technologies;
[0038] Figure 2 A logical diagram of a method for uniformly allocating IP addresses based on a container cloud platform according to some embodiments of the present application;
[0039] Figure 3 A logical diagram of a method for uniformly allocating IP addresses based on a container cloud platform according to other embodiments of the present application;
[0040] Figure 4 A flowchart of a method for uniformly allocating IP addresses based on a container cloud platform according to some embodiments of the present application is provided;
[0041] Figure 5 A schematic diagram of the structure of a system for uniformly allocating IP addresses based on a container cloud platform according to some embodiments of the present application;
[0042] Figure 6 A schematic structural diagram of an electronic device provided according to some embodiments of the present application;
[0043] Figure 7 A hardware structure diagram of an electronic device provided according to some embodiments of the present application. DETAILED DESCRIPTION
[0044] In order to facilitate understanding of the technical aspects of this application, the relevant technologies are explained below.
[0045] The container cloud platform is a lightweight cloud platform built on container technology, combined with cloud native technology, and using technologies such as containers, container orchestration, service mesh, and microservices.
[0046] Kubernetes is Google's open source container orchestration engine, used to manage containerized applications on multiple hosts in the cloud platform.
[0047] Kubernetes clusters are one of the most widely used container cloud platforms. They are clusters of multiple nodes deployed with the Kubernetes system. From a cluster management perspective, the Kubernetes system divides hosts in the cluster into control nodes and worker nodes. Control nodes run a set of cluster management-related programs to automatically manage resources, container group scheduling, elastic scaling, security controls, system monitoring, and error correction for the entire cluster. Worker nodes are used to deploy applications corresponding to business systems.
[0048] The Container Network Interface (CNI) is a set of specifications and libraries for configuring Linux container network interfaces, including network resource allocation interfaces and network resource release interfaces.
[0049] CNI plug-ins are a set of programs that implement the CNI specification. They are used to allocate network resources such as IP addresses to container groups when they are created, and to release the occupied IP addresses and other network resources when the container group is deleted.
[0050] When a container cloud platform (such as a Kubernetes cluster) creates a container group, it is necessary to allocate network resources such as an IP address to the created container group to enable the container group to communicate normally on the flat network.
[0051] In related technologies, the container cloud platform maintains IP address allocation data through the CNI plug-in. When a container group is created, the CNI plug-in is called to allocate network resources such as IP addresses to the container group.
[0052] Figure 1 A schematic diagram of how to allocate IP addresses to CNI plugins in related technologies. Figure 1 As shown in the figure, when a new application is deployed in a Kubernetes cluster, the Scheduler component selects a suitable node based on relevant screening conditions and scores, uses the suitable node as the scheduling target node for the application, and binds the application to the scheduling target node.
[0053] A Kubelet component is deployed on each node in a Kubernetes cluster. The Kubelet component monitors application scheduling through the API-Server component. After the target node determines that the application will be scheduled to itself, the Kubelet component of the target node creates a new Pod to deploy the application. During the Pod creation process, the Kubelet component sends an IP address allocation request to the CNI plug-in, instructing the CNI plug-in to allocate an IP address for the created Pod.
[0054] Specifically, when assigning an IP address to a created Pod, the CNI plug-in randomly selects an unassigned IP address from the entire IP address set consisting of all IP addresses in the Kubernetes cluster and binds the selected IP address to the Pod.
[0055] To meet the needs of some application scenarios, such as setting firewall policies based on application IP addresses, application administrators can set an alternative IP address field in the application's resource file (such as the application's deployment file), such as "annotaiton xxxxx / ips." They can then manually specify several IP addresses from the entire set of IP addresses as values for the alternative IP address field. For example, you can set "annotaiton xxxxx / ips:{"192.168.0.1","192.168.0.2","192.168.0.3"}" in the application's resource file to specify 192.168.0.1, 192.168.0.2, and 192.168.0.3 as the application's alternative IP addresses. This allows the CNI plugin to select only from these alternative IP addresses when allocating an IP address to the application, thereby limiting the application's IP address to a specific range and enabling refined IP address management for the application.
[0056] However, as described in the background of this application, manually setting a number of optional IP addresses in the alternative IP address field has the following problems:
[0057] 1. Application administrators need to manually set several alternative IP addresses, which is inefficient and prone to errors. In addition, since there is no verification mechanism, application administrators of different applications can specify the same IP address as the alternative IP address for the applications they manage, resulting in IP address allocation conflicts.
[0058] 2. To achieve zero service interruption, the same application often corresponds to multiple application instances, which jointly respond to access requests to the application. Each application instance must select an IP address from the application's candidate IP addresses for binding. In production practice, applications often scale up or down based on varying business loads, increasing or decreasing the number of application instances. However, once assigned, the number of candidate IP addresses for an application does not change with the expansion or reduction of the application. If the number of application instances exceeds the number of candidate IP addresses, the number of candidate IP addresses does not increase accordingly. Therefore, the application administrator must manually modify the value of the candidate IP address field in the application's resource file to re-plan the IP addresses. Otherwise, new application instances cannot be added, and capacity expansion cannot be completed, thus affecting service reliability. However, since the application's candidate IP address value is directly written into the candidate IP address field in the application's resource file, modifying the number of candidate IP addresses requires modifying the application's resource file. For the modified resource file to take effect, the application must be restarted, potentially causing service interruption and significantly impacting the availability of the business system.
[0059] 3. When assigning IP addresses to applications that don't have alternative IP addresses set in the Alternative IP Address field, the CNI plugin randomly selects an unassigned IP address from the entire set of IP addresses in the Kubernetes cluster. This may preempt the IP address specified by an application that has already set an alternative IP address, leaving the application with no available IP address. For example, if the Alternative IP Address field for Application A is set with 192.168.0.1, 192.168.0.2, and 192.168.0.3, while Application B, Application C, and Application D do not have an Alternative IP Address field, and the CNI plugin assigns 192.168.0.1, 192.168.0.2, and 192.168.0.3 to Application B, Application C, and Application D, respectively, deployed first, then Application A, deployed later, will find that all its alternative IP addresses are occupied, and the CNI plugin will be unable to assign an IP address to Application A.
[0060] After an in-depth analysis of the existing technology, the applicant found that when the CNI plug-in allocates IP addresses to different applications, it selects an unallocated IP address from the entire IP address set consisting of all IP addresses in the Kubernetes cluster. Although the relevant technology allows application administrators to manually set several optional IP addresses as alternative IP addresses for specified applications, this setting can only constrain the CNI plug-in to select an unallocated IP address from the set alternative IP addresses when allocating an IP address to the application, and cannot achieve the allocation of the set alternative IP address to the application. In other words, these alternative IP addresses still belong to the entire IP address set consisting of all IP addresses in the Kubernetes cluster and are not separated from the entire IP address set. When allocating IP addresses to applications other than this application, the CNI plug-in can still allocate these alternative IP addresses to other applications, which may result in the application having no IP address to allocate. Modifying the alternative IP address of the application requires modifying its corresponding resource file, which in turn affects the normal operation of the business.
[0061] To this end, the present application provides a method, system, computer-readable storage medium and electronic device for uniformly allocating IP addresses based on a container cloud platform. In this technical solution, at least one IP address pool is created based on a preset IP address pool resource file. The IP address pool resource file is used to define at least one IP address pool and the IP addresses contained in each IP address pool, and a binding relationship between a target application and a target IP address pool is established, so that when an IP address is allocated to an application instance of a target application, an IP address in an unallocated state can be selected from the target IP address pool based on the binding relationship between the target application and the target IP address pool as the target IP address allocated to the application instance corresponding to the target application. All IP addresses in the container cloud platform are divided into multiple IP address pools, and the application is bound to the IP address pool. An IP address in an unallocated state is selected from the target IP address pool that has a binding relationship with the target application and is allocated to the target application, so that the target application will not preempt the IP addresses of other applications, nor will the bound IP addresses be preempted by other applications, thereby achieving refined allocation of IP addresses and making the management and allocation of IP addresses more reasonable.
[0062] By defining the IP address pool and the IP addresses contained in each IP address pool through the IP address pool resource file, IP address planning is separated from IP address usage. When business load changes cause the target application to expand or shrink, only the IP addresses contained in the target IP address pool need to be changed in the IP address pool resource file. There is no need for the target application's resource file, and there is no need to restart the target application, so that IP address allocation can meet the needs of business load changes.
[0063] Exemplary Methods
[0064] The present application embodiment provides a method for uniformly allocating IP addresses based on a container cloud platform, such as Figures 2 to 4 As shown, the method includes:
[0065] Step S101: Create at least one IP address pool based on a preset IP address pool resource file.
[0066] The IP address pool resource file is used to define at least one IP address pool and the IP addresses contained in each IP address pool.
[0067] As mentioned above, in the traditional technical solution, all IP addresses in the Kubernetes cluster constitute the set of all IP addresses. When an IP address needs to be allocated to an application, the CNI plug-in randomly selects an IP address in an unallocated state from the set of all IP addresses for allocation. Due to the needs of the application scenario, the application administrator can specify several IP addresses from all IP addresses in the Kubernetes cluster and write them into the resource file corresponding to a specific application as alternative IP addresses. However, writing the alternative IP addresses into the resource file corresponding to a specific application brings various inconveniences to IP address management. To this end, this application adds a custom resource (Custom Resources Definition, CRD resource) to the cluster - IP address pool, that is, all IP addresses in the Kubernetes cluster are divided into multiple IP address pools through the IP address pool resource file, and each IP address pool resource file records the IP addresses contained in each IP address pool.
[0068] It should be understood that the IP address pool is a CRD resource set up to meet the needs of flexible and efficient management of IP addresses, and is proposed by this application to solve the shortcomings of traditional technical solutions. The embodiment of this application adds a CRD resource, the IP address pool, so that the backup IP address of the application does not need to be written into the resource file corresponding to the application, thereby realizing the unbinding of the backup IP address of the application from the application. When the business load changes and causes the target application to expand or shrink, it is only necessary to modify the content of the IP address pool resource file to change the IP addresses contained in the target IP address pool. Without modifying the resource file of the target application, the IP address allocation can meet the needs of business load changes, thereby improving the flexibility of IP address management.
[0069] Specifically, see Figure 2The IP addresses in a Kubernetes cluster are divided into multiple IP address pools in the form of YAML files, including but not limited to: IP address pool 1, IP address pool 2, and IP address pool 3. The API-Server component, Scheduler component, Kubelet component, and CNI plug-in are also deployed on the nodes of the Kubernetes cluster. After all the IP addresses in the cluster are divided into multiple IP address pools, the CNI plug-in maintains the IP address allocation data recorded in all IP address pools. When an application is scheduled to the node, the Kubelet component on the node calls the CNI plug-in to allocate an IP address to the Pod when creating the Pod for deploying the application instance. The CNI plug-in selects an unallocated IP address for the Pod based on the maintained IP address allocation data.
[0070] In order to ensure the correctness of IP address management and avoid duplicate allocation of IP addresses, some embodiments of the present application also provide a verification mechanism for the creation of IP address pools. At this time, at least one IP address pool is created based on a preset IP address pool resource file. Specifically: in response to a change event of the IP address pool resource file being monitored, it is determined whether each IP address contained in the IP address pool defined in the IP address pool resource file is in an available state; if each IP address contained in the IP address pool defined in the IP address pool resource file is in an available state, then an IP address pool is created.
[0071] It should be noted that an IP address in an available state means that the IP address has not been assigned to any other IP address pool and has not been allocated to any application instance as a public IP address.
[0072] Similarly, in some embodiments of the present application, a verification mechanism is also provided for the expansion of the IP address pool. At this time, at least one IP address pool is expanded based on the change event of the IP address pool resource file. Specifically, in response to monitoring the change event of the IP address pool resource file, it is determined whether each newly added IP address defined in the IP address pool resource file is in an available state; if at least one newly added IP address defined in the IP address pool resource file is in an available state, then at least one newly added IP address in an available state is assigned to the IP address pool to expand the IP address pool.
[0073] In an embodiment of the present application, the verification mechanism for creating or expanding the IP address pool can be implemented through the WebHook mechanism of the container cloud platform, or through the custom address pool controller provided by this application.
[0074] When an address pool controller is used to provide verification for the creation and expansion of an IP address pool, the address pool controller continuously monitors the change events of the IP address pool resource file. When an event of creating an IP address pool resource file or updating an IP address pool resource file is monitored, each IP address contained in the IP address pool defined in the IP address pool resource file is traversed, and it is determined whether each IP address is in an available state, or whether there is at least one newly added IP address in an available state. If so, the IP address pool is created, or the newly added IP addresses in an available state are assigned to the IP address pool. Otherwise, a message indicating that the IP address pool creation or expansion failed is returned. Verification through the address pool controller can be combined with the IP address pool resource file to make the verification logic more complete.
[0075] Specifically, taking the Kubernetes cluster as an example, see Figure 3 , Kubernetes cluster includes control nodes and worker nodes. The address pool controller is deployed in the control node of the Kubernetes cluster. The IP address pool resource file, namely the address pool CRD, is used to divide all IP addresses in the cluster into multiple IP address pools. Multiple IP address pools defined in the same address pool CRD can form an IP address pool group. The address pool controller monitors the change events of the address pool CRD through the API-Server component. Once the IP address pool CRD creation or update event is monitored, each IP address in the IP address pool defined in the address pool CRD is traversed, and each IP address is determined whether each IP address is in an available state, or whether there is at least one newly added IP address in an available state. If so, the IP address pool is created, or the newly added IP addresses in an available state are assigned to the IP address pool.
[0076] It should be noted that in some special scenarios, a part of the IP addresses in the cluster are allowed not to be assigned to any IP address pool, so as to reserve this part of the IP addresses for the cluster and use them as public IP addresses for flexible allocation by the cluster administrator. To this end, in an embodiment of the present application, determining whether each IP address is in an available state includes: first determining whether the current IP address traversed has been assigned to a certain IP address pool. If so, a message indicating that the creation or expansion failed is returned to avoid repeated allocation of the IP address; if the current IP address has not been assigned to any IP address pool, further determining whether the current IP address is in an occupied state. If so, it indicates that the IP address is a public IP address and has been occupied by an application instance. At this time, a message indicating that the creation or expansion failed is still returned to avoid IP address conflicts.
[0077] Step S102: Establish a binding relationship between the target application and the target IP address pool.
[0078] The target application is any application in the container cloud platform, and the target IP address pool is any IP address pool in the IP address pool defined in the IP address pool resource file.
[0079] After the IP addresses of the cluster are divided into multiple IP address pools, in order to allocate an IP address in any IP address pool (target IP address pool) to a specified application (target application), a binding relationship between the target application and the target IP address pool needs to be established.
[0080] It should be understood that there are many specific implementation methods for establishing a binding relationship between the target application and the target IP address pool, such as establishing a relationship table in the database and recording the correspondence between the target application and the target IP address pool in the relationship table; for example, adding a new custom resource and recording the correspondence between the target application and the target IP address pool in the new custom resource. The embodiments of the present application do not limit this.
[0081] To simplify operations and facilitate management, in an embodiment of the present application, a binding relationship is established between the target application and the target IP address pool. Specifically, a new IP address pool label field is added to the resource file corresponding to the target application, and the identification information of the target IP address pool is written into the IP address pool label field to establish a binding relationship.
[0082] In an embodiment of the present application, by adding an IP address pool label field (such as the annotation field of the Deployment file) in the resource file corresponding to the target application (such as the Deployment file), the identification information of the target IP address pool is set to establish a binding relationship between the target application and the target IP address pool. Among them, the identification information of the target IP address pool can be the name of the IP address pool defined in the IP address pool resource file, or the unique identifier UUID automatically assigned when the IP address pool is created. Therefore, when deploying the target application, the application administrator only needs to set the identification information of the target IP address pool in the IP address pool label field of the resource file corresponding to the target application to establish a binding relationship between the target application and the target IP address pool. It is simple, convenient and easy to operate.
[0083] Since the target IP address pool can be found through the identification information of the target IP address pool, and unassigned IP addresses can be selected from the IP addresses contained in the target IP address pool and allocated to the target application, compared with the original method of manually writing several IP addresses one by one in the resource file of the application, the target IP address pool is bound to the target application by writing the identification information of the target IP address pool, which improves management efficiency and reduces the possibility of errors when the application administrator sets field values.
[0084] It should be understood that the target application can select one IP address pool as the target IP address pool and write the identification information of the target IP address pool into the IP address pool tag field to establish a binding relationship with the one IP address pool; the target application can also select multiple IP address pools as the target IP address pools and write the identification information of the multiple target IP address pools into the IP address pool tag field to establish binding relationships with the multiple target IP address pools. This embodiment of the present application is not limited to this.
[0085] Furthermore, in order to prevent multiple applications from selecting the same IP address pool and causing a shortage of IP address resources, in some implementations, a constraint mechanism can be added to the process of establishing a binding relationship. Specifically, the address pool controller can also be used to monitor the change event of the IP address pool label field of the target application. When the IP address pool label field of the target application is monitored to change, it is determined whether the IP address pool identification information bound in the IP address pool label field matches the identification information of the created IP address pool. If so, it is further determined whether the IP address pool has a binding relationship with other applications other than the target application. If the IP address pool does not have a binding relationship with other applications other than the target application, the IP address pool is used as the target IP address pool, and its identification information is written into the IP address pool label field of the target application to establish a binding relationship between the two.
[0086] By adding an IP address pool label field to the target application's corresponding resource file to establish a binding relationship between the target application and the target IP address pool, the CNI plugin can use this binding relationship to locate the target IP address pool when allocating an IP address to the target application and select an unassigned IP address from the target IP address pool to allocate to the target application. Because the target IP address pool is separated from the cluster's overall IP address pool as a CRD resource, combined with the constraints of the binding process, applications that do not have the IP address pool label field set cannot preempt the IP address resources planned by the target application, thus ensuring that each application receives its planned IP address allocation.
[0087] By adding a binding constraint mechanism, you can ensure that the binding relationship between the target application and the target IP address pool is unique, preventing the target application from specifying an occupied IP address pool to bind to it, causing multiple applications to occupy the same IP address pool and resulting in insufficient IP address resources.
[0088] In some scenarios, it is also possible to prevent multiple applications from occupying the same IP address pool and enable multiple applications to share multiple IP address pools by establishing a two-way binding relationship between the target application and the target IP address pool. Specifically, establishing a binding relationship between the target application and the target IP address pool also includes: adding an application affinity field of the target IP address pool in the IP address pool resource file, and writing the identification information of the target application into the application affinity field of the target IP address pool to establish a two-way binding relationship.
[0089] In an embodiment of the present application, an application affinity field of the target IP address pool is added to the IP address pool resource file, for example, a podAffinity field is added to the address pool CRD, which is used to set the identification information of the target application, such as writing the name of the target application or the ID of the target application in the podAffinity field of the address pool CRD, to achieve two-way binding between the target IP address pool and the target application, so as to prevent the incorrect IP address allocation of the application due to the incorrect setting of the IP address pool label field of the target application or the application affinity field value of the target IP address pool, and to prevent too many applications from selecting the same IP address pool and causing a shortage of IP addresses.
[0090] Taking Kubernetes as an example, when deploying the target application to the Kubernetes cluster, in order to achieve two-way binding between the target application and the target IP address pool, the application administrator needs to set the identification information of the target IP address pool in the IP address pool label field in the resource file corresponding to the target application. In addition, the application administrator should also set the podAffinity field in the address pool CRD file corresponding to the target IP address pool to the identification information of the target application.
[0091] It should be noted that once the target IP address pool has a two-way binding relationship with the target application, the CNI plug-in will allocate the IP address for the target application only after determining the two-way binding relationship. Specifically, the CNI plug-in first determines the target IP address pool bound to the target application based on the value of the IP address pool label field in the resource file corresponding to the target application. Then, based on the application affinity field in the target IP address pool, it reversely determines whether the target application exists in the applications that have affinity with the target IP address pool. If so, the CNI plug-in selects an IP address in an unallocated state from the target IP address pool and allocates it to the target application. Otherwise, the CNI plug-in still does not select an IP address in an unallocated state from the target IP address pool and allocates it to the target application. Therefore, on the one hand, it can prevent IP address allocation errors caused by incorrectly setting the IP address pool label field of the target application or the application affinity field of the target application. On the other hand, it can also prevent multiple applications from being bound to the same IP address pool and causing a shortage of IP address resources.
[0092] It should be noted that in an embodiment of the present application, the IP address pool label field of the target application can be set with identification information of one or more target IP address pools. Correspondingly, the application affinity field of the target IP address pool can be set with identification information of one or more target applications. Thus, the CNI plug-in can select an unallocated IP address from one or more target IP address pools and assign it to the target application. At the same time, multiple target IP address pools can also be shared among multiple target applications. In this way, not only can one or more applications be bound with an exclusive IP address pool to meet the needs of different application scenarios, such as enabling the application to allocate IP addresses in a fixed IP address range in a rolling manner to cooperate with the firewall to set a release policy for the application, but also, as the application expands, the size of the target IP address pool or the number of target IP address pools can increase accordingly, providing application administrators with greater flexibility in IP address management.
[0093] Step S103: In response to receiving a request to allocate an IP address to an application instance corresponding to a target application, based on the binding relationship between the target application and the target IP address pool, an IP address in an unallocated state is selected from the target IP address pool as the target IP address allocated to the application instance corresponding to the target application, and the state of the target IP address is marked as allocated.
[0094] As mentioned above, in order to achieve zero service interruption, the same application usually corresponds to multiple application instances, and each application instance needs to be assigned an IP address. In an embodiment of the present application, based on the binding relationship between the target application and the target IP address pool established in step S102, when the CNI plug-in receives a request to allocate an IP address for the application instance corresponding to the target application, the CNI plug-in selects an IP address in an unallocated state from the target IP address pool according to the IP address allocation data recorded in the target IP address pool, as the target IP address assigned to the application instance corresponding to the target application, binds the target IP address to the Pod where the application instance is located, and also assigns the target IP address to the application instance. At the same time, the target IP address is marked as allocated in the IP address allocation data of the target IP address pool.
[0095] Specifically, see Figure 3 The CNI plug-in is deployed in the worker node of the Kubernetes cluster. At the same time, the application instance corresponding to the target application will also be deployed in the Pod of the worker node. During the process of creating the Pod for deploying the application instance, the Kubelet component sends a request to the CNI plug-in to allocate an IP address for the Pod, thereby calling the CNI plug-in to allocate an IP address for the Pod.
[0096] It should be noted that CNI plugins can be divided into three categories: main plugins, IPAM plugins, and meta plugins. The main plugin is used to create binary files for specific network devices; the IPAM plugin is responsible for assigning IP addresses to pods in the Kubernetes cluster; and the meta plugin is an extension plugin that must be implemented in conjunction with the main and IPAM plugins.
[0097] Based on the functions of the above three types of CNI plug-ins, the specific process of the Kubelet component calling the CNI plug-in to allocate an IP address to the Pod is as follows: the Kubelet component calls the main plug-in, and the main plug-in then calls the IPAM plug-in to allocate an IP address to the Pod.
[0098] In order to break through the limitation of the original CNI plug-in selecting unallocated IP addresses from the entire IP address set for allocation, and to realize the allocation of IP addresses to application instances of target applications from the target IP address pool, in the embodiment of the present application, IP address pool resource files, address pool controllers and address pool agents are used to replace the original IPAM plug-in to allocate IP addresses to application instances of target applications.
[0099] Specifically, see Figure 3 Deploy an IP address pool and address pool controller as a Deployment on any node in the Kubernetes cluster (such as the control node). Deploy the address pool proxy as a Daemonset on all worker nodes in the Kubernetes cluster. The address pool controller is a custom controller that creates and maintains multiple IP address pools based on the contents of the IP address pool resource file. The address pool proxy interfaces with the IPAM plugin, receives requests from the IPAM plugin to allocate IP addresses to pods, and responds to those requests.
[0100] Specifically, when the application instance corresponding to the target application is scheduled to a working node in the Kubernetes cluster, the Kubelet component on the working node creates a Pod for deploying the application instance and sends a request to the CNI plug-in to allocate an IP address for the Pod. The address pool agent on the working node receives the request for allocating an IP address forwarded by the IPAM plug-in in the CNI plug-in, and determines the target IP address pool corresponding to the target application deployed on the Pod and the affinity relationship with the target application recorded in the application affinity field of the target IP address pool through the API-Server component on the access control node. If it is determined that the IP address pool field of the target application records the identification information of the target IP address pool, then according to the IP address allocation data of the target IP address pool maintained by the CNI plug-in, an IP address in an unallocated state is selected from the target IP address pool as the target IP address, and the target IP address is bound to the Pod, and then the target IP address is marked as allocated.
[0101] Furthermore, when the target application is bound to multiple target IP address pools, each target IP address pool is set with a priority; based on the binding relationship between the target application and the target IP address pool, an IP address in an unallocated state is selected from the target IP address pool, specifically: based on the binding relationship between the target application and the target IP address pool, an IP address in an unallocated state is selected from multiple target IP address pools in the order of the priority of the target IP address pool.
[0102] In an embodiment of the present application, the address pool agent receives a request for allocating an IP address forwarded from the IPAM plug-in, determines the target IP address pool corresponding to the target application deployed on the Pod by accessing the API-Server component on the control node, and when it is determined that there are multiple target IP address pools, selects an unassigned IP address from the multiple target IP address pools in order of priority as the target IP address and binds it to the Pod. By setting the priority of the target IP address pool, the target application can specify certain IP addresses for priority use according to the specific needs of the business, further improving the flexibility of IP address management.
[0103] Specifically, the priority of the target IP address pool can be set in multiple ways. For example, the address pool agent can determine the priority of the target IP address pool based on the order of arrangement of multiple target IP address pools. The higher the arrangement, the higher the priority. For another example, weight information can be set for each IP address pool. The larger the weight, the higher the priority. For another example, the priority of the target IP address pool can be determined based on the allocation status of the IP addresses in each IP address pool. The more IP addresses in the unallocated state, the higher the priority. This application does not limit the specific expression of priority.
[0104] When the business load increases, all IP addresses in the target IP address pool may be allocated. To this end, in some embodiments, the method further includes: if all IP addresses contained in the target IP address pool are in an allocated state, querying the usage status of all IP addresses in the container cloud platform; in response to the existence of an IP address in an available state in the container cloud platform, assigning any IP address in an available state to the target IP address pool and writing it into the IP address pool resource file.
[0105] In the embodiment of the present application, since the IP address pool is managed through the IP address pool resource file, the management of the IP address pool is decoupled from the management of the application, and the two are no longer coupled. When all IP addresses in the target IP address pool are occupied, as long as there are still available IP addresses in the container cloud platform, any available IP address can be assigned to the target IP address pool, thereby expanding the target IP address pool without any impact on the target application.
[0106] In some embodiments, the method further includes: in response to monitoring that the target IP address pool defined in the IP address pool resource file is deleted, the correspondence between the target IP address and the application instance corresponding to the target application remains unchanged.
[0107] In the embodiment of the present application, once the target IP address is assigned to the application instance corresponding to the target application, a corresponding relationship between the target IP address and the application instance corresponding to the target application is established. When the target IP address pool defined in the IP address pool resource file is deleted, if the target IP address pool contains an IP address in an allocated state (such as a target IP address), then the target IP address pool will not be deleted, but will enter a deleting state. At this time, the corresponding relationship between the target IP address and the application instance corresponding to the target application will remain unchanged, that is, the target IP address still belongs to the target IP address pool, and the target IP address continues to be occupied by the application instance of the corresponding target application. However, the IP address in an unallocated state contained in the target IP address pool in the deleting state cannot be assigned to any application instance.
[0108] The target IP address pool will only be truly deleted after it is monitored that all allocated IP addresses contained in the target IP address pool are released (for example, the Pod where the application instance corresponding to the target application is located releases the occupied target IP address, the correspondence between the target IP address and the application instance corresponding to the target application is released, and the target IP address becomes unallocated again). All the IP addresses contained in the pool will be designated as public IP addresses and can be assigned to other IP address pools. In this way, the deletion operation of the target IP address pool will not have any impact on the target application.
[0109] Taking the Kubernetes system as an example, the method of uniformly allocating IP addresses based on the container cloud platform can be performed as follows:
[0110] Step 1: The Scheduler component monitors the API-Server component of the Kubernetes cluster;
[0111] Step 2: After the Scheduler component detects a new application (i.e., the target application) deployed to the Kubernetes cluster, it screens all nodes in the Kubernetes cluster and selects the node with the highest score based on the resource usage of the screened nodes as the target node for application scheduling.
[0112] Step 3: After the Kubelet component in the target node monitors the target application being scheduled to the node through the API-Server component, it creates a new Pod and calls the CNI plug-in to assign an IP address to the Pod;
[0113] Step 4: The IPAM plug-in in the CNI plug-in sends the received request to allocate an IP address to the address pool agent for processing. The address pool agent determines the target IP address pool corresponding to the target application based on the identification information of the target IP address pool set in the IP address pool label field (such as the annotation field) in the Deployment file corresponding to the target application, and checks to confirm whether the application affinity field (such as the podAffinity field) of the target IP address pool in the IP address pool resource file (address pool CRD file) is set with the identification information of the target application. After confirmation, an unassigned IP address is selected as the target IP address based on the IP address allocation data recorded in the target IP address pool, and the target IP address is bound to the Pod.
[0114] Step 5: The address pool agent marks the target IP address as allocated in the IP address allocation data.
[0115] In summary, in an embodiment of the present application, at least one IP address pool is created based on a preset IP address pool resource file; the IP address pool resource file is used to define at least one IP address pool, and the IP addresses contained in each IP address pool; then a binding relationship is established between the target application and the target IP address pool; when a request to allocate an IP address to an application instance corresponding to the target application is received, based on the binding relationship between the target application and the target IP address pool, an IP address in an unallocated state is selected from the target IP address pool as the target IP address allocated to the application instance corresponding to the target application, and the state of the target IP address is marked as allocated. In the above technical solution, all IP addresses in the container cloud platform are divided into multiple IP address pools, and the application is bound to the IP address pool, and an IP address in an unallocated state is selected from the target IP address pool that has a binding relationship with the target application and allocated to the target application, so that the target application will not preempt the IP addresses of other applications, nor will the bound IP addresses be preempted by other applications, thereby realizing the refined allocation of IP addresses and making the management and allocation of IP addresses more reasonable.
[0116] In addition, since the IP address pool is defined by the IP address pool resource file (address pool CRD), the definition of the IP address pool is unbound from the application's resource file. When deploying the target application, the application administrator only needs to establish a binding relationship between the target application and the target IP address pool. There is no need to manually specify alternative IPs one by one in the application's resource file. The target application can be allocated an IP address within the IP address range contained in the target IP address pool. When the IP address requirements of the target application change, the application administrator only needs to adjust the IP addresses contained in the target IP address pool in the IP address pool resource file. There is no need to modify the target application's resource file or restart the target application. The adjusted target IP address pool can meet the changed IP address requirements of the target application, thereby realizing flexible management of IP addresses, improving the efficiency of IP address management, and achieving high availability of the application.
[0117] Exemplary Systems
[0118] The embodiment of the present application provides a system for uniformly allocating IP addresses based on a container cloud platform, such as Figure 5 As shown, the system includes: a creation unit 501, a binding unit 502 and an allocation unit 503. Among them:
[0119] The creating unit 501 is configured to create at least one IP address pool based on a preset IP address pool resource file; the IP address pool resource file is used to define at least one IP address pool and the IP addresses contained in each IP address pool.
[0120] The binding unit 502 is configured to establish a binding relationship between the target application and the target IP address pool; the target application is any application in the container cloud platform, and the target IP address pool is any IP address pool defined in the IP address pool resource file.
[0121] The allocation unit 503 is configured to, in response to receiving a request to allocate an IP address to an application instance corresponding to a target application, select an IP address in an unallocated state from the target IP address pool based on the binding relationship between the target application and the target IP address pool as the target IP address allocated to the application instance corresponding to the target application, and mark the state of the target IP address as allocated.
[0122] The system for uniformly allocating IP addresses based on a container cloud platform provided in the embodiments of the present application can implement the processes and steps of the method for uniformly allocating IP addresses based on a container cloud platform in any of the above embodiments and achieve the same technical effects, which will not be described in detail here.
[0123] Exemplary devices
[0124] Figure 6 Schematic diagram of the structure of an electronic device according to some embodiments of the present application; Figure 6 As shown, the electronic device includes:
[0125] One or more processors 601;
[0126] A computer-readable medium can be configured to store one or more programs 602. When one or more processors 601 execute one or more programs 602, the following steps are implemented: creating at least one IP address pool based on a preset IP address pool resource file; the IP address pool resource file is used to define at least one IP address pool and the IP addresses contained in each IP address pool; establishing a binding relationship between a target application and a target IP address pool; the target application is any application in the container cloud platform, and the target IP address pool is any IP address pool in the IP address pool defined by the IP address pool resource file; in response to receiving a request to allocate an IP address to an application instance corresponding to the target application, based on the binding relationship between the target application and the target IP address pool, selecting an IP address in an unallocated state from the target IP address pool as the target IP address allocated to the application instance corresponding to the target application, and marking the state of the target IP address as allocated.
[0127] Figure 7 The hardware structure of the electronic device provided according to some embodiments of the present application; Figure 7 As shown, the hardware structure of the electronic device may include: a processor 701 , a communication interface 702 , a computer-readable medium 703 and a communication bus 704 .
[0128] The processor 701 , the communication interface 702 , and the computer-readable storage medium 703 communicate with each other via a communication bus 704 .
[0129] Optionally, the communication interface 702 may be an interface of a communication module, such as an interface of a GSM module.
[0130] Among them, the processor 701 can be specifically configured to: create at least one IP address pool based on a preset IP address pool resource file; the IP address pool resource file is used to define at least one IP address pool, and the IP addresses contained in each IP address pool; establish a binding relationship between the target application and the target IP address pool; the target application is any application in the container cloud platform, and the target IP address pool is any IP address pool in the IP address pool defined by the IP address pool resource file; in response to receiving a request to allocate an IP address to an application instance corresponding to the target application, based on the binding relationship between the target application and the target IP address pool, select an IP address in an unallocated state from the target IP address pool as the target IP address assigned to the application instance corresponding to the target application, and mark the state of the target IP address as allocated.
[0131] The processor 701 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc., and may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The various methods, steps, and logic block diagrams disclosed in the embodiments of this application may be implemented or executed. The general-purpose processor may be a microprocessor or any conventional processor.
[0132] The electronic devices of the embodiments of the present application exist in various forms, including but not limited to:
[0133] (1) Mobile communication devices: These devices are characterized by their mobile communication capabilities and are primarily designed to provide voice and data communications. These terminals include smartphones (e.g., iPhones), multimedia phones, feature phones, and low-end phones.
[0134] (2) Ultra-mobile personal computer devices: These devices fall under the category of personal computers, have computing and processing capabilities, and generally also have mobile Internet access. These terminals include PDAs, MIDs, and UMPCs, such as the iPad.
[0135] (3) Portable entertainment devices: These devices can display and play multimedia content. These devices include audio and video players (e.g., iPods), handheld game consoles, e-books, smart toys, and portable car navigation devices.
[0136] (4) Server: A device that provides computing services. The server consists of a processor, hard disk, memory, system bus, etc. The server is similar to a general computer architecture, but because it needs to provide highly reliable services, it has higher requirements in terms of processing power, stability, reliability, security, scalability, and manageability.
[0137] (5) Other electronic devices with data interaction functions.
[0138] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present application can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present application.
[0139] The above-mentioned method according to the embodiment of the present application can be implemented in hardware, firmware, or implemented as software or computer code that can be stored in a recording medium (such as a CD ROM, RAM, floppy disk, hard disk or magneto-optical disk), or implemented as computer code originally stored in a remote recording medium or a non-temporary machine storage medium downloaded via a network and to be stored in a local recording medium, so that the method described herein can be stored in such software processing on a recording medium using a general-purpose computer, a dedicated processor or programmable or dedicated hardware (such as an ASIC or FPGA). It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor or hardware, the method for uniformly allocating IP addresses based on a container cloud platform described herein is implemented. In addition, when a general-purpose computer accesses the code for implementing the method shown herein, the execution of the code converts the general-purpose computer into a dedicated computer for executing the method shown herein.
[0140] Those skilled in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of this application.
[0141] It should be noted that the various embodiments in this specification are described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the device and system embodiments are generally similar to the method embodiments, so their descriptions are relatively simple. For relevant parts, refer to the descriptions of the method embodiments.
[0142] The device and system embodiments described above are merely illustrative. Units described as separate components may or may not be physically separate, and components described as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of these modules may be selected based on actual needs to achieve the objectives of the present embodiments. Persons of ordinary skill in the art will be able to understand and implement the present embodiments without inventive effort.
[0143] The foregoing description is merely a preferred embodiment of the present application and is not intended to limit the present application. Various modifications and variations are readily apparent to those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present application shall be included within the scope of protection of the present application.
Claims
1. A method for uniformly allocating IP addresses based on a container cloud platform, characterized in that: include: Create at least one IP address pool based on a preset IP address pool resource file; The IP address pool resource file is used to define at least one IP address pool and the IP addresses contained in each IP address pool; Establishing a binding relationship between a target application and a target IP address pool; the target application is any application in the container cloud platform, and the target IP address pool is any IP address pool defined in the IP address pool resource file; In response to receiving a request to allocate an IP address to the application instance corresponding to the target application, based on a binding relationship between the target application and the target IP address pool, select an IP address in an unallocated state from the target IP address pool as the target IP address to be allocated to the application instance corresponding to the target application, and mark the state of the target IP address as allocated; The establishing of the binding relationship between the target application and the target IP address pool is specifically as follows: Adding an IP address pool label field in the resource file corresponding to the target application, and writing the identification information of the target IP address pool into the IP address pool label field to establish the binding relationship; The establishing of a binding relationship between the target application and the target IP address pool further includes: An application affinity field of the target IP address pool is newly added in the IP address pool resource file, and identification information of the target application is written into the application affinity field of the target IP address pool to establish the binding relationship in both directions.
2. The method for uniformly allocating IP addresses based on a container cloud platform according to claim 1, characterized in that: The step of creating at least one IP address pool based on a preset IP address pool resource file is as follows: In response to monitoring a change event of the IP address pool resource file, determining whether each IP address included in the IP address pool defined in the IP address pool resource file is in an available state; If each IP address included in the IP address pool defined in the IP address pool resource file is in an available state, the IP address pool is created.
3. The method for uniformly allocating IP addresses based on a container cloud platform according to claim 1, characterized in that: In the case where the target application is bound to a plurality of the target IP address pools, each of the target IP address pools is set with a priority; The step of selecting an unassigned IP address from the target IP address pool based on the binding relationship between the target application and the target IP address pool is as follows: Based on the binding relationship between the target application and the target IP address pool, an IP address in an unallocated state is selected from a plurality of the target IP address pools in order of priority of the target IP address pools.
4. The method for uniformly allocating IP addresses based on a container cloud platform according to claim 1, characterized in that: Also includes: If all IP addresses in the target IP address pool are in an allocated state, query the usage status of all IP addresses in the container cloud platform; In response to the existence of an IP address in an available state in the container cloud platform, any of the IP addresses in the available state is assigned to the target IP address pool and written into the IP address pool resource file.
5. The method for uniformly allocating IP addresses based on a container cloud platform according to claim 1, characterized in that: Also includes: In response to monitoring that the target IP address pool defined in the IP address pool resource file is deleted, the correspondence between the target IP address and the application instance corresponding to the target application remains unchanged.
6. A system for uniformly allocating IP addresses based on a container cloud platform, characterized in that: include: A creating unit configured to create at least one IP address pool based on a preset IP address pool resource file; The IP address pool resource file is used to define at least one IP address pool and the IP addresses contained in each IP address pool; A binding unit is configured to establish a binding relationship between a target application and a target IP address pool; the target application is any application in the container cloud platform, and the target IP address pool is any IP address pool defined in the IP address pool resource file; an allocating unit configured to, in response to receiving a request to allocate an IP address to an application instance corresponding to the target application, select an IP address in an unallocated state from the target IP address pool based on a binding relationship between the target application and the target IP address pool as a target IP address to be allocated to the application instance corresponding to the target application, and mark a state of the target IP address as allocated; The establishing of the binding relationship between the target application and the target IP address pool is specifically as follows: Adding an IP address pool label field in the resource file corresponding to the target application, and writing the identification information of the target IP address pool into the IP address pool label field to establish the binding relationship; The establishing of a binding relationship between the target application and the target IP address pool further includes: An application affinity field of the target IP address pool is newly added in the IP address pool resource file, and identification information of the target application is written into the application affinity field of the target IP address pool to establish the binding relationship in both directions.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for uniformly allocating IP addresses based on a container cloud platform are implemented as described in any one of claims 1 to 5.
8. An electronic device, characterized in that: include: A memory, a processor, and a program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the method for uniformly allocating IP addresses based on a container cloud platform as described in any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Method and device for allocating network IP resources in cloud computing environment
CN105589749A
Method and system for allocating IP addresses to containers
CN107580083A