Cluster load balancing method, device, equipment and storage medium

By deploying a load balancing controller and LVS cluster in the Kubernetes cluster and using the postStart hook script to automatically mount the IP address, the problem of the lack of a load balancing mechanism on the Ingress node is solved, automatic load balancing of the cluster is achieved, and availability and service quality are improved.

CN116614509BActive Publication Date: 2025-09-12E SURFING VISION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310609765.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-26
Publication Date
2025-09-12
Estimated Expiration
2043-05-26

AI Technical Summary

Technical Problem

The Ingress nodes of the Kubernetes cluster lack a load balancing mechanism, which requires manual configuration when adding or expanding nodes. This makes the load balancing process lengthy and error-prone, affecting the cluster's availability and service quality.

Method used

Deploy a load balancing controller in the Kubernetes cluster, generate a Controller container, connect to the LVS cluster, mark the target node with a label, use the postStart hook script to mount the IP address to the Lo network card, and update the LVS cluster configuration file to achieve automatic load balancing.

Benefits of technology

Automatic load balancing is implemented for Kubernetes clusters when new Ingress nodes are created, improving cluster availability and service quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116614509B_ABST
    Figure CN116614509B_ABST
Patent Text Reader

Abstract

The present application discloses a cluster load balancing method, apparatus, device and storage medium, which generates a Controller container by deploying a load balancing controller in a Kubernetes cluster; connecting an LVS cluster with a Kubernetes cluster and setting a configuration file of the LVS cluster in the load balancing controller; determining a target node and marking the target node to obtain a marked node, creating an Ingress POD in the marked node, and monitoring the Ingress POD through a Controller container; obtaining the IP address of the marked node and a postStart hook script, and using the postStart hook script to mount the IP address of the marked node to the Lo network card of the marked node; when the Controller container monitors that the Ingress POD generates a lifecycle event, the IP address of the marked node is obtained from the Lo network card of the marked node; and the configuration file of the LVS cluster is updated using the IP address, so as to achieve load balancing of the Kubernetes cluster when a new Ingress node is created. This solution can implement an automatic load balancing mechanism in a new Ingress node, thereby improving the availability and service quality of the cluster.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of load balancing, and in particular to a cluster load balancing method, apparatus, device, and storage medium. Background Art

[0002] Cloud computing systems typically cluster multiple hosts to provide services to users, using load balancers as access points. In recent years, cloud-native technologies based on Kubernetes clusters have experienced rapid development. Kubernetes clusters offer a variety of traffic entry solutions. For example, the Ingress node within a cluster not only provides Layer 4 and Layer 7 forwarding mechanisms but also transcends cloud provider restrictions, allowing for flexible deployment on private and edge clouds.

[0003] However, the Ingress node itself lacks a load balancing mechanism. If you want to create or expand an Ingress node, you need to manually configure it. This will make the load balancing process of the Kubernetes cluster longer and more error-prone, which is not conducive to the availability and service quality of the cluster. Summary of the Invention

[0004] In view of this, the present application provides a cluster load balancing implementation method, apparatus, device and storage medium to solve the problem that the Ingress node itself lacks a load balancing mechanism. If you want to create or expand an Ingress node, you need to manually configure it. This will cause the load balancing process of the Kubernetes cluster to be longer and prone to errors, which is not conducive to the availability and service quality of the cluster.

[0005] To achieve the above objectives, the following solutions are proposed:

[0006] In a first aspect, a cluster load balancing method includes:

[0007] Deploy a load balancing controller in the Kubernetes cluster and generate a Controller container corresponding to the load balancing controller.

[0008] Connect the preset LVS cluster to the Kubernetes cluster and set the configuration file of the LVS cluster in the load balancing controller;

[0009] Determine a target node from among the nodes of the Kubernetes cluster;

[0010] Mark the target node with a preset label to obtain a marked node, create an Ingress POD in the marked node, and monitor the Ingress POD through the Controller container;

[0011] Obtain the IP address of the marked node and the postStart hook script in the Ingress POD, and use the postStart hook script to mount the IP address of the marked node to the Lo network card of the marked node;

[0012] When the Controller container monitors the lifecycle event of the Ingress POD, it obtains the IP address of the marked node from the Lo network card of the marked node;

