CN111124604B - Method, device, equipment and storage medium for distributing pod IP address - Google Patents

Method, device, equipment and storage medium for distributing pod IP address Download PDF

Info

Publication number
CN111124604B
CN111124604B CN201911237032.2A CN201911237032A CN111124604B CN 111124604 B CN111124604 B CN 111124604B CN 201911237032 A CN201911237032 A CN 201911237032A CN 111124604 B CN111124604 B CN 111124604B
Authority
CN
China
Prior art keywords
container group
target container
group pod
pod
address
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911237032.2A
Other languages
Chinese (zh)
Other versions
CN111124604A (en
Inventor
赵帅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Beijing Kingsoft Cloud Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology Co Ltd
Beijing Kingsoft Cloud Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Cloud Network Technology Co Ltd, Beijing Kingsoft Cloud Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN201911237032.2A priority Critical patent/CN111124604B/en
Publication of CN111124604A publication Critical patent/CN111124604A/en
Application granted granted Critical
Publication of CN111124604B publication Critical patent/CN111124604B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5007Internet protocol [IP] addresses
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/4557Distribution of virtual machine instances; Migration and load balancing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45591Monitoring or debugging support
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45595Network integration; Enabling network access in virtual machine instances

Abstract

The invention discloses a method, a device, equipment and a storage medium for distributing pod IP addresses. The method is applied to the computing nodes in the Kubernetes cluster, and comprises the following steps: acquiring a container group pod of an IP address to be allocated as a target container group pod; determining whether the target container group pod belongs to a set type according to the type information of the target container group pod, wherein the name of the container group pod of the set type is unchanged; under the condition that the target container group pod belongs to a set type, searching the name of the target container group pod in a database of the Kubernetes cluster; in the case where the name of the target container group pod is found, an IP address corresponding to the name of the target container group pod is assigned to the target container group pod. Thus, the target container group pod belonging to the set type will have the same name as the container group pod before reconstruction. Meanwhile, since any information of the configuration file corresponding to the target container group pod is not modified, the configuration file of the target container group pod can be used across clusters.

Description

Method, device, equipment and storage medium for distributing pod IP address
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a method, an apparatus, a device, and a storage medium for allocating pod IP addresses of a container group.
Background
Kubernetes is a container-based cluster management platform, and a Kubernetes cluster includes a Master Node (Master) and a plurality of computing nodes (nodes) respectively communicatively connected to the Master Node. The master node is used to manage and control the plurality of computing nodes. The computing nodes are workload nodes, each of which is provided with a plurality of Container groups (Pod), each Container group is packaged with one or more containers (containers) for bearing software programs, the Pod is a basic operation unit of Kubernetes and is the smallest deployment unit capable of being created, debugged and managed, and a plurality of containers in the same Pod share network resources, for example, one Pod has only one IP address, and a plurality of containers in the same Pod share the IP address.
When a compute node fails, the set of containers pod deployed on that compute node will be rebuilt. Or when a container group pod on a computing node fails, the failed container group pod will be rebuilt. When the container group pod is rebuilt, the rebuilt container group pod is allocated an IP address by the deployed computing node. And the IP address is typically a new IP address that is different from the IP address of the container group pod before rebuilding. However, when the IP address of the rebuilt container group pod changes, the specific software program carried in the container contained therein will not operate normally.
In order to avoid that a specific software program cannot normally run, some network components in the Kubernetes cluster, such as a calico, may be utilized, and by setting a fixed IP address for the container group pod in a configuration file of the container group pod, the reconstructed container group pod of the container group pod still has the same IP address as the IP address of the container group pod before reconstruction.
However, since the IP network segment of the fixed IP address set for the container group pod in the configuration file of the container group pod is an IP network segment of the Kubernetes cluster where the container group pod is located, and the IP network segments among the Kubernetes clusters are generally different, after the fixed IP address is set for the container group pod in the configuration file of the container group pod, the configuration file cannot be applied to other Kubernetes clusters.
Disclosure of Invention
It is an object of the present invention to provide a new solution for assigning pod IP addresses of a group of containers.
According to a first aspect of the present invention, there is provided a method of assigning container group pod IP addresses, the method being applied to computing nodes in a Kubernetes cluster, the method comprising:
acquiring a container group pod of an IP address to be allocated as a target container group pod;
determining whether the target container group pod belongs to a set type according to the type information of the target container group pod, wherein the name of the container group pod of the set type is unchanged;
searching the name of the target container group pod in a database of the Kubernetes cluster under the condition that the target container group pod belongs to the set type;
and in the case that the name of the target container group pod is found, assigning an IP address corresponding to the name of the target container group pod to the target container group pod.
Optionally, the method further comprises:
extracting a first IP address from an IP address pool in a Kubernetes cluster under the condition that the target container group pod does not belong to the set type; the IP address pool stores unassigned IP addresses;
and allocating the first IP address to the target container group pod.
Optionally, the method further comprises:
extracting a second IP address from an IP address pool in a Kubernetes cluster under the condition that the name of the target container group pod is not found; the IP address pool stores unassigned IP addresses;
assigning the second IP address to the target container group pod;
and uploading the name of the target container group pod and the second IP address to a database of the Kubernetes cluster.
Optionally, in the case that the target container group pod belongs to the set type, searching a database of the Kubernetes cluster for a name of the target container group pod includes:
searching whether a mapping relation between the name and the IP address of the container group pod is stored in a database of the Kubernetes cluster under the condition that the target container group pod belongs to the set type;
under the condition that the mapping relation is not stored in the database of the Kubernetes cluster, the database of the Kubernetes cluster is instructed to establish the mapping relation;
and searching the name of the target container group pod in the database of the Kubernetes cluster under the condition that the mapping relation is stored in the database of the Kubernetes cluster.
Optionally, the method further comprises:
and outputting the IP address allocated for the target container group pod.
Optionally, the method further comprises:
responding to a deleting request for deleting the target container group pod with the allocated IP address, and searching whether the name of the target container group pod is stored in the mapping relation;
deleting the target container group pod and outputting deletion information when the name of the target container group pod is stored in the mapping relation; the deletion information is used to characterize that the IP address of the target container group pod has been deleted.
Optionally, the method further comprises:
and deleting the target container group pod under the condition that the name of the target container group pod is not stored in the mapping relation, releasing the IP address allocated by the target container group pod into an IP address pool in the Kubernetes cluster, and outputting the deleting information.
According to a second aspect of the present invention, there is provided an apparatus for assigning IP addresses of a group of containers pod, the apparatus comprising:
the acquisition module is used for acquiring a container group pod with an IP address to be allocated as a target container group pod;
the determining module is used for determining whether the target container group pod belongs to a set type according to the type information of the target container group pod, wherein the name of the container group pod of the set type is unchanged;
the searching module is used for searching the name of the target container group pod in the database of the Kubernetes cluster under the condition that the target container group pod belongs to the set type;
and the allocation module is used for allocating the IP address corresponding to the name of the target container group pod to the target container group pod under the condition that the name of the target container group pod is found.
According to a third aspect of the present invention there is provided a computing node in a Kubernetes cluster comprising the apparatus of the second aspect; or alternatively, the process may be performed,
comprising a memory for storing computer instructions and a processor for invoking the computer instructions from the memory to perform the method according to any of the first aspects.
According to a fourth aspect of the present invention there is provided a computer readable storage medium having stored thereon computer instructions which, when executed by a processor, implement a method according to any of the first aspects.
In this embodiment, when the computing node allocates an IP address to a target container group pod belonging to a set type, the computing node first searches a database of the Kubernetes cluster for a name of the target container group pod, and when the name of the target container group pod is found, it indicates that the target container group pod belongs to the reconstructed container group pod. At this time, the IP address corresponding to the name of the target container group pod stored in the database of the Kubernetes cluster is assigned to the target container group pod. Thus, the target container group pod belonging to the set type will have the same name as the container group pod before reconstruction. Thus, for a particular program, containers in the target container group pod belonging to the set type can be utilized for carrying. In this way, a particular program can always run normally. Meanwhile, since the method for allocating the IP address of the container group pod provided in the embodiment does not modify any information of the configuration file corresponding to the target container group pod, the configuration file of the target container group pod can be used across clusters.
Other features of the present invention and its advantages will become apparent from the following detailed description of exemplary embodiments of the invention, which proceeds with reference to the accompanying drawings.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description, serve to explain the principles of the invention.
FIG. 1 is a schematic diagram of a Kubernetes cluster;
FIG. 2 is a block diagram of a hardware configuration of a compute node in a Kubernetes Cluster, implementing an embodiment of the invention;
FIG. 3 is a flow chart of a method for assigning pod IP addresses according to an embodiment of the present invention;
FIG. 4 is a flow chart of another method for assigning pod IP addresses according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an apparatus for allocating pod IP addresses according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a computing node in a Kubernetes cluster according to an embodiment of the present invention.
Detailed Description
Various exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that: the relative arrangement of the components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless it is specifically stated otherwise.
The following description of at least one exemplary embodiment is merely exemplary in nature and is in no way intended to limit the invention, its application, or uses.
Techniques, methods, and apparatus known to one of ordinary skill in the relevant art may not be discussed in detail, but are intended to be part of the specification where appropriate.
In all examples shown and discussed herein, any specific values should be construed as merely illustrative, and not a limitation. Thus, other examples of exemplary embodiments may have different values.
It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further discussion thereof is necessary in subsequent figures.
< hardware configuration >
Fig. 2 illustrates a block diagram of a hardware configuration of a computing node 2000 in a Kubernetes cluster in which embodiments of the invention may be implemented.
The computing node 2000 may be a portable computer, desktop computer, cell phone, tablet computer, server, etc., where the server may be a virtual machine or a physical machine. As shown in fig. 2, computing node 2000 may include a processor 2100, memory 2200, interface device 2300, communication device 2400, display device 2500, input device 2600, speaker 2700, microphone 2800, and so forth. The processor 2100 may be a central processing unit CPU, a microprocessor MCU, or the like. The memory 2200 includes, for example, ROM (read only memory), RAM (random access memory), nonvolatile memory such as a hard disk, and the like. The interface device 2300 includes, for example, a USB interface, a headphone interface, and the like. The communication device 2400 can perform wired or wireless communication, for example, and specifically can include Wifi communication, bluetooth communication, 2G/3G/4G/5G communication, and the like. The display device 2500 is, for example, a liquid crystal display, a touch display, or the like. The input device 2600 may include, for example, a touch screen, a keyboard, a somatosensory input, and the like. A user can input/output voice information through the speaker 2700 and the microphone 2800.
The computing node 2000 illustrated in fig. 2 is merely illustrative and is in no way meant to limit the invention, its application, or uses. In an embodiment of the present invention, the memory 1200 of the computing node 2000 is configured to store instructions for controlling the processor 2100 to operate to perform any of the methods for allocating pod IP addresses provided by the embodiments of the present invention.
Those skilled in the art will appreciate that although a plurality of devices are shown for computing node 2000 in fig. 1, the present invention may relate to only some of the devices, e.g., computing node 1000 may relate to only processor 2100 and storage device 2200. The skilled person can design instructions according to the disclosed solution. How the instructions control the processor to operate is well known in the art and will not be described in detail here.
< method example >
As shown in fig. 3, the present embodiment provides a method for allocating a container group podIP address, which is applied to a computing node in a Kubernetes cluster. The compute node may be any one of the compute nodes in the Kubernetes cluster. The method comprises the following steps of S3100-S3400:
s3100, obtaining a container group pod with the IP address to be allocated as a target container.
In this embodiment, the Kubernetes cluster schedules the created container group pod to one of the computing nodes in the Kubernetes cluster according to the container group pod scheduling algorithm. The computing node, upon receiving a container group pod scheduled by the Kubernetes cluster, takes the container group pod as a target container group pod and assigns an IP address to the target container group pod.
It will be appreciated that the created container group pod may be a newly created container group pod or a reconstructed container group pod.
It should be noted that, the container group pod in the Kubernetes cluster carries related parameter information of the container group pod, for example, carries corresponding type information, a corresponding name, a corresponding ID, and the like. Based on this, the target container group pod carries the type information of the container group pod and the name of the container group pod.
S3200, determining whether the target container group pod belongs to a set type according to the type information of the target container group pod, wherein the name of the container group pod of the set type is unchanged.
The type of container group pod in the Kubernetes cluster may be: statefulset type, depoymen type, etc., and the type of container group pod in the Kubernetes cluster may be specified by the operator. Based on this, the target container group pod in the present embodiment may belong to the statefulset type, or may belong to a depoymen type other than the statefulset type, for example.
In addition, for one container group pod in the Kubernetes cluster, when the types corresponding to the container group pod are different, the reconstructed container group pod has the same parameters except that the container carrying the program is the same as the container carrying the program in the container group pod before reconstruction.
For example, for a container group pod carrying a program a, when the container group pod is of statefulset type, the container group pod is reconstructed, and the reconstructed container group pod has a container carrying the program a, and the name of the reconstructed container group pod is the same as the name of the container group pod before reconstruction. When the container group pod is of a depoymen type, after the container group pod is rebuilt, the rebuilt container group pod has a container carrying the program a, but the name of the rebuilt container group pod is different from the name of the container group pod before the rebuild.
Based on the above, the setting type in S3200 may be a statefulset type.
S3300, under the condition that the target container group pod belongs to a set type, searching the name of the target container group pod in a database of the Kubernetes cluster.
In this embodiment, when determining that the target container group pod belongs to the set type, the computing node may search whether the name of the target container group pod is stored in the database of the Kubernetes cluster through a data interaction channel between the computing node and the database of the Kubernetes cluster.
In one embodiment, the above S3300 may be implemented by the following S3310-S3330:
s3310, if the target container group pod belongs to the set type, searching whether a mapping relation between the name and the IP address of the container group pod is stored in a database of the Kubernetes cluster.
In one embodiment, a specific implementation of S3310 may be: the computing node sends a request to a database in the Kubernetes cluster, and the database in the Kubernetes cluster traverses the storage space of the computing node based on the request to determine whether the mapping relation is stored in the storage space of the computing node.
S3320, when the mapping relation is not stored in the database of the Kubernetes cluster, the database is instructed to establish the mapping relation.
It can be understood that after the database of the Kubernetes cluster establishes a mapping relationship, valid data is not stored in the mapping relationship.
In one embodiment, after the database of the Kubernetes cluster establishes a mapping relationship, a storage address of the mapping relationship in the database of the Kubernetes cluster is sent to the computing node. In this way, the computing node can obtain relevant data from the mapping relation in a targeting manner in a subsequent process.
S3330, under the condition that the mapping relation is stored in the database of the Kubernetes cluster, searching the name of the target container group pod in the database of the Kubernetes cluster.
In one embodiment, the specific implementation of S3330 may be: the computing node sends the name of the target container group pod into the database of the Kubernetes cluster. The database of the Kubernetes cluster searches whether the name of the container group pod which is the same as the name of the container group pod reported by the computing node exists in the mapping relation. And feeding back the database of the Kubernetes cluster to the computing node according to the search result.
In one embodiment, the database of the Kubernetes cluster feeds back to the computing node the name of the container group pod that has been found to be the same as the name of the container group pod reported by the computing node when the name of the container group pod that is the same as the name of the container group pod reported by the computing node is found.
In another embodiment, when the database of the Kubernetes cluster finds the name of the container group pod which is the same as the name of the container group pod reported by the computing node, the database feeds back the IP address corresponding to the name of the container group pod which is the same as the name of the container group pod reported by the computing node to the computing node.
Corresponding to S3300 described above, in the case where the target container group pod does not belong to the set type, the method for allocating container group podIP addresses provided in the present embodiment further includes the following S3340 and S3350:
s3340, if the target container group pod does not belong to the set type, extracting the first IP address from the IP address pool in the Kubernetes cluster. Wherein, the IP address pool stores the unassigned IP address.
S3350, the first IP address is assigned to the target container group pod.
In this embodiment, a plurality of IP addresses are stored in the IP address pool in the Kubernetes cluster, each of which is not assigned to a container group pod in the Kubernetes cluster. After the computing node extracts the first IP address from the pool of IP addresses and assigns the second address to the target container group pod, the first IP address will not be present in the pool of IP addresses.
S3400, in the case where the name of the target container group pod is found, assigning an IP address corresponding to the name of the target container group pod to the target container group pod.
In this embodiment, in the case where the name of the target container group pod is found, it is explained that the target container group pod is reconstructed.
In one embodiment, when the database of the Kubernetes cluster feeds back to the computing node that the name of the container group pod that has been found to be the same as the name of the container group pod reported by the computing node, the specific implementation of S3400 may be: the compute node sends a request to the database of the Kubernetes cluster to obtain an IP address corresponding to the container name of the target container group pod.
In another embodiment, when the database of the Kubernetes cluster finds the name of the container group pod that is the same as the name of the container group pod reported by the computing node, the specific implementation of S3400 may be that: the IP address sent by the database of the Kubernetes cluster is obtained.
When the IP address is acquired, the IP address is assigned to the target container group pod.
Corresponding to S3400 described above, in the case where the name of the target container group pod is not found, the method of allocating the IP address of the container group pod provided in the present embodiment further includes the following S3510-S3530:
s3510, extracting a second IP address from an IP address pool of the Kubernetes cluster, where the IP address pool stores unassigned IP addresses, if the name of the target container group pod is not found.
S3520, assigning the second IP address to the target container group pod.
And S3530, uploading the container name and the second IP address of the target container group pod to a database of the Kubernetes cluster.
In this embodiment, in the case that the name of the target container group pod is not found, it is explained that the container group pod is created for the first time by Kubernetes cluster, and not created by reconstruction. At this time, the target container group pod has not been allocated an IP address yet, and therefore, a new IP address, i.e., a second IP address, needs to be extracted from the IP address pool. Meanwhile, in order to make the allocated IP address of the target container group pod unchanged after the target container group pod is subsequently reconstructed, at this time, the computing node is required to upload the IP address of the target container group pod, that is, the second IP address and the name of the target container group pod, to the database of the Kubernetes cluster, and the database of the Kubernetes cluster adds the second IP address and the name of the target container group pod to the mapping relationship.
On the basis of any one of the foregoing embodiments, the method for allocating pod IP addresses of the present embodiment further includes the following S3600:
s3600, outputting the IP address allocated to the target container group pod.
In this embodiment, after the computing node outputs the IP address allocated to the target container group pod, the computing node may configure the IP address on the network card of the target container group pod. In this way, the IP address assigned to the target container group pod is validated and other container groups pods in the computing node can communicate with the target container group pod.
In this embodiment, when the computing node allocates an IP address to a target container group pod belonging to a set type, the computing node first searches a database of the Kubernetes cluster for a name of the target container group pod, and when the name of the target container group pod is found, it indicates that the target container group pod belongs to the reconstructed container group pod. At this time, the IP address corresponding to the name of the target container group pod stored in the database of the Kubernetes cluster is assigned to the target container group pod. Thus, the target container group pod belonging to the set type will have the same name as the container group pod before reconstruction. Thus, for a particular program, containers in the target container group pod belonging to the set type can be utilized for carrying. In this way, a particular program can always run normally. Meanwhile, since the method for allocating the IP address of the container group pod provided in the embodiment does not modify any information of the configuration file corresponding to the target container group pod, the configuration file of the target container group pod can be used across clusters.
The container group pod in the Kubernetes cluster has the possibility of being deleted, i.e., the target container group pod has the possibility of being deleted. When a target container group pod belonging to the set type is deleted after being assigned to an IP address, in order to allow the deleted target container group pod to be rebuilt again, still have a fixed IP address, that is, still have the same IP address as the target container group pod before being deleted, the method of assigning the IP address of the container group pod provided in the present embodiment further includes the following steps S3710 and S3720:
s3710, in response to receiving a deleting request for deleting the target container group pod with the allocated IP address, searching whether the name of the target container group pod is stored in the mapping relation.
In this embodiment, the deletion request is input by the operator based on the API interface of the Kubernetes cluster. When the API of the Kubernetes cluster monitors that an operator enters a delete request, the delete request may be forwarded to the computing node where the target container group pod is located. The computing node responds to the delete request when it receives the delete request. And searching whether the names of the target container group pod are stored in the mapping relation based on the deleting request.
In addition, based on the above, the target container group pod may or may not belong to the setting type.
S3720, deleting the target container group pod and outputting deleting information when the name of the target container group pod is stored in the mapping relation; the deletion information is used to characterize that the IP address of the target container group pod has been deleted.
In the present embodiment, in the case where the name of the target container group pod is stored in the mapping relation, it is explained that the target container group pod belongs to the set type. At this time, the computing node only needs to delete the target container group pod and output the deletion information, and does not need to release the IP address of the target container group pod into the IP address pool of the Kubernetes cluster. Thus, the IP address of the target container group pod will not be assigned to other container groups pod, and when the target container group pod is rebuilt again, the IP address of the target container group pod before deletion can still be obtained by the method described above.
Corresponding to S3720 described above, the method for allocating pod IP addresses of the present embodiment further includes the following S3730:
s3730, deleting the target container group pod when the name of the target container group pod is not stored in the mapping relation, releasing the IP address allocated by the target container group pod into an IP address pool in the Kubernetes cluster, and outputting deleting information.
In the present embodiment, in the case where the name of the target container group pod is not stored in the mapping relationship, it is explained that the target container group pod does not belong to the set type, and therefore the target container group pod does not need to be allocated the same IP address as the target container group pod before deletion at the time of reconstruction. At this time, it is necessary to delete the target container group pod and release the IP address of the target container group pod into the IP address pool in the Kubernetes cluster.
< example >
In one example, the method for allocating pod IP addresses provided in this embodiment is shown in fig. 4, and may include the following steps S4100-S4900:
s4100, obtaining a container group pod of the IP address to be allocated as a target container.
S4200, determining whether the target container group pod belongs to the set type according to the type information of the target container group pod.
S4300, extracting a first IP address from an IP address pool in a Kubernetes cluster under the condition that the target container group pod does not belong to a set type; the first IP address is assigned to the target set of containers pod.
S4400, searching whether a mapping relation between the name and the IP address of the container group pod is stored in a database of the Kubernetes cluster under the condition that the target container group pod belongs to a set type.
S4500, under the condition that a mapping relation is not stored in the database of the Kubernetes cluster, the database of the Kubernetes cluster is instructed to establish the mapping relation.
S4600, in the case that a mapping relation is stored in a database of the Kubernetes cluster, searching the name of the target container group pod in the database of the Kubernetes cluster.
S4700, in the case where the name of the target container group pod is found, the IP address corresponding to the name of the target container group pod is assigned to the target container group pod.
S4800, extracting a second IP address from an IP address pool in the Kubernetes cluster under the condition that the name of the target container group pod is not found; the second IP address is assigned to the target container group pod.
S4900, uploading the name and the second IP address of the target container group pod into a database of the Kubernetes cluster.
< device example >
As shown in fig. 5, the present embodiment provides an apparatus 50 for assigning IP addresses of group pod containers, the apparatus 50 comprising: the device comprises an acquisition module 51, a determination module 52, a search module 53 and an allocation module 54.
Wherein:
an obtaining module 51, configured to obtain a container group pod of an IP address to be allocated as a target container group pod;
a determining module 52, configured to determine, according to the type information of the target container group pod, whether the target container group pod belongs to a set type, where a name of the container group pod of the set type is unchanged;
a searching module 53, configured to search a database of the Kubernetes cluster for a name of the target container group pod if the target container group pod belongs to the set type;
an allocation module 54 is configured to allocate, if the name of the target container group pod is found, an IP address corresponding to the name of the target container group pod to the target container group pod.
In one embodiment, the allocation module 54 is further configured to extract the first IP address from the pool of IP addresses in the Kubernetes cluster if the target container group pod is not of the set type; the IP address pool stores unassigned IP addresses;
and allocating the first IP address to the target container group pod.
In one embodiment, the allocation module 54 is further configured to extract a second IP address from the pool of IP addresses in the Kubernetes cluster if the name of the target container group pod is not found; the IP address pool stores unassigned IP addresses;
assigning the second IP address to the target container group pod;
and uploading the name of the target container group pod and the second IP address to a database of the Kubernetes cluster.
In one embodiment, the searching module 53 is specifically configured to: searching whether a mapping relation between the name and the IP address of the container group pod is stored in a database of the Kubernetes cluster under the condition that the target container group pod belongs to the set type;
under the condition that the mapping relation is not stored in the database of the Kubernetes cluster, the database of the Kubernetes cluster is instructed to establish the mapping relation;
and searching the name of the target container group pod in the database of the Kubernetes cluster under the condition that the mapping relation is stored in the database of the Kubernetes cluster.
In one embodiment, the apparatus 50 for allocating pod IP addresses of the container group provided in this embodiment further includes an output module. The output module is used for outputting the IP address allocated to the target container group pod.
In one embodiment, the apparatus 50 for allocating pod IP addresses of the container group provided in this embodiment further includes a response module and a deletion module. Wherein, response module is used for: responding to a deleting request for deleting the target container group pod with the allocated IP address, and searching whether the name of the target container group pod is stored in the mapping relation;
a deleting module, configured to delete the target container group pod and output deletion information when the name of the target container group pod is stored in the mapping relationship; the deletion information is used to characterize that the IP address of the target container group pod has been deleted.
In one embodiment, the deletion module is further configured to delete the target container group pod if the name of the target container group pod is not stored in the mapping relationship, release the IP address allocated by the target container group pod to an IP address pool in the Kubernetes cluster, and output the deletion information.
< device example >
The present embodiment provides a computing node 60 in a Kubernetes cluster comprising an apparatus 50 for assigning pod IP addresses of a set of containers as shown in fig. 5. Or as shown in fig. 6, comprises a memory 61 and a processor 62, the memory 61 being for storing computer instructions, the processor 62 being for invoking the computer instructions from the memory 61 to perform the method according to any of the method embodiments.
The present invention may be a system, method, and/or computer program product. The computer program product may include a computer readable storage medium having computer readable program instructions embodied thereon for causing a processor to implement aspects of the present invention.
The computer readable storage medium may be a tangible device that can hold and store instructions for use by an instruction execution device. The computer readable storage medium may be, for example, but not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: portable computer disks, hard disks, random Access Memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static Random Access Memory (SRAM), portable compact disk read-only memory (CD-ROM), digital Versatile Disks (DVD), memory sticks, floppy disks, mechanical coding devices, punch cards or in-groove structures such as punch cards or grooves having instructions stored thereon, and any suitable combination of the foregoing. Computer-readable storage media, as used herein, are not to be construed as transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., optical pulses through fiber optic cables), or electrical signals transmitted through wires.
The computer readable program instructions described herein may be downloaded from a computer readable storage medium to a respective computing/processing device or to an external computer or external storage device over a network, such as the internet, a local area network, a wide area network, and/or a wireless network. The network may include copper transmission cables, fiber optic transmissions, wireless transmissions, routers, firewalls, switches, gateway computers and/or edge servers. The network interface card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium in the respective computing/processing device.
Computer program instructions for carrying out operations of the present invention may be assembly instructions, instruction Set Architecture (ISA) instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, c++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The computer readable program instructions may be executed entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider). In some embodiments, aspects of the present invention are implemented by personalizing electronic circuitry, such as programmable logic circuitry, field Programmable Gate Arrays (FPGAs), or Programmable Logic Arrays (PLAs), with state information for computer readable program instructions, which can execute the computer readable program instructions.
Various aspects of the present invention are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer-readable program instructions.
These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable medium having the instructions stored therein includes an article of manufacture including instructions which implement the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer, other programmable apparatus or other devices implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions. It is well known to those skilled in the art that implementation by hardware, implementation by software, and implementation by a combination of software and hardware are all equivalent.
The foregoing description of embodiments of the invention has been presented for purposes of illustration and description, and is not intended to be exhaustive or limited to the embodiments disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the various embodiments described. The terminology used herein was chosen in order to best explain the principles of the embodiments, the practical application, or the technical improvement of the technology in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein. The scope of the invention is defined by the appended claims.

