CN114500464A - Container static IP distribution method, system, device and storage medium - Google Patents

Container static IP distribution method, system, device and storage medium Download PDF

Info

Publication number
CN114500464A
CN114500464A CN202111520237.9A CN202111520237A CN114500464A CN 114500464 A CN114500464 A CN 114500464A CN 202111520237 A CN202111520237 A CN 202111520237A CN 114500464 A CN114500464 A CN 114500464A
Authority
CN
China
Prior art keywords
static
container
record table
name
workload
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.)
Granted
Application number
CN202111520237.9A
Other languages
Chinese (zh)
Other versions
CN114500464B (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.)
Tianyi IoT Technology Co Ltd
Original Assignee
Tianyi IoT 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 Tianyi IoT Technology Co Ltd filed Critical Tianyi IoT Technology Co Ltd
Priority to CN202111520237.9A priority Critical patent/CN114500464B/en
Publication of CN114500464A publication Critical patent/CN114500464A/en
Application granted granted Critical
Publication of CN114500464B publication Critical patent/CN114500464B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting

Abstract

The application provides a container static IP allocation method, a system, a device and a storage medium. The method comprises the steps of determining whether a first name exists in a static IP record table or not by acquiring the first name of a workload; if the first name exists in the static IP record table, determining that the IP record exists in the container; and determining a first static IP matched with the container according to the static IP record table, and allocating the first static IP to the container. The system includes a first determination module, a second determination module, and a third determination module. By using the method provided by the application, the static IP can be distributed for the container, the IP address can be kept unchanged after the container is restarted, and the working performance of the container is improved. The method and the device can be widely applied to the technical field of computers.

Description

Container static IP allocation method, system, device and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, a system, an apparatus, and a storage medium for allocating static IP for a container.
Background
With the rapid development of the internet, the containers are widely used. During operation, the IP address of the container is changed when the container is restarted. In the related art, only the IP address of the container is kept unchanged when the container name is unchanged, and the IP address of the container is usually required to be explicitly specified when the container is created, otherwise the fixed IP address cannot be maintained. In the related art, the IP staticization of the container is realized by modifying kubernets, but only the fixation of the IP address under the condition of the status workload is supported.
Disclosure of Invention
The present application aims to solve at least to some extent one of the technical problems existing in the prior art.
Therefore, an object of the embodiments of the present application is to provide a method for allocating a static IP to a container, where the method is capable of allocating the static IP to the container, and keeping an IP address unchanged after the container is restarted, which is beneficial to improving the working performance of the container.
It is another object of embodiments of the present application to provide a container static IP distribution system.
In order to achieve the technical purpose, the technical scheme adopted by the embodiment of the application comprises the following steps:
in one aspect, an embodiment of the present application provides a method for allocating a static IP for a container, including the following steps:
acquiring a first name of the workload, and determining that the first name exists in a static IP record table or the first name does not exist in the static IP record table; if the first name exists in the static IP record table, determining that the IP record exists in the container; and determining a first static IP matched with the container according to the static IP record table, and allocating the first static IP to the container.
The container static IP allocation method can allocate static IP for the container, can keep the IP address unchanged after the container is restarted, and is beneficial to improving the working performance of the container.
In addition, the container static IP allocation method according to the above embodiment of the present application may further have the following additional technical features:
further, in the method for allocating static IP of a container in the embodiment of the present application, the static IP record table includes a first sub record table, where the first sub record table is used to record a correspondence between a name of the container and a static IP, and the first static IP is determined through the following steps:
judging whether the working load is a stateful working load or not;
and if the workload is a stateful workload, determining that the static IP corresponding to the container name is a first static IP according to the first sub-record table.
Further, in the method for allocating static IP of a container in the embodiment of the present application, the static IP record table includes a second sub record table, the second sub record table is used for recording a correspondence between a workload name and a static IP, and the first static IP is determined through the following steps:
judging whether the working load is a stateless working load or not;
if the working load is a stateless working load, determining a static IP set corresponding to the first name according to the second sub-record table;
and acquiring the working state of any static IP in the static IP set, and determining the static IP in the idle state as the first static IP.
Further, in the method for allocating static IP of a container in the embodiment of the present application, the static IP record table includes a third sub record table, the third sub record table is used to record a correspondence between a node name and a static IP, and the first static IP is determined through the following steps:
judging whether the workload is a daemon set workload;
and if the workload is the guard set workload, determining the static IP corresponding to the node name as a first static IP according to the third sub-record table.
Further, in the method for allocating static IP to a container in this embodiment of the present application, the method further includes: and if the workload is deleted, putting the static IP corresponding to the container into an IP address pool.
Further, in the method for allocating static IP to a container in this embodiment of the present application, the method further includes: and if the first name does not exist in the static IP record table, allocating a second static IP in an IP address pool to the container.
Further, in the method for allocating static IP to a container in this embodiment of the present application, the method further includes: and putting the corresponding relation between the container and the second static IP into the static IP record table according to a preset format.
In another aspect, an embodiment of the present application provides a container static IP allocation system, where the container is managed by a workload, and the system includes:
a first determining module, configured to obtain a first name of the workload, and determine that the first name exists in a static IP record table or the first name does not exist in the static IP record table;
a second determining module, configured to determine that an IP record exists in the container when the first name exists in the static IP record table;
and the third determining module is used for determining a first static IP matched with the container according to the static IP record table and distributing the first static IP to the container.
On the other hand, an embodiment of the present application provides a static IP allocation apparatus for a container, including:
at least one processor;
at least one memory for storing at least one program;
the at least one program, when executed by the at least one processor, causes the at least one processor to implement the container static IP allocation method described above.
In another aspect, embodiments of the present application provide a storage medium in which a processor-executable program is stored, where the processor-executable program is used to implement the container static IP allocation method described above when executed by a processor.
The embodiment of the application provides a container static IP allocation method, which comprises the steps of determining whether a first name exists in a static IP record table or not by acquiring the first name of a workload; if the first name exists in the static IP record table, determining that the IP record exists in the container; and determining a first static IP matched with the container according to the static IP record table, and allocating the first static IP to the container. The method can allocate static IP for the container, can keep the IP address unchanged after the container is restarted, and is beneficial to improving the working performance of the container.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following description is made on the drawings of the embodiments of the present application or the related technical solutions in the prior art, and it should be understood that the drawings in the following description are only for convenience and clarity of describing some embodiments in the technical solutions of the present application, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a schematic flow chart of a static IP allocation method for a container according to the present application;
FIG. 2 is a schematic flow chart diagram illustrating an embodiment of a method for static IP allocation of a container provided herein;
FIG. 3 is a schematic flow chart diagram illustrating another embodiment of a static IP allocation method for containers according to the present application;
FIG. 4 is a schematic flow chart diagram illustrating another embodiment of a static IP allocation method for containers according to the present application;
FIG. 5 is a schematic diagram of a static IP container distribution system according to the present application;
fig. 6 is a schematic structural diagram of a static IP distribution device for a container according to the present application.
Detailed Description
Reference will now be made in detail to embodiments of the present application, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the drawings are exemplary only for the purpose of explaining the present application and are not to be construed as limiting the present application. The step numbers in the following embodiments are provided only for convenience of illustration, the order between the steps is not limited at all, and the execution order of each step in the embodiments can be adapted according to the understanding of those skilled in the art.
Kubernetes, K8S for short, is the most widely used container arrangement tool at present, and solves the problem of large-scale deployment after containerization. Kubernets does not provide a default available container network, and a third party provides a container network plug-in that must satisfy the following conditions: 1. the containers can communicate with each other without NAT; 2. the host machine and the container can communicate with each other without NAT; 3. the container sees its own IP the same as its IP seen by other nodes (or containers). I.e. each container comprised by the cluster has an independent IP address that is directly routable to the other containers in the cluster and nodes. However, Kubernetes does not implement such a network model specifically, and only designs an open container network standard CNI.
The containers in Kubernetes are managed primarily by workload. The types of workloads that are commonly used are: stateful workload (stateful set), stateless workload (deplonym), and daemon workload (DaemonSet). Three workloads are introduced as follows:
(1) stateful workload: for this type of workload managed container, the container name has certain rules, for example, if a stateful workload with name mysql and number of containers 2 is created, two containers will be created, the container names mysql-0 and mysql-1, respectively, i.e. suffixes are incremented. When one of the containers, such as mysql-0, is manually deleted, the mysql workload may automatically recreate one more container to ensure that the number of containers is 2, the name of the new container is also mysql-0; the new container may be dispatched to other K8S nodes, not necessarily the original node.
(2) Stateless workload: for this type of workload managed container, the suffix of the container name is random, and if a stateless workload with the name nginx and the number of containers 2 is created, two containers with the names nginx-xxxx and nginx-yyyyy are created. When one of the containers, such as nginx-xxxx, is manually deleted, the nginx workload automatically recreates a container to ensure that the number of containers is 2, and the name suffix is random, such as changing to nginx-zzzz; the new container may be dispatched to other K8S nodes, not necessarily the original node.
(3) The guard set workload: this type of workload managed container, the suffix to the container name is random. But this type of workload, without specifying the number of containers, would create one on each K8S node and only one container per node. If a workload named exporter daemon is created, there are two K8S nodes, and two containers are created, one for each node, with the names of the containers being random, e.g., the name of the container on node1 is exporter-xxxx, and the name of the container on node2 is exporter-yyyy. When one of the containers, such as exporter-xxxx on node1, is manually deleted, the exporter workload automatically creates another container (whose name changes, such as exporter-zzzz) on node1 to ensure that there is one container on each node.
Containers running in kubernets are managed by using workload, otherwise, once the containers are deleted or a host where the containers are located goes down, a new container cannot be automatically created.
In the using process, when a developer migrates an application from a traditional virtual machine to a container platform for the first time, cloud and native transformation of the application is often difficult to be performed in time. At this point, the container is used more as a virtual machine. When the virtual machine is used to issue an application, the IP of the virtual machine will generally remain unchanged, i.e. after the virtual machine is powered off and restarted, its IP is still the original IP. However, the containers are different, and when a container is restarted (for example, manual deletion or automatic scheduling caused by down of a host in which the container is located), the IP of the container is changed. For the application of the cloud primary transformation which is not thorough, certain influence can be generated.
In the open source container network scheme in the related art, one method only supports that the IP of a container is kept unchanged when the name of the container is not changed, the IP of the container needs to be explicitly specified when the container is created, and once the condition is not met, the IP cannot be kept unchanged; another needs to modify kubernets while only supporting the case where IP remains unchanged under stateful workloads. Therefore, the current methods have great limitations.
In view of the foregoing, the present application provides a container static IP allocation, system, apparatus, and storage medium. The method comprises the steps of determining whether a first name exists in a static IP record table or not by acquiring the first name of a workload; if the first name exists in the static IP record table, determining that the IP record exists in the container; and determining a first static IP matched with the container according to the static IP record table, and allocating the first static IP to the container. The system includes a first determination module, a second determination module, and a third determination module. By using the method provided by the application, the static IP can be allocated to the container, the IP address can be kept unchanged after the container is restarted, and the working performance of the container is improved. The technical solution proposed in the present application is described in detail below.
The implementation environment of the container static IP allocation method provided by the embodiment of the application can comprise a terminal and a server. The terminal may be a user side device, and may be a smart phone, a tablet pc, an e-book reader, an MP3(Moving Picture Experts Group Audio Layer III, motion Picture Experts compression standard Audio Layer 3) player, an MP4(Moving Picture Experts Group Audio Layer IV, motion Picture Experts compression standard Audio Layer 4) player, a laptop computer, a desktop computer, an intelligent speaker, an intelligent watch, or the like. The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a CDN (Content Delivery Network), a big data and artificial intelligence platform. The terminal and the server can be connected through a wired network or a wireless network, so that data interaction can be performed between the terminal and the server. Those skilled in the art will appreciate that the number of the above-mentioned terminals may be only one, or the above-mentioned terminals may be several tens or hundreds, or more. The number of terminals and the type of device are not limited in the present application.
The container static IP allocation method provided by the embodiment of the application can be combined with various application scenes, for example, a plurality of containers are created in a server, the technical scheme provided by the embodiment of the application can be applied, the condition of IP change after the containers are restarted can be relieved, and the operating environment of the server is improved.
A container static IP allocation method and system proposed according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings, and first, the container static IP allocation method proposed by an embodiment of the present application will be described with reference to the accompanying drawings.
Referring to fig. 1, an embodiment of the present application provides a method for static IP allocation of a container, where the container is managed by a workload, and the method mainly includes the following steps:
s101: and acquiring a first name of the workload, and determining that the first name exists in a static IP record table or the first name does not exist in the static IP record table.
In the embodiment of the application, the first name of the workload is acquired, the static IP record table is inquired, and the first name in the static IP record table or the first name in the static IP record table is determined to be absent. The static IP record table is used for recording the mapping relation between the container and the IP, namely representing whether the container has the static IP record or not. And selecting different modes to carry out IP allocation on the container according to different conditions so as to realize IP staticizing of the container.
S102: and if the first name exists in the static IP record table, determining that the IP record exists in the container.
In the embodiment of the present application, if the first name exists in the static IP record table obtained through querying, that is, the IP record exists in the container. In some possible embodiments, where there is an IP record for a container, it is used to characterize that the container belongs to a re-created container, and therefore the original IP needs to be assigned to the container. And the IP of the container recorded in the static IP record table is associated with the name of the workload of the container, so that whether the IP record exists in the container can be determined by inquiring whether the first name exists in the static IP record table.
S103: and determining a first static IP matched with the container according to the static IP record table, and allocating the first static IP to the container.
In the embodiment of the application, the static IP record table is inquired, the first static IP matched with the container is determined, and the first static IP is allocated to the container, so that the IP staticization of the container is realized. By the method, the network intercommunication between the container and the host K8S is realized, and the IP remains unchanged after the container is restarted or rescheduled; the problem of keeping the IP statically after restarting containers of different types of workload management is solved without explicitly specifying the IP to be used for the container at the time of container creation and without modifying the native Kubernets. In some possible embodiments, the network configuration within the container is achieved by providing an IP address assigner and a container network configurator. Alternatively, the IP address assigner is configured to obtain an IP from the IP address pool, assign the IP to the container, and set the IP address assigner on each K8S node. The network configurator is used for configuring the network in the container, for example, setting information such as IP and route for the network card in the container, calling the IP address assignor on the same node to obtain the IP to be configured, and similarly, setting the network configurator on each K8S node. The query and assignment of static IP is achieved by an IP address assigner and a container network configurator. Those skilled in the art will understand that other modules may be arranged to implement query and assignment of static IP, and the present application does not limit the implementation manner of query and assignment of static IP.
Optionally, in the method for allocating static IP of a container in this embodiment of the present application, a static IP record table includes a first sub record table, where the first sub record table is used to record a correspondence between a name of the container and a static IP, and the first static IP is determined through the following steps:
judging whether the working load is a stateful working load or not;
and if the workload is a stateful workload, determining that the static IP corresponding to the container name is a first static IP according to the first sub-record table.
In this step, if the workload is a stateful workload, a recording form of the static IP recording table is set for the characteristics of the stateful workload, that is, the name is not changed after the container is restarted, and the correspondence between the container name and the static IP can be recorded through the first sub-recording table. And determining a first static IP by inquiring the IP corresponding to the container name in the first sub-record table. Illustratively, a stateful workload mysql is created, and if there are 2 containers, two containers mysql-0 and mysql-1 are generated, and after the static IP is allocated, the record format in the first record table is: mysql-0:192.168.1.101 and mysql-1: 192.168.1.102. If one container mysql-1 is restarted after failure, 192.168.1.102 is found to correspond to the static IP by querying the first sub-record table, and 192.168.1.102 is allocated to the container mysql-1 as the first static IP, so that IP staticizing of the container is realized.
Optionally, in the method for allocating static IP of a container in this embodiment of the present application, the static IP record table includes a second sub record table, where the second sub record table is used to record a correspondence between a workload name and a static IP, and the first static IP is determined through the following steps:
judging whether the working load is a stateless working load or not;
if the working load is a stateless working load, determining a static IP set corresponding to the first name according to the second sub-record table;
and acquiring the working state of any static IP in the static IP set, and determining the static IP in the idle state as a first static IP.
In this step, if the workload of the container is a stateless workload, the container name and the rebuilt address are random according to the characteristics of the stateless workload, that is, after the container is rebuilt, so that a second sub-record table is set in the static IP record table and is used for recording the corresponding relationship between the workload name and the static IP. All static IPs under the workload can be obtained by inquiring the second sub-record table, and if the container is restarted, the originally corresponding static IPs are in an idle state. Therefore, by querying the working state of any static IP in the static IP set, the static IP in the idle state is found, which is the first static IP of the container. Illustratively, the format of the record in the second sub-record table may be: IPs [ "192.168.1.103", "192.168.1.104" ]. In some possible embodiments, if the number of deleted containers is greater than or equal to 2, the static IP in the idle state may be added with a time attribute, and when the container is re-established, the static IP with an earlier time stamp is preferentially allocated to implement IP staticizing of the container. The static IPs in the idle state can also be connected through the pointers, and when the container is reestablished, the static IPs are sequentially distributed to the container according to the sequence of the pointers, so that the IP staticization of the container is ensured. An idle state IP record table can be established, static IPs in an idle state are recorded in the table, and in addition, attribute marks such as time or sequence are added, so that the container can find the corresponding static IPs. The present application does not limit the specific marking method of the static IP in the idle state.
Optionally, in the method for allocating static IP of a container in this embodiment of the present application, the static IP record table includes a third sub record table, where the third sub record table is used to record a correspondence between a node name and a static IP, and the first static IP is determined through the following steps:
judging whether the workload is a daemon set workload;
and if the workload is a guard set workload, determining that the static IP corresponding to the node name is a first static IP according to the third sub-record table.
In this step, if the workload is a daemon workload, a container is established on the original node of the container when the container is reconstructed according to the characteristics of the daemon workload, and therefore a third sub-record table is set in the static IP record table and used for recording the corresponding relationship between the node name and the static IP. When the container is rebuilt, whether the static IP record exists in the container can be determined by inquiring whether the static IP record exists in the node name of the node where the container is located. Illustratively, the record format of the third sub-record table may be: [ node1:192.168.1.105, node2:192.168.1.106 ]. By the method, the IP staticizing of the container is realized.
Optionally, in the method for allocating static IP to a container in this embodiment of the present application, the method further includes:
and if the workload is deleted, putting the static IP corresponding to the container into an IP address pool.
In this step, if the workload is deleted, the container stops working, and the static IP corresponding to the container is returned to the IP address pool, where the IP address pool is used to represent a set of static IP addresses that can be allocated to the container. By recovering the static IP of the container which stops working, the efficient utilization of the IP address is realized.
Optionally, in the method for allocating static IP to a container in this embodiment of the present application, the method further includes:
and if the first name does not exist in the static IP record table, allocating a second static IP in an IP address pool to the container.
In this step, if the first name does not exist in the static IP record table, at this time, the container does not have an IP record and belongs to a newly-created container, and a second static IP in the IP address pool is allocated to the container.
Optionally, in the method for allocating static IP to a container in this embodiment of the present application, the method further includes:
and putting the corresponding relation between the container and the second static IP into the static IP record table according to a preset format.
In this step, when the first name does not exist in the static IP record table, the newly established container stores the correspondence between the container and the static IP in the static IP record table, so as to implement IP staticization of the container. In some possible embodiments, different preset formats are set by the different allocation methods corresponding to different types of workloads, and different sub-record tables in the static IP record table are stored, so as to implement IP staticizing of the container.
As can be seen from the above description, in the container static IP allocation method provided in this embodiment of the present application, the method determines whether a first name exists in a static IP record table by obtaining the first name of a workload; if the first name exists in the static IP record table, determining that the IP record exists in the container; and determining a first static IP matched with the container according to the static IP record table, and allocating the first static IP to the container. The system includes a first determination module, a second determination module, and a third determination module. By using the method provided by the application, the static IP can be allocated to the container, the IP address can be kept unchanged after the container is restarted, and the working performance of the container is improved.
In order to better understand the technical solution of the present application, the following describes a container static IP allocation method by using three examples, and the specific process is as follows:
example one: referring to fig. 2, taking the workload as a stateful workload as an example, the container creation and reconstruction process is as follows:
step 201: and creating a stateful workload mysql with 2 containers, generating two containers mysql-0 and mysql-1, and running mysql-0 on the K8S node1 and mysql-1 on the K8S node 2.
Step 202: the IP address allocator at each node will obtain an IP, 192.168.1.101 and 192.168.1.102 respectively, from the IP address pool for the container at the respective node, and place the two static IPs into the first sub-record table of the static IP record table, which is shown in fig. 2 and expressed as: mysql-0:192.168.1.101 and mysql-1: 192.168.1.102.
Step 203: if the node1 of the K8S crashes, a container named mysql-0 is pulled up on the node2 of the K8S by the mysql working load in a state; the IP distributor on the node firstly searches a static IP record table to obtain that mysql-0 has an IP corresponding record, the corresponding IP is 192.168.1.101, and the IP is distributed to a container mysql-0; the original IP can be used after the container is restarted, and staticization of the IP of the container is realized.
Step 204: and when the workload mysql is deleted, deleting mysql records in the static IP record table, and simultaneously putting the IP back into the IP address pool.
Example two: as shown in fig. 3, taking the workload as a stateless workload as an example, the container creation and reconstruction process is as follows:
step 301: creating a stateless workload nginx, creating two containers nginx-xx and nginx-yy, setting nginx-xx to run on node1 of K8S and nginx-yy to run on node2 of K8S.
Step 302: the IP address assigner on each node obtains an IP from the pool of IP addresses, 192.168.1.103 and 192.168.1.104, respectively, for the container on the respective node. Recording the two IPs into the second sub-record table in the static IP record table, since the name of the container of the stateless workload changes after restarting, the recording manner is different from the existence of the stateful workload, and the recording form is shown in fig. 3 and is expressed as: IPs [ "192.168.1.103", "192.168.1.104" ].
Step 303: if the K8S node1 is down, a container named nginx-zz is pulled up by the nginx stateless workload on the K8S node 2; the IP address distributor on the node firstly searches a static IP record table to obtain that two IPs exist under the workload, 192.168.1.104 is used by a container nginx-yy, 192.168.1.103 is idle, and the IP in an idle state is distributed to the container; the newly pulled container can use the previous IP, and the staticizing of the IP is realized.
Step 304: and deleting the nginx record in the static IP record table and simultaneously putting the IP back into the IP address pool after the workload nginx is deleted.
Example three, referring to fig. 4, taking the workload as the daemon workload as an example, the process of creating and rebuilding a container is as follows:
step 401: and creating a daemon workload exporter, generating two containers exporter-xx and exporter-yy, and running the exporter-xx on the K8S node1 and the exporter-yy on the K8S node 2.
Step 402: the IP address assignor on node1 and node2 will obtain an IP from the pool of IP addresses for the container on the respective node, 192.168.1.105 and 192.168.1.106 respectively. Recording the two IPs into a third sub-record table of the static IP record table, since the new container is always at the original node after the container of the daemon set workload is restarted, recording the IP used by the container on the node by using the node as a key, wherein the recording format is represented as 4: node1:192.168.1.105 and node2: 192.168.1.106.
Step 403: if the exporter container on the node1 of K8S is restarted (K8S is restarted by deleting), the daemon workload regenerates a container on the node, and the IP address allocator searches the fixed IP record table to find that the IP of the exporter container on the node is 192.168.1.105; the method and the device ensure that the previous IP can be used after the container is restarted, and realize the staticization of the IP of the container.
Step 404: and after the workload exporter is deleted, deleting the record of the exporter in the static IP record table, and returning the IP to the IP address pool.
It will be understood by those skilled in the art that the above three examples are illustrative examples and are not intended as specific limitations on the static IP assignment process in this application.
Next, a static IP allocation system for containers, which is proposed according to an embodiment of the present application and managed by a workload, is described with reference to fig. 5, where the system specifically includes:
a first determining module 510, configured to obtain a first name of the workload, and determine that the first name exists in a static IP record table or the first name does not exist in the static IP record table;
a second determining module 520, configured to determine that an IP record exists in the container when the first name exists in the static IP record table;
a third determining module 530, configured to determine, according to the static IP record table, a first static IP matching the container, and allocate the first static IP to the container.
It can be seen that the contents in the foregoing method embodiments are all applicable to this system embodiment, the functions specifically implemented by this system embodiment are the same as those in the foregoing method embodiment, and the advantageous effects achieved by this system embodiment are also the same as those achieved by the foregoing method embodiment.
Referring to fig. 6, an embodiment of the present application provides a container static IP distribution apparatus, including:
at least one processor 610;
at least one memory 620 for storing at least one program;
the at least one program, when executed by the at least one processor 610, causes the at least one processor 610 to implement the container static IP allocation method.
Similarly, the contents of the method embodiments are all applicable to the apparatus embodiments, the functions specifically implemented by the apparatus embodiments are the same as the method embodiments, and the beneficial effects achieved by the apparatus embodiments are also the same as the beneficial effects achieved by the method embodiments.
In alternative embodiments, the functions/acts noted in the block diagrams may occur out of the order noted in the operational illustrations. 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/acts involved. Furthermore, the embodiments presented and described in the flowcharts of the present application are provided by way of example in order to provide a more comprehensive understanding of the technology. The disclosed methods are not limited to the operations and logic flows presented herein. Alternative embodiments are contemplated in which the order of various operations is changed and in which sub-operations described as part of larger operations are performed independently.
Furthermore, although the present application is described in the context of functional modules, it should be understood that, unless otherwise stated to the contrary, one or more of the functions and/or features may be integrated in a single physical device and/or software module, or one or more functions and/or features may be implemented in separate physical devices or software modules. It will also be appreciated that a detailed discussion regarding the actual implementation of each module is not necessary for an understanding of the present application. Rather, the actual implementation of the various functional modules in the apparatus disclosed herein will be understood within the ordinary skill of an engineer, given the nature, function, and internal relationship of the modules. Accordingly, those skilled in the art can, using ordinary skill, practice the present application as set forth in the claims without undue experimentation. It is also to be understood that the specific concepts disclosed are merely illustrative of and not intended to limit the scope of the application, which is defined by the appended claims and their full scope of equivalents.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium, which includes programs for enabling a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The logic and/or steps represented in the flowcharts or otherwise described herein, such as an ordered listing of executable programs that can be considered for implementing logical functions, can be embodied in any computer-readable medium for use by or in connection with a program execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the programs from the program execution system, apparatus, or device and execute the programs. For the purposes of this description, a "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the program execution system, apparatus, or device.
More specific examples (a non-exhaustive list) of the computer-readable medium would include the following: an electrical connection (electronic device) having one or more wires, a portable computer diskette (magnetic device), a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium could even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, via for instance optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner if necessary, and then stored in a computer memory.
It should be understood that portions of the present application may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable program execution system. For example, if implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
In the foregoing description of the specification, reference to the description of "one embodiment/example," "another embodiment/example," or "certain embodiments/examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
While embodiments of the present application have been shown and described, it will be understood by those of ordinary skill in the art that: numerous changes, modifications, substitutions and alterations can be made to the embodiments without departing from the principles and spirit of the application, the scope of which is defined by the claims and their equivalents.
While the present application has been described with reference to the preferred embodiments, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (10)

1. A method for static IP allocation of containers, wherein said containers are managed by a workload, said method comprising the steps of:
acquiring a first name of the workload, and determining that the first name exists in a static IP record table or the first name does not exist in the static IP record table;
if the first name exists in the static IP record table, determining that the IP record exists in the container;
and determining a first static IP matched with the container according to the static IP record table, and allocating the first static IP to the container.
2. The method according to claim 1, wherein the static IP record table includes a first sub record table, the first sub record table is used for recording a correspondence between a container name and a static IP, and the first static IP is determined by:
judging whether the working load is a stateful working load or not;
and if the workload is a stateful workload, determining that the static IP corresponding to the container name is a first static IP according to the first sub-record table.
3. The container static IP allocation method according to claim 1, wherein the static IP record table includes a second sub record table, the second sub record table is used for recording a corresponding relationship between a workload name and a static IP, and the first static IP is determined through the following steps:
judging whether the working load is a stateless working load or not;
if the working load is a stateless working load, determining a static IP set corresponding to the first name according to the second sub-record table;
and acquiring the working state of any static IP in the static IP set, and determining the static IP in the idle state as the first static IP.
4. The container static IP allocation method according to claim 1, wherein the static IP record table includes a third sub record table, the third sub record table is used for recording a correspondence between a node name and a static IP, and the first static IP is determined by the following steps:
judging whether the workload is a daemon set workload;
and if the workload is a guard set workload, determining that the static IP corresponding to the node name is a first static IP according to the third sub-record table.
5. The container static IP allocation method according to claim 1, further comprising:
and if the workload is deleted, putting the static IP corresponding to the container into an IP address pool.
6. The container static IP allocation method according to claim 1, further comprising:
and if the first name does not exist in the static IP record table, allocating a second static IP in an IP address pool to the container.
7. The container static IP allocation method according to claim 6, further comprising:
and putting the corresponding relation between the container and the second static IP into the static IP record table according to a preset format.
8. A container static IP allocation system, wherein the containers are managed by workloads, the system comprising:
a first determining module, configured to obtain a first name of the workload, and determine that the first name exists in a static IP record table or the first name does not exist in the static IP record table;
a second determining module, configured to determine that an IP record exists in the container when the first name exists in the static IP record table;
and the third determining module is used for determining a first static IP matched with the container according to the static IP record table and distributing the first static IP to the container.
9. A container static IP dispensing apparatus, comprising:
at least one processor;
at least one memory for storing at least one program;
when executed by the at least one processor, cause the at least one processor to implement a container static IP allocation method as claimed in any one of claims 1 to 7.
10. A storage medium having stored therein a program executable by a processor, characterized in that: the processor executable program when executed by a processor is for implementing a container static IP allocation method as claimed in any one of claims 1 to 7.
CN202111520237.9A 2021-12-13 2021-12-13 Container static IP distribution method, system, device and storage medium Active CN114500464B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111520237.9A CN114500464B (en) 2021-12-13 2021-12-13 Container static IP distribution method, system, device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111520237.9A CN114500464B (en) 2021-12-13 2021-12-13 Container static IP distribution method, system, device and storage medium

Publications (2)

Publication Number Publication Date
CN114500464A true CN114500464A (en) 2022-05-13
CN114500464B CN114500464B (en) 2023-12-12

Family

ID=81492883

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111520237.9A Active CN114500464B (en) 2021-12-13 2021-12-13 Container static IP distribution method, system, device and storage medium

Country Status (1)

Country Link
CN (1) CN114500464B (en)

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8788707B1 (en) * 2010-05-27 2014-07-22 Crimson Corporation Assigning a random static IP address in a quarantine network
CN107968851A (en) * 2017-12-06 2018-04-27 深信服科技股份有限公司 A kind of Floating IP address binding method and device based on k8s platforms
US20180367528A1 (en) * 2017-06-12 2018-12-20 Cyberark Software Ltd. Seamless Provision of Authentication Credential Data to Cloud-Based Assets on Demand
US20190235898A1 (en) * 2018-01-30 2019-08-01 Nutanix, Inc. Static ip retention for multi-homed vms on migration
CN110716787A (en) * 2018-07-13 2020-01-21 中兴通讯股份有限公司 Container address setting method, apparatus, and computer-readable storage medium
CN110750332A (en) * 2019-10-23 2020-02-04 广西梯度科技有限公司 Method for setting static IP (Internet protocol) in Pod in Kubernetes
CN111124604A (en) * 2019-12-05 2020-05-08 北京金山云网络技术有限公司 Method, device, equipment and storage medium for allocating Pod (POD) IP addresses
CN111352689A (en) * 2018-12-21 2020-06-30 中国电信股份有限公司 Method and device for realizing seamless migration of application containerized deployment
WO2020233020A1 (en) * 2019-05-17 2020-11-26 平安科技(深圳)有限公司 Method and device for pre-distributing container ip, computer device and storage medium
CN112153167A (en) * 2020-08-06 2020-12-29 北京百度网讯科技有限公司 Internet interconnection protocol management method, device, electronic equipment and storage medium
CN112243044A (en) * 2019-07-16 2021-01-19 广州虎牙科技有限公司 Container address allocation method and device
CN113285843A (en) * 2021-07-23 2021-08-20 中航金网(北京)电子商务有限公司 Container network configuration method and device, computer readable medium and electronic equipment

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8788707B1 (en) * 2010-05-27 2014-07-22 Crimson Corporation Assigning a random static IP address in a quarantine network
US20180367528A1 (en) * 2017-06-12 2018-12-20 Cyberark Software Ltd. Seamless Provision of Authentication Credential Data to Cloud-Based Assets on Demand
CN107968851A (en) * 2017-12-06 2018-04-27 深信服科技股份有限公司 A kind of Floating IP address binding method and device based on k8s platforms
US20190235898A1 (en) * 2018-01-30 2019-08-01 Nutanix, Inc. Static ip retention for multi-homed vms on migration
CN110716787A (en) * 2018-07-13 2020-01-21 中兴通讯股份有限公司 Container address setting method, apparatus, and computer-readable storage medium
CN111352689A (en) * 2018-12-21 2020-06-30 中国电信股份有限公司 Method and device for realizing seamless migration of application containerized deployment
WO2020233020A1 (en) * 2019-05-17 2020-11-26 平安科技(深圳)有限公司 Method and device for pre-distributing container ip, computer device and storage medium
CN112243044A (en) * 2019-07-16 2021-01-19 广州虎牙科技有限公司 Container address allocation method and device
CN110750332A (en) * 2019-10-23 2020-02-04 广西梯度科技有限公司 Method for setting static IP (Internet protocol) in Pod in Kubernetes
CN111124604A (en) * 2019-12-05 2020-05-08 北京金山云网络技术有限公司 Method, device, equipment and storage medium for allocating Pod (POD) IP addresses
CN112153167A (en) * 2020-08-06 2020-12-29 北京百度网讯科技有限公司 Internet interconnection protocol management method, device, electronic equipment and storage medium
CN113285843A (en) * 2021-07-23 2021-08-20 中航金网(北京)电子商务有限公司 Container network configuration method and device, computer readable medium and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
凌云;: "基于Docker平台的DevOps运维系统的研究与改进", 电脑知识与技术, no. 26 *

Also Published As

Publication number Publication date
CN114500464B (en) 2023-12-12

Similar Documents

Publication Publication Date Title
CN107580083B (en) Method and system for allocating IP addresses of containers
CN105897946B (en) A kind of acquisition methods and system of access address
CN102710814B (en) The control method of virtual machine IP address and device
US8577892B2 (en) Utilizing affinity groups to allocate data items and computing resources
WO2017107414A1 (en) File operation method and device
US20170208138A1 (en) Allocating edge services with large-scale processing framework clusters
US20200042344A1 (en) Cloud Management Platform, and Virtual Machine Management Method and System
US20210397351A1 (en) Synchronous discovery logs in a fabric storage system
US10713215B2 (en) Allocating non-conflicting inode numbers
CN112417051A (en) Container arrangement engine resource management method and device, readable medium and electronic equipment
CN108089912A (en) A kind of virtual machine surpasses emerging system construction method and device with container
CN105045762A (en) Management method and apparatus for configuration file
CN102355499A (en) Cloud computing system
CN111124589A (en) Service discovery system, method, device and equipment
CN103369038A (en) PaaS (platform as a service) management platform and method
CN114546563B (en) Multi-tenant page access control method and system
CN112256439A (en) Service directory dynamic updating system and method based on cloud computing resource pool
US8978041B2 (en) Service virtualization container
CN107408239B (en) Architecture for managing mass data in communication application through multiple mailboxes
CN111274004B (en) Process instance management method and device and computer storage medium
CN115080533A (en) Middle platform system for data exchange and sharing based on big data
CN114500464B (en) Container static IP distribution method, system, device and storage medium
CN115904876A (en) Method, system, terminal and medium for solving conflict of log data in different formats
CN115293365A (en) Management method, device, management platform and storage medium of machine learning model
CN114879907A (en) Data distribution determination method, device, equipment and storage medium

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