[0013] The configuration file of the LVS cluster is updated using the IP address to achieve load balancing of the Kubernetes cluster when a new Ingress node is created.

[0014] Preferably, obtaining the IP address of the marking node includes:

[0015] Get the namespace of the Kubernetes cluster;

[0016] Deploy a pre-customized ConfigMap in the namespace;

[0017] Determine the IP address of the marked node from the ConfigMap.

[0018] Preferably, the step of using the postStart hook script to mount the IP address of the marking node to the Lo network card of the marking node includes:

[0019] Configure the Nginx container privileged mode for the Ingress POD and run the Ingress POD as the default root user;

[0020] Start the Ingress POD, and the pre-set lifecycle management process of the Kubernetes cluster automatically triggers the postStart hook script;

[0021] Obtaining a modification script corresponding to the IP address of the marked node;

[0022] The IP address of the marking node is read by the Ingress POD, and the modification script is executed, so as to mount the IP address of the marking node to the Lo network card of the marking node by using the postStart hook script.

[0023] Preferably, when the Controller container monitors that the Ingress POD generates a lifecycle event, obtaining the IP address of the marking node from the Lo network card of the marking node includes:

[0024] When the Controller container monitors the Ingress POD and generates a lifecycle event, it obtains the application programming interface of the Kubernetes cluster and uses the application programming interface to query the status information of the Ingress POD;

[0025] The IP address of the marking node is obtained from the Lo network card of the marking node based on the status information.

[0026] Preferably, the updating of the configuration file of the LVS cluster using the IP address in order to achieve load balancing of the Kubernetes cluster when a new Ingress node is created includes:

[0027] Install Ansible in the image of the load balancing controller, start Ansible, and use Ansible to add the IP address to the configuration file of the LVS cluster;

[0028] Restart the LVS cluster and load the configuration file of the LVS cluster with the added IP address, so that the LVS cluster can determine whether the marked node is normal;

[0029] If so, the marked node is added to the Kubernetes cluster in order to achieve load balancing of the Kubernetes cluster when a new Ingress node is created.

[0030] Preferably, it also includes:

[0031] When the marked node goes down, obtain the pre-set preStop hook script;

[0032] Start the Ingress POD, and the pre-set lifecycle management process of the Kubernetes cluster automatically triggers the preStop hook script;

[0033] The IP address of the marked node is uninstalled using the preStop hook script.

[0034] In a second aspect, a cluster load balancing device includes:

[0035] A deployment generation module is used to deploy a load balancing controller in the Kubernetes cluster and generate a Controller container corresponding to the load balancing controller;

[0036] A connection module, used to connect the preset LVS cluster with the Kubernetes cluster and set the configuration file of the LVS cluster in the load balancing controller;

[0037] A target node determination module, configured to determine a target node from among the nodes in the Kubernetes cluster;

[0038] A marking module is used to mark the target node with a preset label to obtain a marked node, create an Ingress POD in the marked node, and monitor the Ingress POD through the Controller container;

[0039] An acquisition and mounting module, configured to acquire the IP address of the marking node and the postStart hook script in the Ingress POD, and to mount the IP address of the marking node to the Lo network card of the marking node using the postStart hook script;

[0040] An IP address acquisition module is configured to acquire the IP address of the marked node from the Lo network card of the marked node when the Controller container monitors the generation of a lifecycle event by the Ingress POD;

[0041] The update module is used to update the configuration file of the LVS cluster using the IP address, so as to achieve load balancing of the Kubernetes cluster when a new Ingress node is created.

[0042] Preferably, the mounting module includes:

[0043] A configuration and operation module is used to configure the Nginx container privilege mode for the Ingress POD and run the Ingress POD as a preset root user;

[0044] A trigger module is used to start the Ingress POD and automatically trigger the postStart hook script by the pre-set lifecycle management process of the Kubernetes cluster;

[0045] A modification script acquisition module, configured to acquire a modification script corresponding to the IP address of the marked node;

[0046] The read execution module is used to use the Ingress POD to read the IP address of the marking node and execute the modification script, so as to use the postStart hook script to mount the IP address of the marking node to the Lo network card of the marking node.

[0047] In a third aspect, a cluster load balancing device includes a memory and a processor;