Claims (9)

1. A method of assigning pod IP addresses for a group of containers, the method being applied to computing nodes in a Kubernetes cluster, the method comprising:
acquiring a container group pod of an IP address to be allocated as a target container group pod;
determining whether the target container group pod belongs to a set type according to the type information of the target container group pod, wherein the name of the container group pod of the set type is unchanged;
searching the name of the target container group pod in a database of the Kubernetes cluster under the condition that the target container group pod belongs to the set type;
assigning an IP address corresponding to the name of the target container group pod to the target container group pod if the name of the target container group pod is found;
wherein the method further comprises:
extracting a first IP address from an IP address pool in a Kubernetes cluster under the condition that the target container group pod does not belong to the set type; the IP address pool stores unassigned IP addresses;
and allocating the first IP address to the target container group pod.
2. The method according to claim 1, wherein the method further comprises:
extracting a second IP address from an IP address pool in a Kubernetes cluster under the condition that the name of the target container group pod is not found; the IP address pool stores unassigned IP addresses;
assigning the second IP address to the target container group pod;
and uploading the name of the target container group pod and the second IP address to a database of the Kubernetes cluster.
3. The method according to claim 1, wherein, in case the target container group pod belongs to the set type, searching the database of the Kubernetes cluster for the name of the target container group pod comprises:
searching whether a mapping relation between the name and the IP address of the container group pod is stored in a database of the Kubernetes cluster under the condition that the target container group pod belongs to the set type;
under the condition that the mapping relation is not stored in the database of the Kubernetes cluster, the database of the Kubernetes cluster is instructed to establish the mapping relation;
and searching the name of the target container group pod in the database of the Kubernetes cluster under the condition that the mapping relation is stored in the database of the Kubernetes cluster.
4. A method according to any one of claims 1-3, wherein the method further comprises:
and outputting the IP address allocated for the target container group pod.
5. A method according to claim 3, characterized in that the method further comprises:
responding to a deleting request for deleting the target container group pod with the allocated IP address, and searching whether the name of the target container group pod is stored in the mapping relation;
deleting the target container group pod and outputting deletion information when the name of the target container group pod is stored in the mapping relation; the deletion information is used to characterize that the IP address of the target container group pod has been deleted.
6. The method of claim 5, wherein the method further comprises:
and deleting the target container group pod under the condition that the name of the target container group pod is not stored in the mapping relation, releasing the IP address allocated by the target container group pod into an IP address pool in the Kubernetes cluster, and outputting the deleting information.
7. An apparatus for assigning pod IP addresses, the apparatus comprising:
the acquisition module is used for acquiring a container group pod with an IP address to be allocated as a target container group pod;
the determining module is used for determining whether the target container group pod belongs to a set type according to the type information of the target container group pod, wherein the name of the container group pod of the set type is unchanged;
the searching module is used for searching the name of the target container group pod in a database of the Kubernetes cluster under the condition that the target container group pod belongs to the set type;
an allocation module, configured to allocate, if the name of the target container group pod is found, an IP address corresponding to the name of the target container group pod to the target container group pod;
the allocation module is further configured to extract a first IP address from an IP address pool in a Kubernetes cluster if the target container group pod does not belong to the set type; the IP address pool stores unassigned IP addresses;
and allocating the first IP address to the target container group pod.
8. A compute node in a Kubernetes cluster comprising the apparatus of claim 7; or alternatively, the process may be performed,
comprising a memory for storing computer instructions and a processor for invoking the computer instructions from the memory to perform the method of any of claims 1-6.
9. A computer readable storage medium storing computer instructions which, when executed by a processor, implement the method of any one of claims 1-6.
CN201911237032.2A 2019-12-05 2019-12-05 Method, device, equipment and storage medium for distributing pod IP address Active CN111124604B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911237032.2A CN111124604B (en) 2019-12-05 2019-12-05 Method, device, equipment and storage medium for distributing pod IP address

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911237032.2A CN111124604B (en) 2019-12-05 2019-12-05 Method, device, equipment and storage medium for distributing pod IP address

