Master selection method and device after cloud platform failure and storage medium
By deploying an automatic master election recovery device in the Kubernetes platform, the problem of virtual IP address connection failure caused by network card failure was solved. This enabled automatic master election when the keepalive software service was abnormal, ensuring the high availability and business stability of the cloud platform.
Patent Information
- Application Number
- CN202410839755.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2026-01-16
- Estimated Expiration
- 2044-06-26
AI Technical Summary
In the Kubernetes platform, network interruptions caused by network card failures can lead to the failure of virtual IP address connections, affecting the stability of cloud platform and business access. The existing keepalive software service's re-election mechanism cannot recover in a timely manner under certain failure conditions.
Deploy an automatic recovery and master election device. By detecting the connection status of the virtual IP address, if it has not switched and has failed, actively perform a master election operation to switch the virtual IP address to another normal node. High availability is ensured by using the VRRP protocol and Iptables firewall rules.
When the keepalive software service fails to re-elect a master, the master election operation is automatically restored to ensure the high availability and business stability of the cloud platform and reduce the impact of network card failure on the platform and business.
Smart Images

Figure CN118713986B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of cloud platform, and particularly relate to a cloud platform master selection method and device after failure and a storage medium. BACKGROUND
[0002] Kubernetes, referred to as K8S, is an open source system for automatically deploying, scaling and managing containerized applications, which simplifies the deployment process of containerized applications and improves application management efficiency. Usually, K8S is composed of three or more odd nodes. Taking a three-node control cluster as an example, K8S has a virtual IP address corresponding to a single virtual machine, and each node stores a physical IP address of a server. The virtual IP address is switched back and forth on each node, and only on one node at the same time, and each node also stores a keepalive software service component to enable the virtual IP address to be loaded to the corresponding node. When a user uses K8S, cloud platform access is performed by accessing the virtual IP address, and the user's business is also accessed by the virtual IP address. When a single node fails, the keepalive software service can reselect the master through the VRRP (Virtual Router Redundancy Protocol) protocol, so that the virtual IP address can be loaded to another normal node, realizing cloud platform access and business high availability. Among them, VRRP is used to ensure the smoothness of the whole network when a single server node is down. In addition to being able to manage LVS (Linux Virtual Server) software, the keepalive software service can also be used as a high-availability solution software for other services (such as Nginx, Haproxy, MySQL, etc.).
[0003] However, the inventors realize that in the actual cloud platform hardware environment, network interruption problems caused by network card failure and other reasons often occur. Once the network card failure affects the ICMP (Internet Control Message Protocol) protocol, the physical IP of the failed node cannot be connected through the ping command, and if the virtual IP address of the user access business is loaded on the failed node at this time, the virtual IP address connection will be invalid, thereby affecting the cloud platform and business access. SUMMARY
[0004] The application provides a master selection method and device after cloud platform failure and a storage medium. The application deploys an automatic recovery master selection device for the cloud platform. When the re-election function of the keepalive software service is abnormal, the device actively performs a re-election operation, switches and loads a virtual IP address to another normal node, ensures the high availability of the cloud platform, and improves the access and service stability of the cloud platform.
[0005] The application provides a master selection method after cloud platform failure according to the first aspect. The method is applied to an automatic recovery master selection device deployed on a first node in a cloud platform. The method comprises the following steps.
[0006] Based on the set container application parameters, the keepalive software service is started. The container application parameters comprise a virtual IP address in the cloud platform. If the virtual IP address is connected to fail, the keepalive software service automatically switches the virtual IP address to a second node.
[0007] In response to the connection failure of the virtual IP address, it is detected whether the virtual IP address is switched.
[0008] If the virtual IP address is not switched and still fails, it is indicated that the keepalive software service is abnormal. A re-election operation is performed to actively switch the virtual IP address to the second node.
[0009] In some embodiments, the cloud platform is a K8S platform, the first node is a server or a virtual machine, and the virtual IP address is a single IP address that can be switched between nodes. The container application parameters further comprise physical IP addresses of nodes in the K8S platform and a virtual service IP address of the keepalive software service. Based on the set container application parameters, the keepalive software service is started. The method comprises the following steps.
[0010] In the K8S platform, address information configuration of the physical IP addresses of the nodes is completed, and address information configuration of the virtual IP address and the virtual service IP address is completed.
[0011] The keepalive software service component is installed, a first service for judging whether the keepalive software service is alive is started, and a second service for triggering the keepalive software service to perform a re-election operation is started.
[0012] When the second service is normal, if the virtual IP address is connected to fail, the second service performs a re-election operation. The second node is a node with effective connectivity. A minimum management unit corresponding to the second node stores a plurality of application containers corresponding to the virtual IP address.
[0013] When the second service runs abnormally, if the virtual IP address is connected to fail, the master re-election operation is not performed.
[0014] In some embodiments, the virtual IP address is switched to the second node, and the method comprises:
[0015] The keepalive software service is restarted, and the virtual route redundancy VRRP protocol function is activated to perform the master re-election operation.
[0016] In some embodiments, the keepalive software service is restarted, and the method comprises:
[0017] The node or the keepalive software service is restarted, or the keepalive software service component is reinstalled.
[0018] In some embodiments, before the keepalive software service is restarted, the method further comprises:
[0019] The survival state of the keepalive software service is determined based on the first service;
[0020] If the survival state of the keepalive software service is abnormal, the step of starting the keepalive software service in the above embodiments is performed.
[0021] In some embodiments, before detecting whether the virtual IP address is switched, the method further comprises:
[0022] It is determined whether the ICMP protocol, the IP protocol, the TCP protocol and the VRRP protocol of the K8S platform are abnormal;
[0023] If one of the ICMP protocol, the IP protocol, the TCP protocol and the VRRP protocol is abnormal, it indicates that the virtual IP address is connected to fail.
[0024] In some embodiments, the failure causes of the virtual IP address connected to fail include card failure, network fluctuation, server hardware failure and switch configuration error; if the virtual IP address is connected to fail, the method further comprises:
[0025] The ping command is executed to locate the failure, and the failure cause is determined according to the failure locating result.
[0026] In some embodiments, if the failure locating result is that the Internet Control Message Protocol ICMP is abnormal, and the virtual route redundancy VRRP protocol is not abnormal, the failure cause is card failure; after the virtual IP address is actively switched to the second node, the method further comprises:
[0027] An Iptables firewall rule is set to disable Internet Control Message Protocol (ICMP) to make the second service run abnormally, and to ensure that the VRRP protocol does not occur abnormally.
[0028] After the preset time length, it is detected whether the virtual IP address is still connected to be invalid; wherein, the preset time length is a time length required for completing the re-election operation;
[0029] If the virtual IP address is still connected to be invalid, the step of restarting the keepalive software service described in the above embodiment is executed.
[0030] The application provides a device for automatically recovering the master selection according to the second aspect, the device is deployed on a first node in a cloud platform, and the device comprises:
[0031] A software service configuration module is configured to start a keepalive software service based on a set container application parameter; the container application parameter comprises a virtual IP address in the cloud platform; if the virtual IP address is connected to be invalid, the keepalive software service automatically switches the virtual IP address to a second node.
[0032] A passive master selection detection module is configured to detect whether the virtual IP address is switched when the virtual IP address is connected to be invalid.
[0033] An active master selection execution module is configured to, when the virtual IP address is still invalid without switching, indicate that the keepalive software service runs abnormally, and execute a re-election operation to actively switch the virtual IP address to the second node.
[0034] The application provides a computer readable storage medium according to the third aspect, the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the master selection method after the cloud platform failure.
[0035] The application provides a computer device according to the fourth aspect, the computer device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the master selection method after the cloud platform failure when executing the computer program.
[0036] The method of the above embodiment can be applied to an automatic recovery master selection device deployed on a K8S platform, which is deployed on a specific server or virtual machine in a cloud platform. The technician first configures a container application parameter for the device, and the container application parameter includes a virtual IP address of a single virtual machine in the K8S platform, a physical IP address of each node, and a virtual service IP address of a keepalive software service. The virtual IP address is a single virtual IP address that can be switched between nodes. After the container application parameter configuration is completed, the device starts the keepalive software service. The K8S platform is generally configured with an alarm mechanism for real-time detection of whether the virtual IP address has failed to connect. If the connection fails, the keepalive software service automatically switches the virtual IP address to the second node. Then, the device detects whether the virtual IP address has been switched. If no switching occurs and the virtual IP address is still invalid, it indicates that the keepalive software service is running abnormally, and a re-election operation is performed to switch the virtual IP address to the second node. Through the steps of the above method, when the re-election function of the keepalive software service is abnormal, the re-election operation is actively performed to switch the virtual IP address to another normal node, ensuring the high availability of the K8S platform and improving the access and business stability of the K8S platform. BRIEF DESCRIPTION OF DRAWINGS
[0037] Figure 1 A master selection method flowchart after a cloud platform failure in one or more embodiments of the present application;
[0038] Figure 2 A keepalive software service starting method flowchart of a K8S platform in one or more embodiments of the present application;
[0039] Figure 3 A device cluster arrangement schematic diagram of a K8S platform in one or more embodiments of the present application;
[0040] Figure 4 A function review method flowchart of a re-election operation in one or more embodiments of the present application;
[0041] Figure 5 A master selection method flowchart after a K8S platform failure in one or more embodiments of the present application;
[0042] Figure 6 A structure schematic diagram of an automatic recovery master selection device in one or more embodiments of the present application;
[0043] Figure 7 A structure schematic diagram of a computer device in one or more embodiments of the present application. DETAILED DESCRIPTION
[0044] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and not used to limit the present application.
[0045] The present application provides a master selection method after cloud platform failure according to a first aspect. The method is applied to an automatic recovery master selection device deployed on a first node in a cloud platform, as shown in Figure 1 The method comprises the following steps.
[0046] S110: Start a keepalive software service based on a set container application parameter. The container application parameter comprises a virtual IP address in the cloud platform. If the virtual IP address is connected to fail, the keepalive software service automatically switches the virtual IP address to a second node.
[0047] Specifically, a plurality of minimum scheduling units for creating applications are also running in the cloud platform. The virtual IP address is loaded to a server node corresponding to any minimum scheduling unit. The minimum scheduling unit can contain a plurality of containers running in the cloud platform. Generally, an alarm mechanism is also configured in the cloud platform to monitor whether the virtual IP address is connected to fail.
[0048] For example, assuming that the VRRP protocol function of the cloud platform is normal, when the business access of the cloud platform is abnormal, it indicates that one of the ICMP protocol, IP protocol or TCP protocol of the cloud platform is abnormal, triggering the above-mentioned alarm mechanism to determine that the virtual IP address is connected to fail. Since the re-election operation of the keepalive software service is generally performed through the VRRP protocol, the keepalive software service can complete the switching of the virtual IP address in the case that the VRRP protocol function is normal.
[0049] S120: In response to the virtual IP address being connected to fail, it is detected whether the virtual IP address is switched.
[0050] Specifically, whether the virtual IP address is switched can be determined by detecting whether the business access of the cloud platform is normal. For example, if the business access of the cloud platform is still abnormal, it indicates that the ICMP protocol, IP protocol or TCP protocol of the cloud platform is still abnormal, and the virtual IP address is still not switched.
[0051] S130: If the switching does not occur and the virtual IP address is still invalid, a re-election operation is performed to actively switch the virtual IP address to the second node.
[0052] Specifically, if the switching does not occur and the virtual IP address is still invalid, it indicates that the keepalive software service is abnormal, in which case, a re-election operation is performed to actively switch the virtual IP address to the second node. The second node is another server node with normal connectivity, and for the minimum scheduling unit corresponding to the second node and the minimum scheduling unit corresponding to the virtual IP address, both contain the same plurality of containers to undertake the same cloud platform service access function.
[0053] For example, if a network card failure occurs in the cloud platform, causing the ICMP protocol function to be abnormal, but the network card failure does not affect the VRRP protocol function. At this time, if the VRRP protocol function of the keepalive software service is abnormal, the re-election operation cannot be automatically performed. Therefore, the automatic re-election master device needs to actively perform the re-election operation to switch the virtual IP address to the second node.
[0054] By the above method of deploying an automatic re-election master device for the cloud platform, when the re-election function of the keepalive software service is abnormal, the device can actively perform the re-election operation to switch the virtual IP address and load it to another normal node, ensuring the high availability of the cloud platform and improving the access and service stability of the cloud platform.
[0055] In some embodiments, the cloud platform is a K8S platform, the nodes are servers or virtual machines, and the virtual IP address is a single IP address that can be switched between nodes; the container application parameters further include the physical IP addresses of each node of the K8S platform and the virtual service IP address of the keepalive software service; based on the set container application parameters, the keepalive software service is started, as shown in Figure 2 The method comprises:
[0056] S210: In the K8S platform, the address information configuration of the physical IP addresses of each node is completed, and the address information configuration of the virtual IP address and the virtual service IP address is completed.
[0057] For example, as shown in Figure 3In the Kubernetes (K8S) platform device cluster shown, 11413:8082, 11413:8082, and 11413:8082 represent the physical IP addresses of three different servers, while 10.10.128.159:8082 is the virtual service IP address of the keepalive software service. All three servers are configured with the keepalive software service. Taking the middle Node02 server as an example, its keepalive software service corresponds to three different minimum management units (Pods), with virtual IP addresses of 10.122.10410.8082, 10.122104.11:8082, and 10.122.104.12:8082, respectively.
[0058] S220: Install the keepalive software service component, start the first service to determine whether the keepalive software service is alive, and start the second service to trigger the keepalive software service to perform a re-election operation.
[0059] Only after the second service is started can the keepalive software service re-elect a master via the VRRP protocol.
[0060] S230: When the second service is running normally, if the virtual IP address fails to connect, the second service will perform a re-election of the master. The second node is a node with valid connectivity, and the smallest management unit corresponding to the second node contains multiple application containers corresponding to the virtual IP address. When the second service is running abnormally, if the virtual IP address fails to connect, the re-election of the master will not be performed.
[0061] For example, such as Figure 3 In the Kubernetes platform with three Pods shown, if an iptables firewall rule is configured on a node containing one of the Pods to disable the ICMP protocol, the physical IP address and virtual IP address of that Pod node will be unable to communicate via ping. In this abnormal scenario, if the second service of the keepalive software service malfunctions, the re-election of a leader cannot be performed. In this case, the automatic leader election device needs to actively perform a re-election to switch the virtual IP address of the node with the disabled ICMP protocol to another node with valid connectivity.
[0062] In addition, the automatic master selection recovery device can actively perform the re-election operation by restarting the keepalive software service. In some embodiments, before the keepalive software service is restarted, the method further includes: judging the running state of the keepalive software service based on the first service; and if the keepalive software service has been closed, performing the step of starting the keepalive software service in the above embodiments. By deploying the automatic master selection recovery device for the K8S platform in the above manner, when the ICMP of the node is disabled by the protocol and the re-election function of the keepalive software service is abnormal, the device can actively load the virtual IP address of the abnormal node to another normal node, ensuring the high availability of the K8S platform.
[0063] In some embodiments, the above-mentioned switching of the virtual IP address to the second node can include the steps of: restarting the keepalive software service and activating the VRRP protocol function to perform the re-election operation. By actively activating the VRRP protocol, the virtual IP address is actively loaded to another normal node, ensuring the high availability of the K8S platform.
[0064] In some embodiments, the above-mentioned restarting of the keepalive software service can include the steps of: restarting the node or the keepalive software service, or reinstalling the keepalive software service component.
[0065] Specifically, if the reason for the connection failure of the virtual IP address is a network card failure, the virtual IP address can be loaded to another normal node by restarting the network card service when the node is restarted. In this way, the access and service stability of the K8S platform are improved.
[0066] In some embodiments, the failure reasons for the connection failure of the virtual IP address include network card failure, network fluctuation, server hardware failure, and switch configuration error; and if the connection failure of the virtual IP address occurs, the method can further include the steps of: performing a ping command for fault location, and determining the failure reason according to the fault location result.
[0067] Specifically, if any one or more of the above-mentioned failures occurs in the K8S platform, one or more of the ICMP protocol, the IP protocol, or the TCP protocol of the K8S platform can be abnormal. The ICMP protocol is a sub-protocol of the TCP / IP protocol cluster, which is used to transmit control messages between IP hosts and routers. The control message is a message about the network itself, such as whether the network is connected, whether the host is reachable, and whether the route is available. These control messages do not transmit user data, but play an important role in the transmission of user data.
[0068] Exemplarily, the network card fault causes the ICMP protocol, at this time, the automatic master selection device executes the ping command to determine that the fault reason is the network card fault, and determines the abnormal node corresponding to the target virtual IP according to the network card fault result. In this way, the fault reason is quickly determined, the re-election operation is ensured to be executed in time, and the access and service stability of the cloud platform are improved.
[0069] In some embodiments, before detecting whether the virtual IP address is switched, the method further includes the step of judging whether the ICMP protocol, the IP protocol, the TCP protocol and the VRRP protocol of the K8S platform are abnormal.
[0070] If one of the ICMP protocol, the IP protocol, the TCP protocol and the VRRP protocol is abnormal, it is determined that the virtual IP address is connected invalid.
[0071] In some embodiments, if the fault positioning result is that the Internet Control Message Protocol ICMP is abnormal and the Virtual Routing Redundancy VRRP protocol is not abnormal, the fault reason is the network card fault; after actively switching the virtual IP address to the second node, as shown in the following figure, the method further includes: Figure 4
[0072] S310: Set the Iptables firewall rule, disable the Internet Control Message Protocol ICMP to make the second service run abnormally, and ensure that the VRRP protocol is not abnormal.
[0073] S320: After a preset time length, detect whether the virtual IP address is still connected invalid; wherein the preset time length is the time length required for completing the re-election operation.
[0074] S330: If the virtual IP address is still connected invalid, execute the step of restarting the keepalive software service as described in the above embodiments.
[0075] Specifically, after the automatic master recovery device actively switches the virtual IP address to the second node, it is still necessary to confirm whether the re-election operation is successfully completed. Therefore, the automatic master recovery device can simulate a network card failure in the following way: set the iptables firewall rule to actively disable the ICMP protocol, causing abnormal access of the K8S platform business, while ensuring that the VRRP protocol does not occur. Abnormal to simulate network card failure. Then, after a preset time, it is confirmed whether the re-election operation is successfully completed. In this way, the successful completion of the re-election operation is ensured, further ensuring the high availability of the K8S platform. The above-mentioned iptables (full name: netilter iptables) is a packet filtering firewall under the Linux platform, and like most Linux software, it can complete packet filtering, packet redirection, and network address translation (NAT) tasks.
[0076] The method of the above embodiment can be applied to an automatic master recovery device deployed in a K8S device cluster, as shown in Figure 3 、 5 The device is deployed on a specific server Node01 / Node02 / Node03 in the cloud platform. The technician first configures the physical IP addresses 11413:8082, 11413:6082, and 11413:8082 of each node in the K8S device cluster, as well as the virtual service IP address 10.10.128.159:8082 of the keepalive software service. After completing the parameter configuration, the device starts the keepalive software service. The K8S device cluster is generally configured with an alarm mechanism to periodically detect whether the virtual IP address has failed to connect. If the virtual IP address fails to connect, the keepalive software service automatically switches the virtual IP address to another normal node. Then, the device detects whether the virtual IP address has been switched. If no switching occurs and the virtual IP address is still invalid, it indicates that the keepalive software service is running abnormally, the master election is unsuccessful, and the re-election operation is performed to switch the virtual IP address to a normal node. If switching occurs, it indicates that the keepalive software service is running normally, the master election is successful, and the connectivity of the virtual IP address is detected again. Through the above method, when the re-election function of the keepalive software service is abnormal, the re-election operation is actively performed to switch and load the abnormal virtual IP address to another normal node, ensuring the high availability of the K8S platform and improving the access and business stability of the K8S platform.
[0077] The K8S container cloud platform development or operation personnel deploys the device when using the platform, and on the basis of the keepalive software service self-host mechanism, increases the network interruption caused by network card failure and other reasons, and in the case that the keepalive software service does not normally trigger the master selection action based on the VRRP protocol, discovers the situation that the platform virtual IP and key service are unavailable in time, and triggers the keepalive software service to re-select the master based on the automatic recovery master mechanism of the device.
[0078] In the above embodiment, the following 5 process steps are mainly included:
[0079] (1) Device deployment: deploy the device on a physical server or virtual machine, provide cloud platform virtual IP network connectivity test, and can actively trigger the keepalive software service to re-select the master when the virtual IP cannot be accessed due to network card failure and other abnormal reasons, to actively switch the virtual IP address to another normal node.
[0080] (2) Virtual IP connectivity check:
[0081] The device will periodically check the connectivity of the virtual IP address of the cloud platform, and when it is found that the virtual machine IP cannot be connected, it will trigger the next master selection action in time.
[0082] (3) Check whether the keepalive software service triggers the master selection when the network card fails: after the virtual IP connectivity problem is checked in the last step, continue to check whether the keepalive software service triggers the master selection mechanism, and whether the virtual IP is switched to other normal nodes in time.
[0083] (4) Active trigger of keepalive software service master selection: if the virtual IP connectivity has a problem and the keepalive software service does not perform master selection to switch the virtual IP, the device will actively trigger the re-master mechanism of the keepalive software service.
[0084] (5) Verification: after the device triggers the master, continue to perform periodic virtual IP connectivity check.
[0085] In other embodiments, the keepalive software service re-election mechanism is known to rely on the VRRP protocol, and a switch configuration error can only cause a TCP protocol error without affecting the VRRP protocol, but still cause a node network failure, and the keepalive software service does not perform virtual IP switching, which seriously affects the K8S container platform and business access. Through actual environment verification, in a 3-node container platform cluster, the TCP protocol is disabled on the node where the virtual IP address is located by setting the Iptables rule, at which time the test finds that the current node IP and the virtual IP address cannot be pinged, but the keepalive software service still does not trigger the virtual IP switching, and the platform and business are in an inaccessible state. It is proved that the re-election mechanism of the keepalive software service itself is abnormal, and it fails to guarantee the high availability of the platform and business in this abnormal scenario.
[0086] To cope with this abnormal scenario, the technical personnel start the automatic recovery election device. When a node of the K8S container platform is interrupted due to a switch configuration error, if the failure only affects the TCP protocol, that is, the IP address and virtual IP address of the node cannot be pinged, and the platform and business cannot be accessed, the device can intervene in the keepalive software service to perform the election logic, ensuring that the keepalive software service not only judges whether the VRRP protocol needs to be re-elected, but also judges whether the current node IP and the platform virtual IP can be pinged, and whether the key service port is normally providing services. If only the keepalive software service itself triggers the election action, it will cause the platform and business to be inaccessible, but the virtual IP of the K8S container platform is still in the fault node. By judging the connectivity of the K8S container platform network and whether the key service port is available, the high availability of the K8S container cloud platform and the platform business can be improved, the robustness of the cloud platform can be improved, the impact of network card failure on the platform and business can be reduced, and the investment of platform operation and maintenance personnel can be reduced.
[0087] In addition, during the operation of the device, the node physical IP address of the K8S device cluster can also be configured to automatically perform periodic network connectivity checks. When network fluctuations cause the virtual IP address to be inaccessible or the platform key service port to be invalid, if it is also detected that the keepalive software service itself does not perform re-election, the device will automatically perform re-election by shutting down the network card service or restarting the keepalive software service of the fault node, so that the virtual IP address of the K8S container cloud platform can be timely loaded to the normal node, guaranteeing the high availability requirement of platform access, ensuring the continuity of business, improving the robustness of the keepalive software service component, and making up for the shortcomings of the election mechanism itself.
[0088] The application provides an automatic master recovery device according to the second aspect, which is deployed on a first node in a cloud platform, as shown in the figure, and comprises: Figure 6
[0089] a software service configuration module 110 configured to start a keepalive software service based on a set container application parameter, wherein the container application parameter comprises a virtual IP address in the cloud platform, and the keepalive software service automatically switches the virtual IP address to a second node if the virtual IP address is connected to fail;
[0090] a passive master selection detection module 120 configured to detect whether the virtual IP address is switched when the virtual IP address is connected to fail;
[0091] an active master selection execution module 130 configured to execute a re-master operation to actively switch the virtual IP address to the second node when the virtual IP address is still failed without switching.
[0092] In some embodiments, the cloud platform is a K8S platform, the first node is a server or a virtual machine, and the virtual IP address is a single IP address that can be switched between the nodes; the container application parameter further comprises a physical IP address of each node of the K8S platform and a virtual service IP address of the keepalive software service;
[0093] The software service configuration module 110 is further configured to complete address information configuration of the physical IP address of each node in the K8S platform, and complete address information configuration of the virtual IP address and the virtual service IP address; install a keepalive software service component, start a first service for judging whether the keepalive software service is alive, and start a second service for triggering the keepalive software service to execute the re-master operation; when the second service is running normally, if the virtual IP address is connected to fail, the second service executes the re-master operation, the second node is a node with effective connectivity, and the second node corresponds to a minimum management unit in which multiple application containers corresponding to the virtual IP address are stored; when the second service is running abnormally, if the virtual IP address is connected to fail, the re-master operation is not executed.
[0094] In some embodiments, the software service configuration module 110 is further configured to restart the keepalive software service and activate a VRRP protocol function to execute the re-master operation.
[0095] In some embodiments, the software service configuration module 110 is further configured to restart the node or the keepalive software service, or reinstall the keepalive software service component.
[0096] In some embodiments, before restarting the keepalive software service, the software service configuration module 110 is further configured to determine the survival state of the keepalive software service based on the first service, and if the survival state of the keepalive software service is abnormal, execute the step of starting the keepalive software service.
[0097] In some embodiments, before detecting whether the virtual IP address is switched, the passive master selection detection module 120 is further configured to determine whether the ICMP protocol, the IP protocol, the TCP protocol and the VRRP protocol of the K8S platform are abnormal, and if one of the ICMP protocol, the IP protocol, the TCP protocol and the VRRP protocol is abnormal, determine that the virtual IP address is connected invalid.
[0098] In some embodiments, the fault reason of the connection invalidity of the virtual IP address includes a network card fault, network fluctuation, server hardware fault and switch configuration error, and if the virtual IP address is connected invalid, the passive master selection detection module 120 is further configured to execute a ping command for fault locating, and determine the fault reason according to the fault locating result.
[0099] In some embodiments, if the fault locating result is that the ICMP is abnormal and the VRRP protocol is not abnormal, the fault reason is a network card fault, and after actively switching the virtual IP address to the second node, the passive master selection detection module 120 is further configured to set an Iptables firewall rule to disable the ICMP protocol to make the service access of the K8S platform abnormal, and at this time, the active master selection execution module 130 executes a re-election operation. After a preset time length, the passive master selection detection module 120 detects whether the virtual IP address is still connected invalid. The preset time length is the time length required for the active master selection execution module 130 to complete the re-election operation.
[0100] If the virtual IP address is still connected invalid, the active master selection execution module 130 is further configured to execute the above-mentioned step of restarting the keepalive software service.
[0101] For specific limitations applicable to the automatic master recovery device, refer to the limitations applicable to the automatic master recovery method in the foregoing, which will not be repeated here. Each module in the above-mentioned automatic master recovery device can be realized by software, hardware and a combination thereof, in whole or in part. Each module can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory in the computer device in software form, so as to be called and executed by the processor to perform the operations corresponding to each module.
[0102] According to a third aspect, the present application provides a computer readable storage medium, having stored thereon a computer program, which, when executed by a processor, implements the steps of any of the above-mentioned cloud platform post-failure master election methods.
[0103] According to a fourth aspect, the present application provides a computer device, as shown in Figure 7 The computer device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any of the above-mentioned cloud platform post-failure master election methods when executing the computer program.
[0104] Any reference to memory, storage, database, or other medium used in the embodiments provided by the present application can include non-volatile and / or volatile memory. The non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. The volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), RamBus (RamBus), direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0105] Any combination of the technical features of the above embodiments can be made, and in order to make the description concise, not all possible combinations of the technical features in the above embodiments are described, however, as long as the combination of the technical features does not exist, it should be considered as the scope of the present application.
[0106] The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the patent. It should be noted that for those skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the scope of the present application. Therefore, the scope of protection of the patent of the present application should be subject to the appended claims.
[0107] Finally, it is to be understood that the phraseology or terminology such as "first" and "second" etc. is merely used to differentiate one from another entity or action, but does not require or imply that these are in any way prior one or the other. Moreover, the terms "comprising", "including", or any other closure, are intended to cover the non-exclusive inclusion of the elements listed, such that process, method, article, or apparatus that comprises elements not expressly listed does not exclude other elements from being present. Without more limitation, an element preceded by "comprising" does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.
Claims
1. A method for leader election after cloud platform failure, characterized in that, The method is applied to an automatic recovery master election device deployed on a first node in a cloud platform, and comprises the following steps: starting a keepalive software service based on a set container application parameter, wherein the container application parameter comprises a virtual IP address in the cloud platform, and if the virtual IP address is connected to fail, the keepalive software service automatically switches the virtual IP address to a second node; in response to the virtual IP address being connected to fail, detecting whether the virtual IP address is switched; if the virtual IP address is not switched and still fails, performing a re-election operation to actively switch the virtual IP address to the second node.
2. The method of claim 1, wherein, The cloud platform is a K8S platform, the first node is a server or a virtual machine, and the virtual IP address is a single IP address that can be switched between the nodes; the container application parameter further comprises physical IP addresses of the nodes of the K8S platform and a virtual service IP address of the keepalive software service; the starting of the keepalive software service based on the set container application parameter comprises the following steps: in the K8S platform, completing address information configuration of the physical IP addresses of the nodes, and completing address information configuration of the virtual IP address and the virtual service IP address; installing a keepalive software service component, starting a first service for judging whether the keepalive software service is alive, and starting a second service for triggering the keepalive software service to perform a re-election operation; if the virtual IP address is connected to fail when the second service is running normally, the second service performs the re-election operation, the second node is a node with effective connectivity, and a minimum management unit corresponding to the second node stores a plurality of application containers corresponding to the virtual IP address; if the virtual IP address is connected to fail when the second service is running abnormally, the re-election operation is not performed.
3. The method of claim 2, wherein, The switching of the virtual IP address to the second node comprises the following steps: restarting the keepalive software service and activating a virtual routing redundancy protocol function to perform the re-election operation.
4. The method of claim 3, wherein, The restarting of the keepalive software service comprises restarting the node or the keepalive software service, or reinstalling the keepalive software service component.
5. The method of claim 4, wherein, Before the restarting of the keepalive software service, the method further comprises the following steps: judging the alive state of the keepalive software service based on the first service; if the alive state of the keepalive software service is abnormal, performing the step of starting the keepalive software service according to claim 2.
6. The method of claim 3, wherein, Before the detection of whether the virtual IP address is switched, the method further comprises the following steps: determine whether the ICMP protocol, the IP protocol, the TCP protocol, and the VRRP protocol of the K8S platform are abnormal; if one of the ICMP protocol, the IP protocol, the TCP protocol, and the VRRP protocol is abnormal, it is determined that the virtual IP address is connected invalidly.
7. The method of claim 6, wherein, The failure causes of the virtual IP address connected invalidly include a network card failure, network fluctuation, server hardware failure, and switch configuration error. If the virtual IP address is connected invalidly, the method further comprises: performing a ping command to locate the failure, and determining the failure cause according to the failure locating result.
8. The method of claim 7, wherein, If the failure locating result is that the Internet Control Message Protocol is abnormal, and the Virtual Route Redundancy Protocol is not abnormal, the failure cause is a network card failure. After the virtual IP address is actively switched to the second node, the method further comprises: setting an Iptables firewall rule, disabling the Internet Control Message Protocol to make the service access of the K8S platform abnormal, and ensuring that the Virtual Route Redundancy Protocol is not abnormal; after a preset time length, detecting whether the virtual IP address is still connected invalidly; wherein the preset time length is a time length required to complete the re-election operation. If the virtual IP address is still connected invalidly, the step of restarting the keepalive software service in claim 3 is performed.
9. An automatic master election recovery apparatus, characterized by comprising: The device is deployed on a first node in a cloud platform, and the device comprises: a software service configuration module configured to start a keepalive software service based on a set container application parameter; the container application parameter comprises a virtual IP address in the cloud platform, and if the virtual IP address is connected invalidly, the keepalive software service automatically switches the virtual IP address to a second node; a passive election detection module configured to detect whether the virtual IP address is switched when the virtual IP address is connected invalidly; an active election execution module configured to perform a re-election operation to actively switch the virtual IP address to the second node when the virtual IP address is still invalid without switching.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by a processor to realize the steps of the method in any one of claims 1 to 8. The computer program is executed by a processor to realize the steps of the method in any one of claims 1 to 8.
Citation Information
Patent Citations
Method for preventing keepalive virtual IP from being lost
CN113746951A
Processing method and device for high-availability architecture
CN117493081A