[0048] The memory is used to store programs;

[0049] The processor is configured to execute the program to implement the various steps of the cluster load balancing method as described in the first aspect.

[0050] In a fourth aspect, a storage medium stores a computer program thereon, wherein when the computer program is executed by a processor, the computer program implements the various steps of the cluster load balancing method as described in the first aspect.

[0051] It can be seen from the above technical solution that the present application deploys a load balancing controller in the Kubernetes cluster and generates a Controller container corresponding to the load balancing controller at the same time; connects the preset LVS cluster with the Kubernetes cluster, and sets the configuration file of the LVS cluster in the load balancing controller; determines the target node from each node of the Kubernetes cluster; marks the target node with a preset label to obtain a marked node, and creates an Ingress POD in the marked node, and monitors the Ingress POD through the Controller container; obtains the IP address of the marked node and the postStart hook script in the Ingress POD, and uses the postStart hook script to mount the IP address of the marked node to the Lo network card of the marked node; when the Controller container monitors the Ingress POD to generate a life cycle event, it obtains the IP address of the marked node from the Lo network card of the marked node; uses the IP address to update the configuration file of the LVS cluster, so as to achieve load balancing of the Kubernetes cluster when a new Ingress node is created. This solution extends the load balancing capabilities of the Kubernetes cluster by deploying a load balancing controller, deploying an LVS cluster connected to the Kubernetes cluster outside the cluster, and managing the lifecycle of the LVS cluster. It can implement an automatic load balancing mechanism on the newly created Ingress node, improving the cluster's availability and service quality. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0053] Figure 1 An optional flow chart of a cluster load balancing method provided in an embodiment of the present application;

[0054] Figure 2 An optional flow chart of another cluster load balancing method provided in an embodiment of the present application;

[0055] Figure 3 A system structure block diagram provided in an embodiment of the present application;

[0056] Figure 4 A schematic diagram of the structure of a cluster load balancing device provided in an embodiment of the present application;

[0057] Figure 5 A schematic diagram of the structure of a cluster load balancing device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0058] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0059] Cloud computing systems typically cluster multiple hosts to provide services to users, using load balancers as access points. In recent years, Gartner has predicted that by 2025, cloud-native platforms will underpin over 95% of new digital initiatives, with multi-cloud and distributed cloud emerging as a key trend. Cloud-native technologies based on Kubernetes clusters are rapidly developing. Kubernetes clusters offer a variety of traffic entry solutions, such as NodePort, LoadBalancer, and Ingress. LoadBalancer is provided by public cloud service providers and can only be used in public cloud environments. NodePort only forwards Layer 4 traffic and lacks Layer 7 grayscale releases, routing control, and log collection. Ingress nodes, on the other hand, offer Layer 4 and Layer 7 forwarding mechanisms and are independent of cloud service provider restrictions, allowing for flexible deployment on private and edge clouds.

[0060] However, the Ingress node itself lacks a load balancing mechanism. If you want to create or expand an Ingress node, you need to manually configure it. This will make the load balancing process of the Kubernetes cluster longer and more error-prone, which is not conducive to the availability and service quality of the cluster.

[0061] The embodiment of the present invention provides a cluster load balancing method, which can be applied to various live broadcast systems or chat systems, and can also be applied to various computer terminals or smart terminals. The execution subject can be a processor or server of the computer terminal or smart terminal. The method flow chart of the method is as follows: Figure 1 As shown, specifically including:

[0062] S1: Deploy a load balancing controller in the Kubernetes cluster and generate a Controller container corresponding to the load balancing controller.

[0063] In this application, the load balancing controller can be an Operator. When the load balancing controller Operator is deployed in the Kubernetes cluster, the Controller container corresponding to the load balancing controller is also created.

[0064] S2: Connect the preset LVS cluster to the Kubernetes cluster, and set the configuration file of the LVS cluster in the load balancing controller.

[0065] In the embodiments provided herein, an LVS cluster is pre-established. LVS (Linux Virtual Server) is a Linux virtual server, a virtual server cluster system. This cluster is connected to a Kubernetes cluster, allowing the LVS cluster to be used to add or expand Ingress nodes within the Kubernetes cluster. After the connection is established, the LVS cluster configuration file is set in the load balancing controller. The Operator configuration may include the IP addresses of the LVS cluster nodes and SSH user password information.

[0066] S3: Determine a target node from among the nodes of the Kubernetes cluster.

[0067] Specifically, there are multiple nodes in the Kubernetes cluster, including Ingress nodes and non-Ingress nodes. Therefore, a node can be randomly selected from each non-Ingress node as the target node.

[0068] S4: Mark the target node with a preset label to obtain a marked node, create an Ingress POD in the marked node, and monitor the Ingress POD through the Controller container.

[0069] You can use the Ingress label to mark the target node to obtain a marked node. Then, create an Ingress POD in the marked node. After the Ingress POD and the Controller container are created, the Controller container will continue to monitor the lifecycle events of the Ingress POD.

[0070] S5: Obtain the IP address of the marking node and the postStart hook script in the Ingress POD, and use the postStart hook script to mount the IP address of the marking node to the Lo network card of the marking node.

[0071] In this step, the IP address of the marked node and the postStart hook script in the Ingress POD are obtained, so that the IP address of the marked node can be mounted to the Lo network card of the marked node using the postStart hook script to achieve automatic mounting of the IP address.

[0072] S6: When the Controller container monitors that the Ingress POD generates a lifecycle event, the IP address of the marked node is obtained from the Lo network card of the marked node.

[0073] Because the IP address of the marked node has been mounted on the Lo network card, and in step S4 it is mentioned that the Controller container monitors the Ingress POD, when the Controller container monitors the life cycle time of the Ingress POD, the IP address of the marked node is obtained from the Lo network card of the marked node to perform the following operations.

[0074] S7: Use the IP address to update the configuration file of the LVS cluster in order to achieve load balancing of the Kubernetes cluster when a new Ingress node is created.

[0075] It can be seen from the above technical solution that the present application deploys a load balancing controller in the Kubernetes cluster and generates a Controller container corresponding to the load balancing controller at the same time; connects the preset LVS cluster with the Kubernetes cluster, and sets the configuration file of the LVS cluster in the load balancing controller; determines the target node from each node of the Kubernetes cluster; marks the target node with a preset label to obtain a marked node, and creates an Ingress POD in the marked node, and monitors the Ingress POD through the Controller container; obtains the IP address of the marked node and the postStart hook script in the Ingress POD, and uses the postStart hook script to mount the IP address of the marked node to the Lo network card of the marked node; when the Controller container monitors the Ingress POD to generate a life cycle event, it obtains the IP address of the marked node from the Lo network card of the marked node; uses the IP address to update the configuration file of the LVS cluster, so as to achieve load balancing of the Kubernetes cluster when a new Ingress node is created. This solution extends the load balancing capabilities of the Kubernetes cluster by deploying a load balancing controller, deploying an LVS cluster connected to the Kubernetes cluster outside the cluster, and managing the lifecycle of the LVS cluster. It can implement an automatic load balancing mechanism on the newly created Ingress node, improving the cluster's availability and service quality.

[0076] In the method provided in the embodiment of the present invention, the process of obtaining the IP address of the marked node is specifically described as follows:

[0077] Obtain a namespace of the Kubernetes cluster; deploy a pre-customized ConfigMap in the namespace; and determine the IP address of the marked node from the ConfigMap.

[0078] The modification script corresponding to the marked node's IP address can also be obtained from the ConfigMap. In the above process, to modify the DaemonSet deployment script of the Ingress POD, you can first mount the modification script in the ConfigMap into the container through volume mounting, and then configure the marked node's IP address in the ConfigMap as an environment variable of the Ingress POD by reference.

[0079] The following is a detailed description of the process of using the postStart hook script in this application to mount the IP address of the marking node to the Lo network card of the marking node.

[0080] Configure the Nginx container privileged mode for the Ingress POD and run the Ingress POD as the default root user;

[0081] Start the Ingress POD, and the pre-set lifecycle management process of the Kubernetes cluster automatically triggers the postStart hook script;

[0082] Obtaining a modification script corresponding to the IP address of the marked node;

[0083] The IP address of the marking node is read by the Ingress POD, and the modification script is executed, so as to mount the IP address of the marking node to the Lo network card of the marking node by using the postStart hook script.

[0084] Specifically, after starting the Ingress POD configured with the Nginx container privileged mode, and running the Ingress POD as the preset root user (root user), the Ingress POD at this time has the permission to modify the Lo network card and ARP configuration of the container host. The postStart hook script is then automatically triggered by the pre-set lifecycle management process of the Kubernetes cluster. The Ingress POD first reads the IP address of the marked node from the environment variable, and then executes the modification script. The modification script mounts the IP address through ifconfig and route, and modifies the ARP configuration through sysctl. At this point, the Kubernetes cluster has the ability to automatically manage the load balancing of the LVS cluster.

[0085] The above describes the process of using the postStart hook script in this application to mount the IP address of the marked node to the Lo network card of the marked node. The following describes the process of obtaining the IP address of the marked node from the Lo network card of the marked node when the Controller container monitors the Ingress POD to generate a lifecycle event, and using the IP address to update the configuration file of the LVS cluster, in order to achieve load balancing of the Kubernetes cluster when a new Ingress node is created.

[0086] When the Controller container monitors the Ingress POD and generates a lifecycle event, it obtains the application programming interface of the Kubernetes cluster and uses the application programming interface to query the status information of the Ingress POD;

[0087] Obtaining the IP address of the marking node from the Lo network card of the marking node based on the status information;

[0088] Install Ansible in the image of the load balancing controller, start Ansible, and use Ansible to add the IP address to the configuration file of the LVS cluster;

[0089] Restart the LVS cluster and load the configuration file of the LVS cluster with the added IP address, so that the LVS cluster can determine whether the marked node is normal;

[0090] If so, the marked node is added to the Kubernetes cluster in order to achieve load balancing of the Kubernetes cluster when a new Ingress node is created.

[0091] Specifically, when the load balancing controller monitors the life cycle event generated by the Ingress POD, it determines that this is a new Ingress POD after comparing it with the local cache. Therefore, it queries the status information of the Ingress POD through the application programming interface of the Kubernetes cluster, obtains the IP address of the marked node through the status information, and then starts Ansible, remotely modifies the configuration file of the LVS cluster, adds the IP address of the marked node to the RealServer of the configuration file of the LVS cluster, and configures the health interface of the node as the probe interface of the RealServer. Remotely restart the LVS cluster through Ansible, and load the configuration file of the LVS cluster with the added IP address to update the new Ingress node to the RealServer of the LVS cluster. At this point, the load balancing of the Kubernetes cluster is completed, and the automatic management of the Kubernetes cluster is realized. The above specific process can be as follows Figure 2 shown.

[0092] Optionally, the method may further include:

[0093] When the marked node goes down, obtain the pre-set preStop hook script;

[0094] Start the Ingress POD, and the pre-set lifecycle management process of the Kubernetes cluster automatically triggers the preStop hook script;

[0095] The IP address of the marked node is uninstalled using the preStop hook script.

[0096] In the above solution, when a node goes down or encounters an extreme state, the cluster can automatically remove the down node to ensure the stability of load balancing and enable the cluster to have disaster recovery capabilities.

[0097] The cluster load balancing method in the above solution can correspond to a system that includes a load balancing controller, a DeamonSet that optimizes native Ingress, and the dependent open source LVS and Ansible components. The specific structure diagram can be as follows: Figure 3 shown.

[0098] and Figure 1 Corresponding to the above method, the embodiment of the present invention also provides a cluster load balancing device for Figure 1 In the specific implementation of the method, the cluster load balancing device provided by the embodiment of the present invention can be used in a computer terminal or various mobile devices, combined with Figure 4 , introduce the load balancing device of the cluster, such as Figure 4 As shown, the device may include:

[0099] A deployment generation module 10 is used to deploy a load balancing controller in the Kubernetes cluster and generate a Controller container corresponding to the load balancing controller;

[0100] A connection module 20 is used to connect the preset LVS cluster with the Kubernetes cluster and set the configuration file of the LVS cluster in the load balancing controller;

[0101] A target node determination module 30 is configured to determine a target node from among the nodes of the Kubernetes cluster;

[0102] The marking module 40 is used to mark the target node with a preset label to obtain a marked node, create an Ingress POD in the marked node, and monitor the Ingress POD through the Controller container;

[0103] An acquisition and mounting module 50 is configured to acquire the IP address of the marking node and the postStart hook script in the Ingress POD, and to mount the IP address of the marking node to the Lo network card of the marking node using the postStart hook script;

[0104] An IP address acquisition module 60 is configured to acquire the IP address of the marked node from the Lo network card of the marked node when the Controller container monitors the generation of a lifecycle event of the Ingress POD;

[0105] The update module 70 is used to update the configuration file of the LVS cluster using the IP address, so as to achieve load balancing of the Kubernetes cluster when a new Ingress node is created.

[0106] It can be seen from the above technical solution that the present application deploys a load balancing controller in the Kubernetes cluster and generates a Controller container corresponding to the load balancing controller at the same time; connects the preset LVS cluster with the Kubernetes cluster, and sets the configuration file of the LVS cluster in the load balancing controller; determines the target node from each node of the Kubernetes cluster; marks the target node with a preset label to obtain a marked node, and creates an Ingress POD in the marked node, and monitors the Ingress POD through the Controller container; obtains the IP address of the marked node and the postStart hook script in the Ingress POD, and uses the postStart hook script to mount the IP address of the marked node to the Lo network card of the marked node; when the Controller container monitors the Ingress POD to generate a life cycle event, it obtains the IP address of the marked node from the Lo network card of the marked node; uses the IP address to update the configuration file of the LVS cluster, so as to achieve load balancing of the Kubernetes cluster when a new Ingress node is created. This solution extends the load balancing capabilities of the Kubernetes cluster by deploying a load balancing controller, deploying an LVS cluster connected to the Kubernetes cluster outside the cluster, and managing the lifecycle of the LVS cluster. It can implement an automatic load balancing mechanism on the newly created Ingress node, improving the cluster's availability and service quality.

[0107] In one example, the acquisition and mounting module 50 may include:

[0108] A namespace acquisition module, used to obtain the namespace of the Kubernetes cluster;

[0109] ConfigMap deployment module, used to deploy pre-customized ConfigMap in the namespace;

[0110] An IP address determination module is used to determine the IP address of the marked node from the ConfigMap.

[0111] In an example, the acquisition and mounting module 50 may further include:

[0112] A configuration and operation module is used to configure the Nginx container privilege mode for the Ingress POD and run the Ingress POD as a preset root user;

[0113] A trigger module is used to start the Ingress POD and automatically trigger the postStart hook script by the pre-set lifecycle management process of the Kubernetes cluster;

[0114] A modification script acquisition module, configured to acquire a modification script corresponding to the IP address of the marked node;

[0115] The read execution module is used to use the Ingress POD to read the IP address of the marking node and execute the modification script, so as to use the postStart hook script to mount the IP address of the marking node to the Lo network card of the marking node.

[0116] In one example, the IP address acquisition module 60 may include:

[0117] A query module is configured to obtain the application programming interface of the Kubernetes cluster when the Controller container monitors the generation of a lifecycle event by the Ingress POD, and use the application programming interface to query the status information of the Ingress POD;

[0118] The acquisition module is used to obtain the IP address of the marking node from the Lo network card of the marking node based on the status information.

[0119] In one example, the updating module 70 may include:

[0120] An additional module is used to install Ansible in the image of the load balancing controller, start the Ansible, and use the Ansible to add the IP address to the configuration file of the LVS cluster;

[0121] A judgment module is used to restart the LVS cluster and load the configuration file of the LVS cluster with the IP address added, so that the LVS cluster can judge whether the marked node is normal;

[0122] The adding module is used to add the marked node to the Kubernetes cluster if so, in order to achieve load balancing of the Kubernetes cluster when a new Ingress node is created.

[0123] In one example, the apparatus may further include:

[0124] A hook script acquisition module is used to obtain a pre-set preStop hook script when the marked node goes down;

[0125] A trigger module is used to start the Ingress POD and automatically trigger the preStop hook script by the pre-set lifecycle management process of the Kubernetes cluster;

[0126] An uninstallation module is used to uninstall the IP address of the marked node using the preStop hook script.

[0127] Furthermore, the embodiment of the present application provides a cluster load balancing device. Figure 5 The hardware structure diagram of the cluster load balancing device is shown in FIG. Figure 5 The hardware structure of the cluster load balancing device may include: at least one processor 01 , at least one communication interface 02 , at least one memory 03 and at least one communication bus 04 .

[0128] In the embodiment of the present application, the number of the processor 01 , the communication interface 02 , the memory 03 , and the communication bus 04 is at least one, and the processor 01 , the communication interface 02 , and the memory 03 communicate with each other through the communication bus 04 .

[0129] The processor 01 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention.

[0130] The memory 03 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory.

[0131] The memory stores a program, and the processor can call the program stored in the memory. The program is used to execute the following cluster load balancing method, including:

[0132] Deploy a load balancing controller in the Kubernetes cluster and generate a Controller container corresponding to the load balancing controller.

[0133] Connect the preset LVS cluster to the Kubernetes cluster and set the configuration file of the LVS cluster in the load balancing controller;

[0134] Determine a target node from among the nodes of the Kubernetes cluster;

[0135] Mark the target node with a preset label to obtain a marked node, create an Ingress POD in the marked node, and monitor the Ingress POD through the Controller container;

[0136] Obtain the IP address of the marked node and the postStart hook script in the Ingress POD, and use the postStart hook script to mount the IP address of the marked node to the Lo network card of the marked node;

[0137] When the Controller container monitors the lifecycle event of the Ingress POD, it obtains the IP address of the marked node from the Lo network card of the marked node;

[0138] The configuration file of the LVS cluster is updated using the IP address to achieve load balancing of the Kubernetes cluster when a new Ingress node is created.

[0139] Optionally, the detailed functions and extended functions of the program may refer to the description of the cluster load balancing method in the method embodiment.

[0140] An embodiment of the present application further provides a storage medium, which may store a program suitable for execution by a processor. When the program is executed, the device where the storage medium is located is controlled to execute the following cluster load balancing method, including:

[0141] Deploy a load balancing controller in the Kubernetes cluster and generate a Controller container corresponding to the load balancing controller.

[0142] Connect the preset LVS cluster to the Kubernetes cluster and set the configuration file of the LVS cluster in the load balancing controller;

[0143] Determine a target node from among the nodes of the Kubernetes cluster;

[0144] Mark the target node with a preset label to obtain a marked node, create an Ingress POD in the marked node, and monitor the Ingress POD through the Controller container;

[0145] Obtain the IP address of the marked node and the postStart hook script in the Ingress POD, and use the postStart hook script to mount the IP address of the marked node to the Lo network card of the marked node;

[0146] When the Controller container monitors the lifecycle event of the Ingress POD, it obtains the IP address of the marked node from the Lo network card of the marked node;

[0147] The configuration file of the LVS cluster is updated using the IP address to achieve load balancing of the Kubernetes cluster when a new Ingress node is created.

[0148] Specifically, the storage medium may be a computer-readable storage medium, and the computer-readable storage medium may be an electronic memory such as a flash memory, an EEPROM (Electrically Erasable Programmable Read-Only Memory), an EPROM, a hard disk or a ROM.

[0149] Optionally, the detailed functions and extended functions of the program may refer to the description of the cluster load balancing method in the method embodiment.

[0150] In addition, the functional modules in the various embodiments of the present disclosure can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part. If the function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a live broadcast device, or a network device, etc.) to perform all or part of the steps of the methods of the various embodiments of the present disclosure.

[0151] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.

[0152] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0153] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A cluster load balancing method, characterized in that: include: Deploy a load balancing controller in the Kubernetes cluster and generate a Controller container corresponding to the load balancing controller. Connect the preset LVS cluster to the Kubernetes cluster and set the configuration file of the LVS cluster in the load balancing controller; Determine a target node from among the nodes of the Kubernetes cluster; Mark the target node with a preset label to obtain a marked node, create an Ingress POD in the marked node, and monitor the Ingress POD through the Controller container; Obtain the IP address of the marked node and the postStart hook script in the Ingress POD, and use the postStart hook script to mount the IP address of the marked node to the Lo network card of the marked node; When the Controller container monitors the lifecycle event of the Ingress POD, it obtains the IP address of the marked node from the Lo network card of the marked node; The configuration file of the LVS cluster is updated using the IP address to achieve load balancing of the Kubernetes cluster when a new Ingress node is created.

2. The method according to claim 1, characterized in that The obtaining of the IP address of the marking node includes: Get the namespace of the Kubernetes cluster; Deploy a pre-customized ConfigMap in the namespace; Determine the IP address of the marked node from the ConfigMap.

3. The method according to claim 1, characterized in that The postStart hook script is used to mount the IP address of the marking node to the Lo network card of the marking node, including: Configure the Nginx container privileged mode for the Ingress POD and run the Ingress POD as the default root user; Start the Ingress POD, and the pre-set lifecycle management process of the Kubernetes cluster automatically triggers the postStart hook script; Obtaining a modification script corresponding to the IP address of the marked node; The IP address of the marking node is read by using the Ingress POD, and the modification script is executed, so as to mount the IP address of the marking node to the Lo network card of the marking node by using the postStart hook script.

4. The method according to claim 1, wherein When the Controller container monitors the Ingress POD and generates a lifecycle event, obtaining the IP address of the marked node from the Lo network card of the marked node includes: When the Controller container monitors the Ingress POD and generates a lifecycle event, it obtains the application programming interface of the Kubernetes cluster and uses the application programming interface to query the status information of the Ingress POD; The IP address of the marking node is obtained from the Lo network card of the marking node based on the status information.

5. The method according to claim 1, wherein The method of updating the configuration file of the LVS cluster using the IP address to achieve load balancing of the Kubernetes cluster when creating a new Ingress node includes: Install Ansible in the image of the load balancing controller, start Ansible, and use Ansible to add the IP address to the configuration file of the LVS cluster; Restart the LVS cluster and load the configuration file of the LVS cluster with the added IP address, so that the LVS cluster can determine whether the marked node is normal; If so, the marked node is added to the Kubernetes cluster in order to achieve load balancing of the Kubernetes cluster when a new Ingress node is created.

6. The method according to claim 1, characterized in that Also includes: When the marked node goes down, obtain the pre-set preStop hook script; Start the Ingress POD, and the pre-set lifecycle management process of the Kubernetes cluster automatically triggers the preStop hook script; The IP address of the marked node is uninstalled using the preStop hook script.

7. A cluster load balancing device, characterized in that: include: A deployment generation module is used to deploy a load balancing controller in the Kubernetes cluster and generate a Controller container corresponding to the load balancing controller; A connection module, used to connect the preset LVS cluster with the Kubernetes cluster and set the configuration file of the LVS cluster in the load balancing controller; A target node determination module, configured to determine a target node from among the nodes in the Kubernetes cluster; A marking module is used to mark the target node with a preset label to obtain a marked node, create an Ingress POD in the marked node, and monitor the Ingress POD through the Controller container; A mounting module, configured to obtain the IP address of the marking node and the postStart hook script in the Ingress POD, and use the postStart hook script to mount the IP address of the marking node to the Lo network card of the marking node; An IP address acquisition module is configured to acquire the IP address of the marked node from the Lo network card of the marked node when the Controller container monitors the generation of a lifecycle event by the Ingress POD; The update module is used to update the configuration file of the LVS cluster using the IP address, so as to achieve load balancing of the Kubernetes cluster when a new Ingress node is created.

8. The device according to claim 7, characterized in that The mounting module includes: A configuration and operation module is used to configure the Nginx container privilege mode for the Ingress POD and run the Ingress POD as a preset root user; A trigger module is used to start the Ingress POD and automatically trigger the postStart hook script by the pre-set lifecycle management process of the Kubernetes cluster; A modification script acquisition module, configured to acquire a modification script corresponding to the IP address of the marked node; The read execution module is used to use the Ingress POD to read the IP address of the marking node and execute the modification script, so as to use the postStart hook script to mount the IP address of the marking node to the Lo network card of the marking node.

9. A cluster load balancing device, characterized in that: including memory and processor; The memory is used to store programs; The processor is configured to execute the program to implement each step of the cluster load balancing method according to any one of claims 1 to 6.

10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, each step of the cluster load balancing method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Method for realizing cluster sharing type public cloud load balancing

    CN111638957A

  • Cluster high-availability service configuration method and system, terminal and storage medium

    CN111736993A