Publications (2)

Publication Number Publication Date
CN111124604A CN111124604A (en) 2020-05-08
CN111124604B true CN111124604B (en) 2023-07-14

Family

ID=70497623

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911237032.2A Active CN111124604B (en) 2019-12-05 2019-12-05 Method, device, equipment and storage medium for distributing pod IP address

Country Status (1)

Country Link
CN (1) CN111124604B (en)

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111796905B (en) * 2020-05-22 2021-04-16 浙商银行股份有限公司 Method and system for realizing Kubernetes container cloud platform VLAN network
CN111858032A (en) * 2020-06-24 2020-10-30 浪潮电子信息产业股份有限公司 Accelerated processing method of AI model task and related device
CN113872997B (en) * 2020-06-30 2022-08-26 华为技术有限公司 Container group POD reconstruction method based on container cluster service and related equipment
CN113010342A (en) * 2021-03-12 2021-06-22 北京百度网讯科技有限公司 Operation and maintenance diagnosis method, device, equipment and storage medium
CN115174529B (en) * 2021-03-18 2024-01-23 北京金山云网络技术有限公司 Network processing method and device, electronic equipment and storage medium
US11671401B2 (en) 2021-03-25 2023-06-06 Cisco Technology, Inc. Providing persistent external internet protocol address for extra-cluster services
EP4315799A1 (en) * 2021-03-25 2024-02-07 Cisco Technology, Inc. Providing persistent external internet protocol address for extra-cluster services
CN113766043B (en) * 2021-05-11 2024-02-23 腾讯科技(深圳)有限公司 Method, device, computer equipment and storage medium for configuring target container
CN114157455A (en) * 2021-11-16 2022-03-08 北京达佳互联信息技术有限公司 Data transmission method, device, equipment and storage medium
CN113835846B (en) * 2021-11-26 2022-04-08 深圳市明源云科技有限公司 Method and device for creating k8s cluster and computer-readable storage medium
CN114500464B (en) * 2021-12-13 2023-12-12 天翼物联科技有限公司 Container static IP distribution method, system, device and storage medium
CN114281478B (en) * 2021-12-24 2023-04-18 北京百度网讯科技有限公司 Container operation method and device, electronic equipment and computer storage medium
CN114640652B (en) * 2022-02-24 2023-09-19 联想(北京)有限公司 Information processing method and device
CN115134310B (en) * 2022-08-31 2022-12-06 浙江大华技术股份有限公司 Traffic scheduling method and device, storage medium and electronic device

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9805345B1 (en) * 2014-11-10 2017-10-31 Turbonomic, Inc. Systems, apparatus, and methods for managing quality of service agreements
CN107580083A (en) * 2017-09-20 2018-01-12 北京京东尚科信息技术有限公司 A kind of method and system of container IP address distribution

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10191778B1 (en) * 2015-11-16 2019-01-29 Turbonomic, Inc. Systems, apparatus and methods for management of software containers
US10482108B2 (en) * 2016-02-26 2019-11-19 Red Hat, Inc. Container clustering in a container-based architecture
CN107666525B (en) * 2017-09-08 2020-11-24 北京京东尚科信息技术有限公司 Method and device for IP allocation of cluster container
US10719352B2 (en) * 2018-01-22 2020-07-21 International Business Machines Corporation System and method for in-process namespace switching
US10873500B2 (en) * 2018-03-06 2020-12-22 Kaloom Inc. Computing device and method for generating a link IPV6 address
US11128530B2 (en) * 2018-03-29 2021-09-21 Hewlett Packard Enterprise Development Lp Container cluster management
CN108924268B (en) * 2018-09-11 2021-05-25 网宿科技股份有限公司 Container cloud service system and pod creation method and device
CN110012125B (en) * 2019-04-01 2022-02-01 优刻得科技股份有限公司 Cluster network communication method, device, storage medium and equipment
CN110427249A (en) * 2019-07-26 2019-11-08 重庆紫光华山智安科技有限公司 Method for allocating tasks, pod initial method and relevant apparatus

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9805345B1 (en) * 2014-11-10 2017-10-31 Turbonomic, Inc. Systems, apparatus, and methods for managing quality of service agreements
CN107580083A (en) * 2017-09-20 2018-01-12 北京京东尚科信息技术有限公司 A kind of method and system of container IP address distribution

