Floating IP transfer method and apparatus
By working collaboratively between the virtual machine control module and the floating IP control module, the conversion relationship between the floating IP address and the virtual machine's internal network IP address is automatically configured, solving the floating IP binding problem after virtual machine hot migration and achieving seamless access and efficient IP address transfer.
Patent Information
- Application Number
- CN202211694960.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-28
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2042-12-28
AI Technical Summary
After a virtual machine is hot-migrated, the physical node cannot automatically bind the floating IP address to the migrated virtual machine, causing users to be unable to access the hot-migrated virtual machine without noticing.
The virtual machine control module detects the virtual machines migrated to the physical node, determines their internal network IP address and the floating IP address to be associated, requests the configuration of the conversion relationship between the floating IP address and the internal network IP address using the Hypertext Transfer Protocol, and the floating IP control module performs the binding on the network card.
It enables automatic transfer and binding of floating IP addresses, ensuring that users can access the migrated virtual machines without being aware of it, improving the timeliness and reliability of floating IP transfer, and even working normally when the container orchestration system is abnormal.
Smart Images

Figure CN116095049B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of communication technology, in particular to a floating IP transfer method and device. BACKGROUND
[0002] Based on the virtual machine hot backup technology, the hot migration of the virtual machine across nodes can be realized, and the high availability of the virtual machine can be effectively guaranteed based on the virtual machine hot backup technology.
[0003] After the virtual machine is hot migrated, in order to enable the user to access the hot migrated virtual machine without awareness, the floating IP technology may be combined to configure the floating IP address bound to the original virtual machine to the migrated virtual machine. However, after the virtual machine is hot migrated, the physical node to which the virtual machine is hot migrated cannot automatically complete the binding of the floating IP address and the hot migrated virtual machine on the physical node after obtaining the floating IP address bound to the original virtual machine. SUMMARY
[0004] The present application provides a floating IP transfer method and device.
[0005] One floating IP transfer method is applied to a physical node in a cluster, the virtual machine control module and the floating IP control module are deployed on the physical node, and the method comprises the following steps.
[0006] The virtual machine control module detects the virtual machine migrated to the physical node, determines the intranet IP address of the virtual machine and the floating IP address to be associated to the virtual machine, and sends a hypertext transfer protocol request.
[0007] The hypertext transfer protocol request comprises the floating IP address and the intranet IP address of the virtual machine.
[0008] The floating IP control module obtains the hypertext transfer protocol request through a hypertext transfer server, configures the floating IP address for the network card of the physical node, and constructs the IP conversion relationship between the floating IP address and the intranet IP address of the virtual machine.
[0009] The network card receives a service request with the floating IP address as the destination address, and transmits the service request to the virtual machine based on the IP conversion relationship.
[0010] In one possible implementation, the hypertext transfer protocol request further comprises the node name of the physical node.
[0011] After the association relationship between the floating IP address and the intranet IP address of the virtual machine is constructed, the following steps are further included.
[0012] The floating IP control module updates a historical node name recorded in target floating IP resource information to a node name of the physical node, the target floating IP resource information being floating IP resource information associated with the floating IP address maintained in the cluster.
[0013] In yet another possible implementation, a container orchestration system for managing the virtual machine control module is deployed in the cluster.
[0014] Before updating the historical node name recorded in the target floating IP resource information to the node name of the physical node, the method further includes:
[0015] The floating IP control module requests the virtual machine set information maintained by the virtual machine control module from the container orchestration system.
[0016] The floating IP control module updates the historical node name recorded in the target floating IP resource information to the node name of the physical node, including:
[0017] If the node name of the target physical node where the virtual machine is located recorded in the virtual machine set information is the same as the node name of the physical node, the floating IP control module updates the historical node name recorded in the target floating IP resource information to the node name of the physical node.
[0018] In yet another possible implementation, before the virtual machine control module detects the virtual machine migrated to the physical node, the method further includes:
[0019] The floating IP control module creates a hypertext transfer server on the physical node.
[0020] In yet another possible implementation, after the floating IP control module updates the historical node name recorded in the target floating IP resource information to the node name of the physical node, the method further includes:
[0021] The floating IP control module detects that the target floating IP resource information has information change, and a current node name currently recorded in the target floating IP resource information is different from the node name of the physical node, the floating IP control module deletes the floating IP address configured in the network card of the physical node and the IP conversion relationship stored in the physical node.
[0022] In yet another possible implementation, after the floating IP control module updates the historical node name recorded in the target floating IP resource information to the node name of the physical node, the method further includes:
[0023] The floating IP control module sets a resource configuration state in the target floating IP resource information to completed change, so that the changed target floating IP resource information can be synchronized to each physical node in the cluster.
[0024] In yet another possible implementation, the floating IP control module updates a historical node name recorded in the target floating IP resource information to a node name of the physical node while the floating IP control module updates the target floating IP resource information.
[0025] The floating IP control module updates an intranet IP address recorded in the target floating IP resource information based on the intranet IP address of the virtual machine.
[0026] In yet another possible implementation, the method further includes:
[0027] Upon detecting an instruction to shut down the physical node or the virtual machine, the floating IP control module deletes the floating IP address configured in the network card of the physical node and the IP conversion relationship stored in the physical node;
[0028] Upon startup of the virtual machine in the physical node, the floating IP control module obtains virtual machine state information on the physical node;
[0029] If the virtual machine state information indicates that the virtual machine is not migrated, the floating IP control module configures the floating IP address for the network card of the physical node according to the floating IP address in the target floating IP resource information and the intranet IP address of the virtual machine, and constructs an IP conversion relationship between the floating IP address and the intranet IP address of the virtual machine.
[0030] The floating IP transfer device is applied to a physical node in a cluster, the physical node is deployed with a virtual machine control module and a floating IP control module, and the device includes:
[0031] An information determination unit is configured to determine an intranet IP address of a virtual machine and a floating IP address to be associated to the virtual machine by detecting, through the virtual machine control module, the virtual machine migrated to the physical node;
[0032] A request sending unit is configured to send, through the virtual machine control module, a hypertext transfer protocol request, the hypertext transfer protocol request including the floating IP address and the intranet IP address of the virtual machine.
[0033] The information configuring unit configures the floating IP address for the network card of the physical node by obtaining the HTTP request through the HTTP server based on the floating IP control module, and constructs the IP conversion relationship between the floating IP address and the intranet IP address of the virtual machine.
[0034] The service processing unit transmits the service request to the virtual machine based on the IP conversion relationship when receiving the service request with the floating IP address as the destination address through the network card.
[0035] In a possible implementation, the HTTP request sent by the request sending unit further includes the node name of the physical node.
[0036] Further comprising:
[0037] The resource information updating unit updates the historical node name recorded in the target floating IP resource information to the node name of the physical node through the floating IP control module after the information configuring unit constructs the association relationship between the floating IP address and the intranet IP address of the virtual machine, where the target floating IP resource information is the floating IP resource information associated with the floating IP address maintained in the cluster.
[0038] As can be seen from the above, in the embodiments of the present application, after the virtual machine control module in the physical node detects the virtual machine migrated to the physical node, the virtual machine control module determines the intranet IP address of the virtual machine and the floating IP address to be associated with the virtual machine, and sends the floating IP address and the intranet IP address of the virtual machine through the HTTP request. Based on this, the floating IP control module on the physical node can obtain the floating IP address and the intranet IP address of the virtual machine through the HTTP server, and can naturally configure the floating IP address for the network card of the physical node, and construct the IP conversion relationship between the floating IP address and the intranet IP address of the virtual machine, so as to realize the transfer of the floating IP address associated with the original virtual machine before migration to the virtual machine after migration, so that the physical node can transmit the service request with the floating IP address as the destination address to the virtual machine based on the IP conversion relationship. BRIEF DESCRIPTION OF DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor based on the provided drawings.
[0040] Figure 1Fig. 1 shows a flow diagram of the floating IP transfer method provided by an embodiment of the present application;
[0041] Figure 2 Fig. 2 shows another flow diagram of the floating IP transfer method provided by an embodiment of the present application;
[0042] Figure 3 Fig. 3 shows another flow diagram of the floating IP transfer method provided by an embodiment of the present application;
[0043] Figure 4 Fig. 4 shows a processing flow diagram of the floating IP control module processing the floating IP address when the virtual machine is closed or opened in an embodiment of the present application;
[0044] Figure 5 Fig. 5 shows a component structure diagram of the floating IP transfer device in an embodiment of the present application;
[0045] Figure 6 Fig. 6 shows a component structure diagram of the electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0046] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort belong to the scope of protection of the present application.
[0047] As shown in Fig. 1, it shows a flow diagram of the floating IP transfer method provided by an embodiment of the present application, and the method of the present embodiment can be applied to a physical node in a cluster, and the physical node is deployed with a virtual machine control module and a floating IP control module. Figure 1
[0048] The method of the present embodiment can include:
[0049] S101, the virtual machine control module detects a virtual machine migrated to the physical node, determines an intranet IP address of the virtual machine and a floating IP address to be associated to the virtual machine.
[0050] The virtual machine control module is a functional module for managing each virtual machine on the physical node. In the present application, a virtual machine control module is run on each physical node to manage and maintain the running and migration of each virtual machine on the physical node and other virtual machine related states.
[0051] The detecting the virtual machine migrated to the physical node refers to detecting that the virtual machine on other physical nodes in the cluster is migrated to the virtual machine on the physical node by a hot migration manner. On this basis, the virtual machine on the physical node can replace the migrated virtual machine on the original physical node to provide service to the outside, so as to ensure the reliability of the cluster to provide service to the outside.
[0052] For example, the virtual machine a on the physical node A has an exception or the like, and the virtual machine a on the physical node A can be migrated to the virtual machine b on the physical node B by a hot migration technology. The virtual machine b on the physical node B belongs to the migrated virtual machine.
[0053] It can be understood that there are many possible specific implementation manners of the hot migration, and the present application does not limit this.
[0054] For example, in an implementation manner, after the virtual machine in the cluster is provided with the hot migration function, two virtual machines are generated on different physical nodes. One of the two virtual machines is a primary virtual machine (PVM), and the other is a standby virtual machine (SVM). The primary virtual machine and the standby virtual machine synchronize state data at regular intervals or irregular intervals, so that the data on the primary virtual machine and the standby virtual machine are synchronized.
[0055] Correspondingly, after the virtual machine control module on a certain physical node detects that the primary virtual machine is abnormal, the virtual machine migration is triggered to be executed, so that the service provided by the primary virtual machine to the outside is taken over by the standby virtual machine corresponding to the primary virtual machine on other physical nodes. On this basis, the virtual control module on the physical node where the standby virtual machine is located changes the virtual machine state of the standby virtual machine to the primary virtual machine after determining that the primary virtual machine is migrated to the standby virtual machine.
[0056] It can be understood that after the other physical node migrates the original virtual machine to the virtual machine on the physical node, the virtual machine control module can determine the IP (Internet Protocol) address of the virtual machine on the physical node, that is, the internal network IP address. At the same time, since the virtual machine control module can also obtain the floating IP address bound to the original virtual machine (for example, the original primary virtual machine) corresponding to the virtual machine migrated to the physical node, the floating IP address is the floating IP address that needs to be migrated to the virtual machine on the physical node, that is, the floating IP address to be associated (or bound) to the virtual machine.
[0057] The floating IP address refers to an IP address that can float on any host or virtual machine, but the IP address itself does not change.
[0058] The virtual machine control module can obtain the floating IP address in the same way as the conventional way, and no limitation is imposed thereon. For example, during the virtual machine live migration, the virtual machine control module where the original virtual machine is located can transmit the floating IP address and other information bound to the original virtual machine to the virtual machine control module.
[0059] Of course, after the virtual machine control module detects the virtual machine migrated to the physical node, the virtual machine control module can determine part or all of the name of the virtual machine, the namespace where the virtual machine is located, and the node name of the physical node (i.e., the physical node running the virtual machine control module) where the virtual machine is located, and no limitation is imposed thereon. The namespace where the virtual machine is located can be a nameable space range, and the name of the virtual machine and the namespace where the virtual machine is located can uniquely identify a virtual machine.
[0060] S102, the virtual machine control module sends a Hyper Text Transfer Protocol (HTTP) request.
[0061] The HTTP request includes the floating IP address and the intranet IP address of the virtual machine.
[0062] In this application, the destination of the HTTP request sent by the virtual machine control module is the HTTP server previously created by the floating IP control module.
[0063] For example, the virtual machine control module and the floating IP control module are previously configured with a specified port corresponding to the HTTP server, and on this basis, the virtual machine control module can transmit the HTTP request to the specified port, so that the HTTP server previously created by the floating IP control module can monitor and obtain the HTTP request.
[0064] S103, the floating IP control module obtains the HTTP request through the HTTP server, configures the floating IP address for the network card of the physical node, and builds the IP conversion relationship between the floating IP address and the intranet IP address of the virtual machine.
[0065] It can be understood that the floating IP control module can be a control system module for managing the floating IP in the physical node. For example, the floating IP control module can configure the binding relationship between the floating IP address and the virtual machine, release the binding relationship between the floating IP address and the virtual machine, and maintain the floating IP resource information corresponding to the floating IP address.
[0066] In the present application, the floating IP control module is deployed and run on each physical node in the cluster. For example, in a cluster based on the K8S container orchestration system, the floating IP control module related program can be deployed on each physical node in the cluster through DaemonSet.
[0067] The hypertext transfer server can be an HTTP server created by the floating IP control module on the physical node. The HTTP server is used to listen to HTTP requests from the virtual machine control module.
[0068] It can be understood that the hypertext transfer server can be created in advance. Based on this, the floating IP control module will create a hypertext transfer server on the physical node before the virtual machine control module detects the virtual machine migrated to the physical node. For example, the floating IP control module REST API technology or other application program interface creation technologies are used to create the HTTP server.
[0069] The floating IP address is configured for the network card of the physical node, that is, the floating IP address is added to the network card, realizing the binding of the floating IP address and the network card. On this basis, the service request with the floating IP address as the destination received in the network will be forwarded to the network card by the router, so that the physical node receives the service request directed to the floating IP address.
[0070] The IP conversion relationship between the floating IP address and the internal network IP address of the virtual machine is actually an IP link relationship between the floating IP address and the internal network IP address of the virtual machine configured in the physical node.
[0071] Through the IP conversion relationship, it can be determined that the service request sent to the floating IP address needs to be transmitted to the virtual machine whose internal network IP address is pointed to by the internal network IP address of the virtual machine. Moreover, after the virtual machine initiates data with the internal network IP address of the virtual machine as the address of the initiator, the IP address carried by the data initiated by the virtual machine can be converted to the floating IP address based on the IP conversion relationship.
[0072] S104, receiving the service request with the floating IP address as the destination through the network card, and transmitting the service request to the virtual machine based on the IP conversion relationship.
[0073] As introduced in step S103, after the floating IP address is configured for the network card of the physical node, the physical node can receive the service request directed to the floating IP address through the network card, and determine the corresponding relationship between the floating IP address and the internal network IP address of the virtual machine based on the IP conversion relationship, so as to forward the service request to the virtual machine, so that the virtual machine can bind the floating IP address for data receiving and sending.
[0074] From the above, in the embodiments of the present application, after the virtual machine control module in the physical node detects the virtual machine migrated to the physical node, the virtual machine control module determines the intranet IP address of the virtual machine and the floating IP address to be associated with the virtual machine, and sends the floating IP address and the intranet IP address of the virtual machine through the hypertext transfer protocol request. Based on this, the floating IP control module on the physical node can obtain the floating IP address and the intranet IP address of the virtual machine through the hypertext transfer server. Naturally, the floating IP control module can configure the floating IP address for the network card of the physical node, and build the IP conversion relationship between the floating IP address and the intranet IP address of the virtual machine, so as to realize the transfer of the floating IP address associated with the original virtual machine before migration to the virtual machine after migration, so that the physical node can transmit the service request with the destination address as the floating IP address to the virtual machine based on the IP conversion relationship after receiving the service request with the destination address as the floating IP address.
[0075] In addition, in the scheme of the present application, the floating IP control module of the physical node can obtain the intranet IP address of the virtual machine migrated to the physical node and the floating IP address to be associated with the virtual machine through the virtual machine control module, and complete the binding of the floating IP address and the migrated virtual machine. The floating IP control module does not need to obtain the related information of the migrated virtual machine through the container orchestration system deployed in the cluster, so that even if the container orchestration system is abnormal or temporarily unavailable, the floating IP address can be bound to the virtual machine after migration, so that the time efficiency of floating IP transfer can be effectively guaranteed without waiting for the container orchestration system to recover.
[0076] It can be understood that, in order to enable each physical node in the cluster to know the related information of the virtual machine to which each floating IP address is bound, floating IP resource information associated with the floating IP address can be maintained in the cluster. On this basis, for any physical node in the cluster, if there is a virtual machine migrated to the physical node, after the floating IP control module configures the binding relationship between the virtual machine and the floating IP address on the physical node, the floating IP control module also needs to update the floating IP resource information corresponding to the floating IP address.
[0077] Based on this, after the virtual machine control module on the physical node detects that the physical node has a virtual machine migration, the floating IP control module needs to be notified of the information of the physical node where the virtual machine is located, so that the floating IP control module updates the floating IP resource information corresponding to the floating IP address based on the information of the physical node where the virtual machine is located. Correspondingly, in the above embodiments of the present application, the hypertext transfer protocol request sent by the virtual machine control module can also include the node name of the physical node.
[0078] Correspondingly, the floating IP control module can also update the historical node name recorded in the target floating IP resource information to the node name of the physical node after establishing the association between the floating IP address and the intranet IP address of the virtual machine, the target floating IP resource information being the floating IP resource information associated with the floating IP address maintained in the cluster.
[0079] In the floating IP resource information associated with the floating IP address, not only the node name of the physical node where the virtual machine is located to which the floating IP address is bound, but also the intranet IP address of the virtual machine can be recorded.
[0080] In actual applications, the live migration technology of the virtual machine can also enable the intranet IP address of the virtual machine to remain unchanged after the virtual machine is migrated to another physical node. Of course, in order to avoid the change of the intranet IP address of the virtual machine, which leads to the change of the intranet IP address of the virtual machine in the floating IP resource information corresponding to the floating IP address, the floating IP control module of the present application can also update the intranet IP address recorded in the target floating IP resource based on the intranet IP address of the virtual machine.
[0081] For example, if the intranet IP address of the virtual machine is consistent with the intranet IP address of the virtual machine recorded in the target floating IP resource information associated with the floating IP address, the intranet IP address of the virtual machine in the target floating IP resource information does not need to be changed; otherwise, the intranet IP address in the target floating IP resource information can be changed to the intranet IP address of the virtual machine.
[0082] It can be understood that the floating IP resource information associated with the floating IP address can also record other information of the virtual machine. The following shows an example of various resources involved in the floating IP resource information:
[0083] Field Type Description FloatingIPAddress Character type Floating IP address FixedIPAddress Character type Intranet IP address of the virtual machine VmName Character type Name of the virtual machine VmNameSpace Character type Namespace where the virtual machine is located NodeName Character type Name of the physical node where the virtual machine is located Status Character type Resource configuration completion status
[0084] It can be understood that in actual applications, similar to the intranet IP address of the virtual machine, the name of the virtual machine and the namespace where the virtual machine is located can remain unchanged after the virtual machine is migrated, and therefore, when the floating IP control module changes the floating IP resource information corresponding to the floating IP address, the name of the virtual machine and the namespace where the virtual machine is located do not need to be changed.
[0085] Of course, if the name of the virtual machine and the namespace where the virtual machine is located change during the migration of the virtual machine, the HTTP request sent by the virtual machine control module to the floating IP control module can also include the name of the virtual machine and the namespace where the virtual machine is located, and the like, so that the floating IP control module updates the related information in the floating IP resource information in the floating IP module based on the name of the virtual machine and the namespace where the virtual machine is located, and the like.
[0086] It can be understood that the virtual machine control module notifies the floating IP control module after detecting that the other virtual machine migrates to the virtual machine of the physical node, but at this time, the virtual machine switching may not have been completed or may not have been switched successfully. If the floating IP address associated floating IP resource information is changed in the case that the virtual machine migration is not successful, it may cause abnormal communication in the cluster. Based on this, the floating IP control module can also change the floating IP address associated floating IP resource information in the case that it is determined that the virtual machine has been successfully migrated. The following will be described in combination with an embodiment.
[0087] As shown in Figure 2 Another flowchart of the floating IP transfer method provided by the embodiment of the application is shown, and the embodiment is applied to a physical node in a cluster. The cluster has a container orchestration system, and the container orchestration system can manage virtual machine control modules on each physical node in the cluster.
[0088] The container orchestration system can be a program system based on a container orchestrator technology, that is, a tool for arranging containers, which can be used for automatically deploying, expanding and managing containerized applications. The container orchestration system can provide resource scheduling, deployment and running, service discovery and expansion and contraction for containerized applications. Correspondingly, each physical node in the cluster deployed with the container orchestration system can be deployed with at least one container, and the virtual machine can be started and run through the container.
[0089] The container orchestration system can have many possibilities, and no limitation is made thereto. For example, the container orchestration system can be a k8s system.
[0090] The method of the embodiment can include:
[0091] S201, the virtual machine control module detects a virtual machine migrated to the physical node, determines attribute information of the virtual machine, a node name of the physical node where the virtual machine is located, and a floating IP address to be associated to the virtual machine.
[0092] The attribute information of the virtual machine at least includes an intranet IP address of the virtual machine. Of course, the attribute information of the virtual machine can also include a name of the virtual machine and a namespace where the virtual machine is located.
[0093] S202, the virtual machine control module sends a hypertext transfer protocol request.
[0094] The hypertext transfer protocol request includes the attribute information of the virtual machine, the node name of the physical node where the virtual machine is located, and the floating IP address. The attribute information of the virtual machine at least includes the intranet IP address of the virtual machine, and of course can also include the name of the virtual machine and the namespace where the virtual machine is located.
[0095] S203, the floating IP control module obtains the hypertext transfer protocol request through the hypertext transfer server, configures the floating IP address for the network card of the physical node, and constructs the IP conversion relationship between the floating IP address and the intranet IP address of the virtual machine.
[0096] S204, after receiving a service request with the floating IP address as the destination address through the network card, the service request is transmitted to the virtual machine based on the IP conversion relationship.
[0097] The above steps S201 to S204 can refer to the related description of the previous embodiment, which will not be repeated here.
[0098] S205, the floating IP control module requests the virtual machine set information maintained by the virtual machine control module from the container orchestration system.
[0099] The virtual machine set information maintained by the virtual machine control module can include the state information of each virtual machine under the physical machine maintained by the virtual machine control module, such as whether the virtual machine migration is successful, the node name of the physical node where the virtual machine is located after migration, etc. The virtual machine set information can also be referred to as virtual machine instance vmi resource information.
[0100] It can be understood that if the container orchestration system in the cluster has a fault or an exception, for example, the container orchestration system has not been transferred from the main physical node to other physical nodes due to a fault, resulting in that the container orchestration system is unavailable, etc., then the floating IP control module can start a coroutine, which requests the virtual machine set information corresponding to the virtual machine control module from the container orchestration system once every period of time through the coroutine until the container orchestration system recovers to normal, so that the floating IP control module receives the virtual machine set information.
[0101] Of course, if the container orchestration system does not have an exception, then the floating IP control module can quickly obtain the virtual machine set information.
[0102] It should be noted that the step S205 can be executed after the step S203, and in actual application, the service request may not be received before the step S205 is executed, so the step S204 will not be executed, and therefore, the order of the steps S204 and S205 is not limited to that shown in the figure. Figure 2
[0103] S206, if the node name of the target physical node where the virtual machine is located recorded in the virtual machine set information is the same as the node name of the physical node, the floating IP control module updates the historical node name recorded in the target floating IP resource information associated with the floating IP address to the node name of the physical node.
[0104] In order to distinguish, the physical node where the virtual machine recorded in the virtual machine set information is called the target physical node.
[0105] It can be understood that if the virtual machine has been successfully migrated to the physical node, the node name of the target physical node where the virtual machine is maintained in the virtual machine control module of the physical node is necessarily the node name of the physical node, in which case the floating IP control module can perform the operation of updating the target floating IP resource information associated with the floating IP address.
[0106] In order to distinguish, the node name of the physical node recorded in the target floating IP resource information before the virtual machine is migrated is called the historical node name.
[0107] It can be understood that if the name of the virtual machine, the namespace where the virtual machine is located, and the intranet IP address of the virtual machine do not change during the migration of the virtual machine, then the name of the virtual machine, the namespace where the virtual machine is located, and the intranet IP address of the virtual machine in the target floating IP resource information associated with the floating IP address need to be updated.
[0108] Of course, if at least one of the name of the virtual machine, the namespace where the virtual machine is located, or the intranet IP address of the virtual machine changes during the migration of the virtual machine, the floating IP control module can also update the corresponding information in the target floating IP address based on the attribute information of the virtual machine in the received HTTP request.
[0109] S207, the floating IP control module sets the resource configuration state in the target floating IP resource information to completed change, so that the changed target floating IP resource information can be synchronized to each physical node in the cluster.
[0110] The resource configuration state can be the resource configuration completion state in the last row of the table as described above, which can represent whether the target floating IP resource information has completed the change. For example, if the resource configuration state is changed to ready, it indicates that the resource configuration state has completed the change.
[0111] On this basis, since the target floating IP resource information is maintained by the cluster, each physical node in the cluster synchronously updates the floating IP resource information associated with each floating IP address, so that the floating IP control module on each physical node can timely detect the floating IP resource information with information change.
[0112] It can be understood that the step S207 can be an optional step, and in actual application, the floating IP control module on each physical node in the cluster can also confirm the existence of the updated floating IP resource information in the cluster through other manners. For example, the floating IP control module can send the changed floating IP resource information to other floating IP control modules in the physical node after updating the real floating IP resource information.
[0113] Of course, based on the different floating IP management mechanisms in the cluster, there can be other ways for the floating IP control module to obtain the changed floating IP resource information, and no limitation is added.
[0114] It can be understood that in the present application, after the floating IP control module on the physical node in the cluster detects the information change of the floating IP resource information, the floating IP control module also needs to determine whether the floating IP address configured in the network card of the physical node needs to be released and the IP association information corresponding to the floating IP address configured by the physical node needs to be deleted based on the changed floating IP resource information, so as to avoid the situation that the same floating IP address is bound to multiple different physical nodes.
[0115] Correspondingly, in any one of the above embodiments of the present application, if the floating IP control module on the physical node detects that the target floating IP resource information has changed, it needs to determine whether the current node name currently recorded in the target floating IP resource information is the node name of the physical node.
[0116] If the current node name currently recorded in the target floating IP resource information is different from the node name of the physical node, it means that the floating IP address in the target floating IP resource information has been bound to the virtual machine on other physical nodes along with the migration of the virtual machine, and therefore, the floating IP control module needs to delete the floating IP address configured in the network card of the physical node and the IP conversion relationship between the floating IP address and the IP address of the virtual machine stored in the physical node.
[0117] Of course, if the floating IP control module on the physical node detects that the target floating IP resource information has changed, and the current node name currently recorded in the target IP resource information is the same as the node name of the physical node, in order to ensure that the target floating IP resource information has indeed been changed, the physical node can also detect whether the resource configuration state in the target floating IP resource information is changed, and if not, update the resource configuration state information to be changed.
[0118] For any one of the physical nodes other than the physical node, after the physical node detects the target floating IP resource information, it is found that the physical node where the virtual machine recorded in the target floating IP resource information is not itself, and the floating IP address associated with the target floating IP resource information is not bound on the physical node, then no processing can be performed.
[0119] For the convenience of understanding, an example is used for illustration. It is assumed that the virtual machine M on the first physical node is migrated to the virtual machine N on the second physical node. For the convenience of description, it is assumed that the virtual machine name and the internal network IP address of the virtual machine do not change before and after the hot migration, and based on this, the name and the internal network IP address of the virtual machine M and the virtual machine N can be the same. On this basis, the floating IP transfer process can be referred to as shown in Figure 3
[0120] For the convenience of distinction, the virtual machine control module deployed on the first physical node is referred to as the first virtual machine control module, the floating IP control module deployed on the first physical node is referred to as the first floating IP control module, and the virtual machine control module on the second physical node is referred to as the second virtual machine control module. Similarly, the floating IP control module on the second physical node is referred to as the second floating IP control module.
[0121] Figure 3 A flowchart of a floating IP transfer process provided by an embodiment of the application in an application scenario is shown. The embodiment can include the following steps:
[0122] S301, the second virtual machine control module of the second physical node detects that the virtual machine M on the first physical node is migrated to the virtual machine N on the second physical node, determines the internal network IP address of the virtual machine N, the floating IP address to be transferred from the virtual machine M to the virtual machine N, and the node name of the second physical node where the virtual machine N is located.
[0123] S302, the second virtual machine control module sends an HTTP request to the HTTP server on the second physical node.
[0124] The HTTP request includes the internal network IP address of the virtual machine N, the floating IP address, and the node name of the second physical node.
[0125] The HTTP server is previously created for the second floating IP control module on the second physical node.
[0126] S303, the second floating IP control module of the second physical node obtains the HTTP request through the HTTP server created by the second floating IP control module, configures the floating IP address for the network card of the second physical node, and builds and stores the IP conversion relationship between the floating IP address and the intranet IP address of the virtual machine N in the second physical node.
[0127] S304, the second floating IP control module requests the virtual machine set information maintained by the second virtual machine control module from the container orchestration system.
[0128] S305, if the node name of the physical node where the virtual machine N is located recorded in the virtual machine set information is the same as the node name of the second physical node, the second floating IP control module updates the historical node name recorded in the target floating IP resource information associated with the floating IP address to the node name of the second physical node, and sets the resource configuration state in the target floating IP resource information to completed change.
[0129] S306, the first floating IP control module on the first physical node detects that the target floating IP resource information exists information change, confirms that the IP conversion relationship corresponding to the floating IP address in the target floating IP resource information is stored in the first physical node, and the node name recorded in the target floating IP resource information is not the node name of the first physical node, deletes the floating IP address configured in the network card of the first physical node and the IP conversion relationship corresponding to the floating IP address stored in the first physical node.
[0130] For the second physical node, the second floating IP control module detects that the target floating IP resource information exists information change, determines that the IP conversion relationship corresponding to the floating IP address in the target floating IP resource information is stored in the second physical node, and the node name recorded in the target floating IP resource information is the node name of the second physical node, and the operation is ended.
[0131] Of course, the second floating IP control module can further confirm whether the resource configuration state in the detected target floating IP resource information is completed change in the case that it is confirmed that the IP conversion relationship corresponding to the floating IP address in the target floating IP resource information is stored in the second physical node, and the node name recorded in the target floating IP resource information is the node name of the second physical node, if yes, no other processing is needed; if no, the resource configuration state in the target floating IP resource information can be updated to completed change.
[0132] It can be understood that if the virtual machine N on the subsequent second physical node migrates to other physical nodes, causing the target floating IP resource information to change, the second floating IP control module on the second physical node can perform similar operations as the first floating IP control module in step S306, which will not be described here.
[0133] It can be understood that in actual application, a user can also configure a floating IP resource for a virtual machine on a physical node. Specifically, the user inputs floating IP configuration information to the container orchestration system of the physical node, and the floating IP configuration information includes: a floating IP address, a name of a virtual machine to which the floating IP address needs to be bound, and an intranet IP address of the virtual machine.
[0134] The container orchestration system can transmit the floating IP configuration information to the floating IP control module of the physical node. The floating IP control module can configure the floating IP address set by the user for the network card of the physical node according to the introduction of the foregoing embodiments, and store the IP conversion relationship between the floating IP address and the intranet IP address of the virtual machine on the physical node.
[0135] In addition, the floating IP control module stores the floating IP resource information corresponding to the floating IP address in the cluster based on the node name of the physical node where the virtual machine is located and the floating IP configuration information.
[0136] In the present application, under the premise that the floating IP address is bound to the virtual machine on the physical node by any one of the foregoing ways, if the virtual machine is normally closed or the physical node is powered off due to other abnormal reasons, the floating IP control module will not only clear the floating IP address bound to the virtual machine from the configuration of the network card in the physical node, but also delete the IP conversion relationship corresponding to the floating IP address stored in the physical node. On this basis, the floating IP control module needs to reconfigure the binding relationship between the virtual machine and the floating IP address on the physical node based on the floating IP resource information associated with the virtual machine each time the virtual machine is powered on.
[0137] The floating IP resource information associated with the virtual machine refers to floating IP resource information containing the name of the virtual machine and the namespace where the virtual machine is located.
[0138] Based on the above, if a virtual machine is migrated due to an anomaly on a physical node, the floating IP resource control information corresponding to the original IP address bound to the migrated virtual machine will be updated. The floating IP control module on that physical node will also promptly obtain this updated floating IP resource control information. After the virtual machine restarts, the floating IP control module, based on the updated floating IP resource control information, can determine that the currently recorded node name in the floating IP resource information is not the physical node. Therefore, the floating IP control module will not rebind the floating IP address for the migrated virtual machine based on the updated floating IP resource control information.
[0139] However, if a virtual machine on a physical node is migrated due to a physical node failure, the floating IP control module on the physical node may not receive the updated floating IP resource information in a timely manner after the floating IP resource information corresponding to the original floating IP address bound to the virtual machine is updated in the cluster. Furthermore, even after the physical node is repaired and restarted, the floating IP control module may still use locally stored, outdated floating IP resource information to bind the migrated virtual machine to that floating IP address, resulting in an incorrect floating IP address binding.
[0140] To avoid this problem, this application will also detect whether the virtual machine belongs to the migrated virtual machine after the virtual machine is powered on. If it is, the application will not rebind the floating IP address to the virtual machine based on the floating IP resource information associated with the virtual machine.
[0141] For example, see Figure 4 As shown, this diagram illustrates a processing flow of the floating IP control module handling floating IP addresses when the virtual machine is shut down and started, as described in this application. The flow applies to physical nodes in a cluster and may include:
[0142] S401, upon detecting an instruction to shut down a physical node or virtual machine, the floating IP control module deletes the floating IP address associated with the virtual machine configured in the network card of the physical node, and deletes the IP translation relationship corresponding to the floating IP address stored in the physical node.
[0143] The virtual machine can be the one mentioned earlier that was migrated to this physical node. This embodiment can be an operation performed based on the previous embodiment where a floating IP address was bound to the virtual machine.
[0144] S402, after the virtual machine is powered on in the physical node, the floating IP control module obtains the virtual machine status information on the physical node.
[0145] The virtual machine status information is used to indicate whether the virtual machine has been migrated. For example, in the case of virtual machine migration from a primary virtual machine to a backup virtual machine, the virtual machine status information can indicate whether the virtual machine is still in the primary virtual machine state. If so, it means that the virtual machine has not been migrated and is still running as the primary virtual machine on the physical node.
[0146] S403, if the virtual machine status information indicates that the virtual machine has not been migrated, the floating IP control module configures the floating IP address for the network card of the physical node based on the floating IP address in the target floating IP resource information and the virtual machine's internal network IP address, and constructs the IP translation relationship between the floating IP address and the virtual machine's internal network IP address.
[0147] As mentioned above, if the virtual machine is not migrated, there will be no update of the target floating IP resource information associated with the virtual machine (or the floating IP address bound to the virtual machine) due to the virtual machine migration. Therefore, even if the virtual machine is shut down due to a physical node failure, there will be no situation where the floating IP control module on the physical node fails to update the target floating IP resource information in a timely manner, and there will be no abnormal floating IP address configuration due to the failure to update the target floating IP resource information in a timely manner.
[0148] Of course, if the virtual machine status information indicates that the virtual machine has been migrated, then there is no need to bind a floating IP address to the virtual machine on the physical node, and therefore no need to perform operations such as configuring a floating IP for the network card and building the corresponding IP translation relationship.
[0149] Corresponding to the floating IP transfer method provided in the embodiments of this application, the embodiments of this application also provide a floating IP transfer device.
[0150] like Figure 5 The diagram illustrates a structural composition of a floating IP transfer device provided in this application embodiment. This device is applied to a physical node in a cluster, where a virtual machine control module and a floating IP control module are deployed. The device includes:
[0151] The information determination unit 501 is used to detect the virtual machine migrated to the physical node through the virtual machine control module, and determine the internal network IP address of the virtual machine and the floating IP address to be associated with the virtual machine;
[0152] The request sending unit 502 is used to send a Hypertext Transfer Protocol request through the virtual machine control module. The Hypertext Transfer Protocol request includes: the floating IP address and the virtual machine's internal network IP address.
[0153] The information configuration unit 503 is configured to obtain the HTTP request by the floating IP control module through the HTTP server, configure the floating IP address for the network card of the physical node, and build the IP conversion relationship between the floating IP address and the intranet IP address of the virtual machine.
[0154] The service processing unit 504 is configured to receive a service request with the destination address being the floating IP address through the network card, and transmit the service request to the virtual machine based on the IP conversion relationship.
[0155] In a possible implementation, the HTTP request sent by the request sending unit further includes a node name of the physical node.
[0156] The apparatus further includes:
[0157] The information updating unit is configured to update a historical node name recorded in target floating IP resource information to the node name of the physical node by the floating IP control module after the information configuration unit builds the association relationship between the floating IP address and the intranet IP address of the virtual machine, the target floating IP resource information being floating IP resource information associated with the floating IP address maintained in the cluster.
[0158] In another possible implementation, a container orchestration system for managing the virtual machine control module is deployed in the cluster.
[0159] The apparatus further includes:
[0160] The information request unit is configured to request virtual machine set information maintained by the virtual machine control module from the container orchestration system by the floating IP control module before the information updating unit updates the historical node name recorded in the target floating IP resource information to the node name of the physical node.
[0161] The information updating unit includes:
[0162] The information updating sub-unit is configured to update the historical node name recorded in the target floating IP resource information to the node name of the physical node by the floating IP control module if the node name of a target physical node where the virtual machine is located recorded in the virtual machine set information is the same as the node name of the physical node.
[0163] In another possible implementation, the apparatus further includes:
[0164] The server creating unit is configured to create a hypertext transfer server on the physical node through the floating IP control module before the information determining unit detects the virtual machine migrated to the physical node through the virtual machine control module.
[0165] In yet another possible implementation, the apparatus further includes:
[0166] The resource recycling unit is configured to, after the information updating unit updates the historical node name recorded in the target floating IP resource information to the node name of the physical node, detect, through the floating IP control module, that the target floating IP resource information has information change, and that the current node name currently recorded in the target floating IP resource information is different from the node name of the physical node, and the floating IP control module deletes the floating IP address configured in the network card of the physical node and the IP conversion relationship stored in the physical node.
[0167] In yet another possible implementation, the apparatus further includes:
[0168] The state modifying unit is configured to, after the information updating unit updates the node name in the target floating IP resource information associated with the floating IP address to the node name of the physical node, set the resource configuration state in the target floating IP resource information to changed to be completed through the floating IP control module, so that the changed target floating IP resource information can be synchronized to each physical node in the cluster.
[0169] In yet another possible implementation, the address updating unit is configured to, while the information updating unit updates the historical node name recorded in the target floating IP resource information to the node name of the physical node, update the intranet IP address recorded in the target floating IP resource information based on the intranet IP address of the virtual machine through the floating IP control module.
[0170] In yet another possible implementation, the apparatus further includes:
[0171] The configuration clearing unit is configured to, after detecting an instruction to shut down the physical node or the virtual machine, delete the floating IP address configured in the network card of the physical node and the IP conversion relationship stored in the physical node through the floating IP control module.
[0172] The state obtaining unit is configured to, after the virtual machine in the physical node is started, obtain the virtual machine state information on the physical node through the floating IP control module.
[0173] The reconfiguration unit is configured to, if the virtual machine state information indicates that the virtual machine is not migrated, configure, by the floating IP control module, a network card of the physical node with a floating IP address according to the floating IP address in the target floating IP resource information and the intranet IP address of the virtual machine, and build an IP conversion relationship between the floating IP address and the intranet IP address of the virtual machine.
[0174] In another aspect, the present application also provides an electronic device, which can be the physical node mentioned above. As shown in Figure 6 which shows a structural diagram of the electronic device, which can be any type of electronic device, and the electronic device at least includes a processor 601 and a memory 602.
[0175] The processor 601 is configured to execute the floating IP transfer method in any one of the above embodiments.
[0176] The memory 602 is configured to store programs required by the processor to execute operations.
[0177] It can be understood that the electronic device can further include a display unit 603 and an input unit 604.
[0178] Of course, the electronic device can also have more or less components, and there is no limitation in this regard. Figure 6
[0179] In another aspect, the present application also provides a computer readable storage medium, which stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the floating IP transfer method in any one of the above embodiments.
[0180] The present application also proposes a computer program, which includes computer instructions stored in a computer readable storage medium. The computer program is used to execute the floating IP transfer method in any one of the above embodiments when running on an electronic device.
[0181] It should be noted that each embodiment in the present specification adopts a progressive manner for description, and each embodiment focuses on the difference from other embodiments, and the same and similar parts of each embodiment can be referred to. Meanwhile, the features recorded in each embodiment in the present specification can be replaced or combined, so that the person skilled in the art can realize or use the present application. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts are referred to the part of the method embodiment.
[0182] Finally, it should be noted that, in this document, the term "only" is used simply to contrast with another entity or action, and does not necessarily require or imply that there is any such actual relationship or order between the entities or actions. Also, the terms "comprises", "comprising", or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises... a" does not, without more constraints, exclude the existence of additional identical elements in the process, method, article, or apparatus that comprises the element.
[0183] The above description of disclosed embodiments provides enabling teaching for making or using the application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein can be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
[0184] The above is only the preferred embodiment of the present application, it should be noted that, for those skilled in the art, without departing from the principles of the present application, can make a number of improvements and refinements, these improvements and refinements should also be considered as the protection scope of the present application.
Claims
1. A floating IP transfer method applied to a physical node in a cluster, wherein a virtual machine control module and a floating IP control module are deployed on the physical node, and the method comprises: the virtual machine control module detecting a virtual machine migrated to the physical node, determining an intranet IP address of the virtual machine and a floating IP address to be associated with the virtual machine; the virtual machine control module sending a hypertext transfer protocol request, wherein the hypertext transfer protocol request comprises the floating IP address and the intranet IP address of the virtual machine; the floating IP control module obtaining the hypertext transfer protocol request through a hypertext transfer server, configuring the floating IP address for a network card of the physical node, and constructing an IP conversion relationship between the floating IP address and the intranet IP address of the virtual machine; receiving a service request with the floating IP address as a destination address through the network card, and transmitting the service request to the virtual machine based on the IP conversion relationship.
2. The method of claim 1, the hypertext transfer protocol request further comprising: a node name of the physical node; after the constructing the association relationship between the floating IP address and the intranet IP address of the virtual machine, the method further comprises: the floating IP control module updating a historical node name recorded in target floating IP resource information to the node name of the physical node, wherein the target floating IP resource information is floating IP resource information associated with the floating IP address maintained in the cluster.
3. The method of claim 2, wherein a container orchestration system for managing the virtual machine control module is deployed in the cluster; before updating the historical node name recorded in the target floating IP resource information to the node name of the physical node, the method further comprises: the floating IP control module requesting virtual machine set information maintained by the virtual machine control module from the container orchestration system; the floating IP control module updating the historical node name recorded in the target floating IP resource information to the node name of the physical node, comprising: if a node name of a target physical node where the virtual machine is located recorded in the virtual machine set information is the same as the node name of the physical node, the floating IP control module updates the historical node name recorded in the target floating IP resource information to the node name of the physical node.
4. The method of claim 1, before the virtual machine control module detects the virtual machine migrated to the physical node, the method further comprises: the floating IP control module creating a hypertext transfer server on the physical node.
5. The method of claim 2 or 3, after the floating IP control module updates the historical node name recorded in the target floating IP resource information to the node name of the physical node, the method further comprises: The floating IP control module detects that the target floating IP resource information exists information change, and a current node name recorded in the target floating IP resource information is different from a node name of the physical node, and the floating IP control module deletes the floating IP address configured in a network card of the physical node and the IP conversion relationship stored in the physical node.
6. The method of claim 5, after the floating IP control module updates a historical node name recorded in target floating IP resource information to a node name of the physical node, further comprising: The floating IP control module sets a resource configuration state in the target floating IP resource information to completed change, so that the changed target floating IP resource information can be synchronized to each physical node in the cluster.
7. The method of claim 2, while the floating IP control module updates a historical node name recorded in target floating IP resource information to a node name of the physical node, further comprising: The floating IP control module updates an intranet IP address recorded in the target floating IP resource information based on the intranet IP address of the virtual machine.
8. The method of claim 7, further comprising: detecting an instruction to shut down the physical node or the virtual machine, and the floating IP control module deleting the floating IP address configured in a network card of the physical node and the IP conversion relationship stored in the physical node; after the virtual machine is started in the physical node, the floating IP control module obtains virtual machine state information on the physical node; if the virtual machine state information indicates that the virtual machine is not migrated, the floating IP control module configures the floating IP address for the network card of the physical node according to the floating IP address in the target floating IP resource information and the intranet IP address of the virtual machine, and constructs the IP conversion relationship between the floating IP address and the intranet IP address of the virtual machine.
9. A floating IP transfer device applied to a physical node in a cluster, the physical node being deployed with a virtual machine control module and a floating IP control module, and the device comprising: an information determination unit configured to determine an intranet IP address of a virtual machine migrated to the physical node and a floating IP address to be associated to the virtual machine through the virtual machine control module; a request sending unit configured to send a hypertext transfer protocol request through the virtual machine control module, the hypertext transfer protocol request comprising the floating IP address and the intranet IP address of the virtual machine; an information configuration unit configured to configure the floating IP address for a network card of the physical node and construct an IP conversion relationship between the floating IP address and the intranet IP address of the virtual machine through the floating IP control module by obtaining the hypertext transfer protocol request through a hypertext transfer server. The service processing unit is configured to receive a service request with the floating IP address as a destination address through the network card, and transmit the service request to the virtual machine based on the IP conversion relationship.
10. The apparatus of claim 9, the hypertext transfer protocol request issued by the request transmitting unit further comprising: The node name of the physical node; Further comprising: The resource information updating unit is configured to update a historical node name recorded in target floating IP resource information to the node name of the physical node through the floating IP control module after the information configuring unit constructs the association relationship between the floating IP address and the intranet IP address of the virtual machine, the target floating IP resource information being floating IP resource information associated with the floating IP address maintained in the cluster.
Citation Information
Patent Citations
Floating IP binding method and device based on k8s platform
CN107968851A
Switch testing method and device
CN110011877A
Floating address management method and system for virtual machine in container
CN113176930A