Also Published As

Publication number Publication date
CN111124604A (en) 2020-05-08

Similar Documents

Publication Publication Date Title
CN111124604B (en) Method, device, equipment and storage medium for distributing pod IP address
KR102376713B1 (en) Composite partition functions
US11188515B2 (en) Preview processing and automatic correction of bulk data for software as a service applications
US10678413B2 (en) Application for auto deletion of images
CN111708557B (en) Method, device and storage medium for updating configuration file
CN112860479A (en) Data storage method and cloud data center
CN108287894B (en) Data processing method, device, computing equipment and storage medium
US20170318129A1 (en) Generation and distribution of named, definable, serialized tokens
US20190129729A1 (en) Managing Multi-Single-Tenant SaaS Services
US10740230B2 (en) Heap contraction for increasing memory density in cloud environment
US20180046393A1 (en) Dynamic compression for runtime services
US10929412B2 (en) Sharing content based on extracted topics
US20170063776A1 (en) FAQs UPDATER AND GENERATOR FOR MULTI-COMMUNICATION CHANNELS
US10082933B2 (en) Context sensitive active fields in user interface
US11704119B2 (en) Migrating infrastructure as code between different cloud providers
US10223463B2 (en) Node controllers for hierarchical data structures
CN115617420A (en) Application program generation method, device, equipment and storage medium
JP2022553021A (en) Nonessential Inputs, Outputs, and Task Signaling in Workflows on Cloud Platforms
US10795686B2 (en) Internationalization controller
US10048940B2 (en) Parallel generation of random numbers
US11016874B2 (en) Updating taint tags based on runtime behavior profiles
US10331651B2 (en) Updating web files based on detected legacy model file changes
US20230127067A1 (en) Multi-dimensional mapping and user cognitive profile based device control and channel assignment
CN108153525B (en) Method and device for constructing interactive interface and electronic equipment
CN107145300B (en) Data sharing management method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant