Node switching method and device, computer equipment, readable storage medium and program product
The multi-objective genetic algorithm model calculates the target solution based on the scores of multiple performance indicators, switches the source node of the pod resource to the target node, solving the service discontinuity problem caused by the selection of a single indicator in the prior art, and achieving high availability of the system.
Patent Information
- Application Number
- CN202411701527.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-03-07
AI Technical Summary
In the prior art, selecting a target node from several fixed nodes according to a single indicator for switching, sometimes resulting in the inability to meet the continuity of the service after the switching.
By obtaining the scores of multiple performance indicators of the target physical machine and inputting these scores into the multi-target genetic algorithm model, the target solution of the target node including the corresponding pod resource is calculated, and the source node where the pod resource is located is switched to the target node according to the target solution.
By considering multiple performance metrics, the determined target nodes can meet the requirements of multiple performance metrics, ensuring service continuity and high system availability.
Smart Images

Figure CN119576783A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software testing technology, and in particular to a node switching method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art
[0002] As the business continues to expand, the customer base is growing, and the scale of requests is also rising. High-availability systems reduce service interruptions. "High availability" (HA) refers to the ability to provide services continuously without interrupting the operation of the system.
[0003] In traditional technology, a target node is selected from a fixed number of nodes based on a single indicator for switching to ensure uninterrupted service.
[0004] Currently, the target node is selected from a fixed number of nodes based on a single indicator. Sometimes, when switching to the target node, eviction occurs due to other indicators. That is, even if switching to a new node, service continuity cannot be met. Summary of the invention
[0005] Based on this, it is necessary to provide a node switching method, apparatus, computer device, computer-readable storage medium and computer program product that can meet service continuity in response to the above technical problems.
[0006] In a first aspect, the present application provides a node switching method, the method comprising:
[0007] Obtain scores corresponding to multiple performance indicators of the target physical machine;
[0008] Input the scores of the multiple performance indicators into a multi-objective genetic algorithm model, and obtain a target solution output by the multi-objective genetic algorithm model; the target solution represents a scheduling scheme for pod resources, including a target node corresponding to the pod resources;
[0009] According to the target solution, the source node where the pod resource is located is switched to the target node.
[0010] In one embodiment, the method further comprises:
[0011] An initial solution set is randomly generated according to the scores corresponding to each of the performance indicators by a target genetic algorithm, wherein the initial solution set includes at least one initial solution, and each initial solution represents an initial scheduling scheme for pod resources;
[0012] Performing adaptability calculation on each of the initial solutions through an evaluation function, and performing selection, crossover and mutation processing according to the calculation results to generate a new set of initial solutions;
[0013] Until the preset conditions are met, a new initial solution set that meets the preset conditions is used as a candidate solution set;
[0014] The target solution is determined from the candidate solution set according to a selection rule.
[0015] In one embodiment, obtaining scores corresponding to multiple performance indicators of the target physical machine includes:
[0016] Obtaining a plurality of performance indicators of each physical machine;
[0017] Determine an abnormal physical machine according to multiple performance indicators of each of the physical machines in the same cluster;
[0018] Eliminating the multiple performance indicators of the abnormal physical machine to obtain multiple performance indicators of each of the target physical machines;
[0019] According to the multiple performance indicators of each of the target physical machines in the same cluster, a score corresponding to each of the performance indicators of each of the target physical machines is determined.
[0020] In one embodiment, switching the source node where the pod resource is located to the target node according to the target solution includes:
[0021] When the target node corresponding to the pod resource in the target solution and the source node where the pod resource is located are in the same cluster, back up the pod resource of the source node and check whether there is any abnormality in the environment of the target node;
[0022] If there is no abnormality in the environment of the target node, the backed up pod resources are switched from the source node to the target node.
[0023] In one embodiment, the source node corresponds to a source network element, and the target node corresponds to a target network element; the method further includes:
[0024] Modifying the Internet Protocol address of the source network element to a first Internet Protocol address, wherein the first Internet Protocol address includes a virtual Internet Protocol address or a floating Internet Protocol address;
[0025] configuring the first Internet Protocol address and the second Internet Protocol address to the target network element, and refreshing the configured routing rule of the target network element; wherein the second Internet Protocol address represents the destination address corresponding to the first Internet Protocol address as the source address;
[0026] The first Internet Protocol address and the second Internet Protocol address of the configured target network element are announced so that traffic flows to the configured target network element.
[0027] In one embodiment, switching the source node where the pod resource is located to the target node according to the target solution includes:
[0028] In the case where the target node corresponding to the pod resource in the target solution and the source node where the pod resource is located are in different clusters, redundantly copying the configuration file of the cluster where the source node is located to the target cluster, where the target cluster represents the cluster where the target node is located;
[0029] The name of the source node in the configuration file copied to the target cluster is modified to the name of the target node, and the modified configuration file is opened to complete the switching of the source node where the pod resource is located to the target node.
[0030] In a second aspect, the present application further provides a node switching device, the device comprising:
[0031] A score acquisition module, used to obtain scores corresponding to multiple performance indicators of the target physical machine;
[0032] A target solution acquisition module, used to input the scores of the multiple performance indicators into the multi-objective genetic algorithm model, and obtain the target solution output by the multi-objective genetic algorithm model; the target solution represents the scheduling plan of the pod resources, including the target node corresponding to the pod resources;
[0033] A switching module is used to switch the source node where the pod resource is located to the target node according to the target solution.
[0034] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.
[0035] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a processor.
[0036] In a fifth aspect, the present application also provides a computer program product, including a computer program, which implements the steps of the above method when executed by a processor.
[0037] The above-mentioned node switching method, device, computer equipment, computer-readable storage medium and computer program product obtain the scores corresponding to multiple performance indicators of the target physical machine; calculate the target solution including the target node corresponding to the pod resource according to the scores corresponding to the multiple performance indicators through the multi-objective genetic algorithm model. Since the multi-objective genetic algorithm model is a scheduling scheme for pod resources determined according to multiple performance indicators, multiple performance indicators are involved in determining the target node. Compared with the prior art, the target node in the target solution determined on the basis of considering multiple performance indicators must meet the requirements of multiple performance indicators. According to the target node in the target solution, the source node where the pod resource is located is switched to the target node to ensure continuous and uninterrupted service, thereby achieving high availability of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0039] Figure 1 An application environment diagram of a node switching method in an embodiment;
[0040] Figure 2 A schematic diagram of a process flow of a node switching method in an embodiment;
[0041] Figure 3 A schematic diagram of a process flow of a target genetic algorithm processing a score in one embodiment;
[0042] Figure 4 A schematic diagram of a process for obtaining scores corresponding to multiple performance indicators in another embodiment;
[0043] Figure 5 A schematic diagram of a process of switching nodes according to a target solution in an embodiment;
[0044] Figure 6 is a schematic flow chart of a node switching method in another embodiment;
[0045] Figure 7 A schematic diagram of a flow chart of network element configuration for node switching within the same cluster in one embodiment;
[0046] Figure 8 A schematic diagram of a network element configuration for node switching within the same cluster in one embodiment;
[0047] Fig. 9A schematic diagram of a process of switching nodes according to a target solution in another embodiment;
[0048] Fig.10 is a structural block diagram of a node switching device in one embodiment;
[0049] Fig.11 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0051] The node switching method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the Kubernetes cluster 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The server obtains the scores corresponding to multiple performance indicators of the target physical machine; the scores of the multiple performance indicators are input into the multi-objective genetic algorithm model, and the target solution output by the multi-objective genetic algorithm model is obtained; the target solution represents the scheduling scheme of the pod resources, including the target node corresponding to the pod resources; according to the target solution, the source node where the pod resource is located is switched to the target node. Among them, the Kubernetes cluster 102 includes multiple clusters, among which Kubernetes is referred to as k8s. In the Kubernetes cluster, it usually includes multiple nodes (Node), which can be physical machines or virtual machines, and they work together to run containerized applications. Server 104 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.
[0052] In an exemplary embodiment, Figure 2 As shown, a node switching method is provided, which is applied to Figure 1 The server in the example is used to illustrate, including the following steps S202 to S206. Among them:
[0053] Step S202: Obtain scores corresponding to multiple performance indicators of the target physical machine.
[0054] The target physical machine is a physical machine that works normally. Performance indicators include service architecture, memory, storage, bandwidth rate, load level, k8s cluster health status, time consumption, etc.
[0055] Optionally, before obtaining the scores corresponding to the multiple performance indicators of the target physical machine, the server determines the scores corresponding to the performance indicators according to the scoring rules corresponding to the performance indicators. Alternatively, the server determines the initial scores corresponding to the performance indicators according to the scoring rules corresponding to the performance indicators; obtains the weights corresponding to the performance indicators; and performs weighted calculation according to the initial scores and weights corresponding to the performance indicators to determine the scores.
[0056] Optionally, the server obtains all physical machines within a specified range, excludes abnormal physical machines, and obtains the target physical machine. The specified range may be all physical machines in a k8s cluster or all physical machines in multiple k8s clusters.
[0057] Optionally, the server obtains scores corresponding to multiple performance indicators of a normally running physical machine. For example, the service architecture score of the target physical machine 1 is a, the memory score is b, the storage score is c, the bandwidth rate score is d, the load score is e, the k8s cluster health score is f, and the time consumption score is g. The scores corresponding to the performance indicators of each target physical machine are obtained by analogy. The server can also multiply the scores corresponding to each performance indicator by the corresponding weight as the final score.
[0058] Step S204, input the scores of multiple performance indicators into the multi-objective genetic algorithm model, and obtain the target solution output by the multi-objective genetic algorithm model; the target solution represents the scheduling plan of the pod resources, including the target node corresponding to the pod resources.
[0059] Among them, Multi-Objective Genetic Algorithm (MOGA) is an optimization algorithm based on genetic algorithm, which is specially used to solve optimization problems with multiple objectives. In optimization problems, when a problem involves multiple objectives, it constitutes a multi-objective optimization problem. There may be conflicts between these objectives, so it is difficult to find a single solution to meet all objectives at the same time. The goal of the multi-objective genetic algorithm is to find a set of solutions that are relatively excellent in multiple objectives.
[0060] The target solution represents the scheduling scheme of pod resources, including the target nodes corresponding to the pod resources. In Kubernetes, Pod is the smallest deployable computing unit for deploying, running, and managing containerized applications. Each Pod can contain one or more containers that share storage, network, and a set of resources to run them. Pod provides a way to package multiple components of an application together for running, making management and deployment simpler and more efficient.
[0061] Node: A node can be a physical machine or a virtual machine. A virtual machine needs to run on a physical machine and consumes the resources of the physical machine. The target node is the node to be switched or migrated. The source node is the current node running the pod.
[0062] Optionally, the server inputs the scores corresponding to each performance indicator into the multi-objective genetic algorithm model, and the multi-objective genetic algorithm model processes the scores corresponding to each performance indicator according to the optimization goal and the evaluation function. For example, the optimization goal is determined to be: maximize cluster performance and schedule the pod to a more idle and healthy node; output multiple candidate solutions, and the server determines the target solution from the multiple candidate solutions according to the selection rules. The target solution includes the scheduling plan of the pod. For example, the target node Node2 corresponding to pod1; ...; the target node Nodem corresponding to podn. Among them, n and m are positive integers.
[0063] Step S206: Switch the source node where the pod resource is located to the target node according to the target solution.
[0064] Optionally, the server switches the source node where the pod resource is located to the target node according to the target solution. For example, the source node where the pod resource is located is Node1, and the source node where the podn resource is located is Noden. The target solution is "target node Node2 corresponding to pod1; ...; target node Nodem corresponding to podn". The server needs to switch pod1 from source node Node1 to target node Node2; ...; and switch podn from source node Noden to target node Nodem according to the target solution.
[0065] In the above node switching method, the scores corresponding to multiple performance indicators of the target physical machine are obtained; the target solution including the target node corresponding to the pod resource is calculated according to the scores corresponding to the multiple performance indicators through the multi-objective genetic algorithm model. Since the multi-objective genetic algorithm model is a scheduling scheme for pod resources determined according to multiple performance indicators, multiple performance indicators are involved in determining the target node. Compared with the prior art, the target node in the target solution determined on the basis of considering multiple performance indicators must meet the requirements of multiple performance indicators. According to the target node in the target solution, the source node where the pod resource is located is switched to the target node to ensure continuous and uninterrupted service, thereby achieving high availability of the system.
[0066] In an exemplary embodiment, Figure 3 As shown, the process of processing the scores by the target genetic algorithm includes steps S302 to S308. Among them:
[0067] Step S302: randomly generate an initial solution set according to the scores corresponding to each performance indicator through a target genetic algorithm. The initial solution set includes at least one initial solution, and each initial solution represents an initial scheduling scheme for pod resources.
[0068] The initial solution set includes at least one initial solution, each initial solution represents an initial scheduling scheme for pod resources, and each initial solution is a chromosome individual.
[0069] Optionally, the server determines the optimization goal and evaluation function of the target genetic algorithm according to the instruction, for example, the optimization goal is to maximize cluster performance and schedule pods to more idle and healthy nodes. The evaluation function corresponding to each performance indicator is determined according to each performance indicator, such as memory usage evaluation function, storage usage evaluation function, etc.
[0070] Optionally, a population is initialized according to the scores corresponding to each performance indicator through a target genetic algorithm, and an initial solution set is randomly generated. The server determines the genetic encoding of each chromosome individual (initial solution), for example, using a bit string or real number encoding to represent different configuration parameters.
[0071] Step S304, performing adaptability calculation on each initial solution through the evaluation function, and performing selection, crossover and mutation processing according to the calculation results to generate a new initial solution set.
[0072] Optionally, the server scores all the targets of each chromosome individual (initial solution) according to the evaluation function, and calculates the Pareto ranking and non-dominated level of each chromosome individual (initial solution). Based on the Pareto ranking and non-dominated level of each chromosome individual (initial solution), as well as other selection pressures (such as crowding distance), select excellent chromosome individuals (initial solutions) to enter the next generation. Pair the selected excellent chromosome individuals (initial solutions), and apply the crossover operation to generate new offspring chromosome individuals (initial solutions). Apply the mutation operation to the new offspring chromosome individuals (initial solutions), introduce new genetic diversity, and generate a new set of initial solutions.
[0073] Step S306: until the preset condition is met, a new initial solution set that meets the preset condition is used as a candidate solution set.
[0074] The preset conditions include a predetermined number of iterations or other termination conditions.
[0075] Optionally, the server performs adaptive calculations on the new initial solution set through an evaluation function, and performs selection, crossover and mutation processing on the Pareto ranking and non-dominated level of each chromosome individual (initial solution) to generate a new initial solution set according to the Pareto ranking and non-dominated level. Until the preset conditions are met, such as whether the predetermined number of iterations is reached or whether other termination conditions are met (such as whether the Pareto front change is less than a certain threshold), the new initial solution set that meets the preset conditions is used as a candidate solution set. The candidate solution set includes at least one candidate solution.
[0076] Step S308: determine the target solution from the candidate solution set according to the selection rule.
[0077] Optionally, the server determines a unique target solution from at least one candidate solution in the candidate solution set according to a selection rule, wherein the selection rule is determined according to business requirements.
[0078] Optionally, the server may also adjust the target solution to meet specific business requirements and obtain a final target solution.
[0079] In this embodiment, a target solution that meets the optimization goal is output by calculating the collected performance indicators through a multi-objective genetic algorithm. The target solution is a solution that meets multiple performance indicators determined based on multiple performance indicators, which reduces the situation where the target node is expelled because other performance indicators are not met after a single performance indicator is met.
[0080] In an exemplary embodiment, Figure 4 As shown, obtaining scores corresponding to multiple performance indicators of the target physical machine includes steps S402 to S408. Among them:
[0081] Step S402: Acquire multiple performance indicators of each physical machine.
[0082] Optionally, the server obtains multiple performance indicators of each physical machine in at least one k8s cluster. For example, the server obtains multiple performance indicators of each physical machine in k8s cluster 1; at the same time, the server can also obtain multiple performance indicators of each physical machine in k8s cluster 2.
[0083] It should be understood that the server can only obtain multiple performance indicators of each physical machine in a k8s cluster.
[0084] Step S404: determining an abnormal physical machine according to multiple performance indicators of each physical machine in the same cluster.
[0085] Optionally, the server determines the abnormal physical machine based on multiple performance indicators of each physical machine in the same cluster. For example, there are 5 physical machines in k8s cluster 1. Among them, the service architecture of four physical machines is arm architecture, and the service architecture of one physical machine is non-arm architecture, such as x86. The physical machine with non-arm architecture is an abnormal physical machine.
[0086] Optionally, the server also determines whether the physical machine is disconnected or down based on the obtained multiple performance indicators of each physical machine, and also determines the disconnected and down physical machines as abnormal physical machines.
[0087] Step S406: Eliminate multiple performance indicators of abnormal physical machines to obtain multiple performance indicators of each target physical machine.
[0088] Optionally, the server removes the performance indicators of the abnormal physical machines and obtains multiple performance indicators of each normally operating target physical machine.
[0089] Step S408 : determining a score corresponding to each performance indicator of each target physical machine according to multiple performance indicators of each target physical machine in the same cluster.
[0090] Optionally, the server sets the average value of each performance indicator in each cluster as a reference value; the server compares multiple performance indicators of each target physical machine in the same cluster with the reference value to determine the score corresponding to each performance indicator of each target physical machine. For example, the reference value of the service architecture in k8s cluster 2 is Kylin; there are two physical machines in k8s cluster 2, namely physical machine 1 and physical machine 2. If the service architecture of physical machine 1 is Kylin, the score is 100 points. If the service architecture of physical machine 2 is not Kylin, the corresponding points will be deducted, for example, 50 points.
[0091] Optionally, the server can also determine the initial score corresponding to each performance indicator according to multiple performance indicators of each target physical machine in the same cluster and the scoring rules corresponding to the performance indicators; obtain the weight corresponding to each performance indicator; perform weighted calculation according to the initial score and weight corresponding to the performance indicator to determine the score, including: the server can also use the above score as the initial score, and at the same time, obtain the weight of each performance indicator, for example, the service architecture and the health status of the k8s cluster have the largest weight, the load level has the second largest weight, and the others have the second largest weight. The server performs weighted calculation according to the initial score and weight corresponding to the performance indicator to determine the score.
[0092] In this embodiment, by eliminating abnormal servers and determining the scores corresponding to each performance indicator of the target physical machine based on multiple performance indicators of each target physical machine in the same cluster, the scores and weights of the performance indicators can be adjusted according to actual conditions, so that the output target solution better matches business needs.
[0093] In an exemplary embodiment, Figure 5 As shown, according to the target solution, the source node where the pod resource is located is switched to the target node, including steps S502 to S504. Among them:
[0094] Step S502: When the target node corresponding to the pod resource in the target solution and the source node where the pod resource is located are in the same cluster, the pod resource of the source node is backed up, and whether there is any abnormality in the environment of the target node is checked.
[0095] Alternatively, if Figure 6 As shown, the server obtains the scores corresponding to multiple performance indicators of the target physical machine, inputs the scores corresponding to the multiple performance indicators into the multi-objective genetic algorithm model, and obtains the target solution output by the multi-objective genetic algorithm model. The server judges the target solution through the arbitration scheduling module. If the target node corresponding to the pod resource in the target solution and the source node where the pod resource is located are in the same cluster, the corresponding switching operation is performed according to the node switching in the same cluster; if the target node corresponding to the pod resource in the target solution and the source node where the pod resource is located are in different clusters, the corresponding switching operation is performed according to the node switching in different clusters.
[0096] Optionally, when the target node corresponding to the pod resource in the target solution and the source node where the pod resource is located are in the same cluster, the server backs up the pod resource of the source node and checks whether there is any abnormality in the environment of the target node.
[0097] Step S504: If there is no abnormality in the environment of the target node, the backed-up pod resources are switched from the source node to the target node.
[0098] Optionally, if there is no abnormality in the environment of the target node, the backed-up pod resources are switched from the source node to the target node. The source node is then destroyed and the target node is released to the outside.
[0099] Optionally, there are multiple types of pod resources, all of which follow the following procedure: before switching, back up the pod resources of the source node and check whether there are any abnormalities in the environment of the target node; if there are no abnormalities in the environment of the target node, switch the backed-up pod resources from the source node to the target node; after switching, destroy the source node and release the target node to the outside.
[0100] If the pod resource is a pod that relies on other services for connectivity and does not provide connectivity services itself, such as a virtual machine, use QEMU's KVM virtualization solution. KVM (Kernel-based Virtual Machine) is a Linux kernel module based on hardware virtualization technology, which is mainly responsible for CPU and memory virtualization. QEMU (Quick Emulator) is an open source virtualization software that is responsible for I / O virtualization and can simulate any hardware device, making the virtual machine think it is interacting with real hardware. The combination of the two can significantly improve virtualization performance.
[0101] If the pod resource is a pod that provides connectivity services, such as a network element pod, first create a backup pod, set a network floating IP, and then cut traffic ARP broadcast and other operations.
[0102] If the pod resource is for other service components, select scheduling through the node scheduling method.
[0103] If the pod resource is for a storage pod, ensure that the pool is connected and that the storage disk of another node is mounted successfully.
[0104] In this embodiment, by generating a backup before switching and switching the nodes in the same cluster after an environmental check, the continuity of the switching is ensured, the continuity of the business is ensured, and the high availability of the system is improved.
[0105] In an exemplary embodiment, Figure 7 As shown, the source node corresponds to the source network element, and the target node corresponds to the target network element; the network element configuration method includes steps S702 to S706. Among them:
[0106] Step S702: modify the Internet Protocol address of the source network element to a first Internet Protocol address, wherein the first Internet Protocol address includes a virtual Internet Protocol address or a floating Internet Protocol address.
[0107] Optionally, the server sets the state of the source network element to switching and sets the state of the target network element to standby. The Internet Protocol (IP) address of the source network element is modified to a first Internet Protocol address, wherein the first Internet Protocol address includes a virtual Internet Protocol (VIP) address or a floating Internet Protocol (Floating Internet Protocol) address. That is, the IP address of the source network element is modified to a VIP or a floating IP. Figure 8 As shown, the server changes the static IP of the source network element to VIP through the controller, and can also change it to a floating IP.
[0108] Step S704, configure the first Internet Protocol address and the second Internet Protocol address to the target network element, and refresh the configured routing rules of the target network element; wherein the second Internet Protocol address represents the destination address corresponding to the first Internet Protocol address as the source address.
[0109] Among them, the second Internet Protocol address is also called the Internet IP.
[0110] Optionally, the server changes the target network element from a standby state to an enabled state, configures the first Internet Protocol address and the second Internet Protocol address to the target network element, and after the configuration is completed, refreshes the routing rules of the configured target network element. If the static IP of the source network element is changed to VIP, the server configures the VIP to the target network element through the controller, and determines the interconnection IP based on the VIP, and the server configures the interconnection IP to the target network element through the controller. By configuring the VIP or floating IP to the target network element, the traffic of other network elements can be directed to the target network element. By configuring the interconnection IP to the target network element, the traffic of the source network element can be directed to the target network element.
[0111] Step S706, announcing the first Internet Protocol address and the second Internet Protocol address of the configured target network element, so that traffic flows to the configured target network element.
[0112] Optionally, the server announces the first Internet Protocol address and the second Internet Protocol address of the configured target network element so that the traffic flows to the configured target network element. Figure 8 As shown, the server notifies the switch and the local area network of the first Internet Protocol address and the second Internet Protocol address. After completion, the source network element can be deleted.
[0113] In this embodiment, by configuring the network element when switching nodes in the same cluster, traffic can flow to the target network element, thereby ensuring the continuity of the network when switching nodes.
[0114] In an exemplary embodiment, Fig. 9 As shown, according to the target solution, the source node where the pod resource is located is switched to the target node, including steps S902 to S904. Among them:
[0115] Step S902, when the target node corresponding to the pod resource in the target solution and the source node where the pod resource is located are in different clusters, redundantly copy the configuration file of the cluster where the source node is located to the target cluster, where the target cluster represents the cluster where the target node is located.
[0116] Alternatively, if Figure 6As shown, the server obtains the scores corresponding to multiple performance indicators of the target physical machine, inputs the scores corresponding to the multiple performance indicators into the multi-objective genetic algorithm model, and obtains the target solution output by the multi-objective genetic algorithm model. The server judges the target solution through the arbitration scheduling module. If the target node corresponding to the pod resource in the target solution and the source node where the pod resource is located are in the same cluster, the corresponding switching operation is performed according to the node switching in the same cluster; if the target node corresponding to the pod resource in the target solution and the source node where the pod resource is located are in different clusters, the corresponding switching operation is performed according to the node switching in different clusters.
[0117] Optionally, when the target node corresponding to the pod resource in the target solution and the source node where the pod resource is located are in different clusters, the configuration file of the cluster where the source node is located is redundantly copied to the target cluster. Before the target cluster represents the cluster where the target node is located, the server also monitors whether cross-cluster is required through the hypervisor component.
[0118] Optionally, if the node switching needs to cross clusters, that is, before the node switching between different clusters, the server also monitors whether the target node is alive through the hypervisor component. If the target node is alive, the configuration file of the cluster where the source node is located, such as CRD configuration, is redundantly copied to the target cluster. For example, the source node node1 where the pod resource is located is located in k8s cluster 1, and it needs to be switched to the target node node2, which is located in k8s cluster 2. The configuration file of k8s cluster 1 is redundantly copied to k8s cluster 2.
[0119] For example, the source node node1 where the pod1 resource is located is in k8s cluster 1 and needs to be switched to the target node node2; the source node node3 where the pod2 resource is located is in k8s cluster 1 and needs to be switched to the target node node4, which is in k8s cluster 3. Then the configuration file of the cluster where the source node is located, that is, the CRD configuration of k8s cluster 1, is redundantly copied to k8s cluster 2 and k8s cluster 3.
[0120] The target cluster represents the cluster where the target node is located. CRD is an extension of the Kubernetes API that allows users to define new resource types that can be created, updated, and deleted like built-in resources (such as Pods, Services, etc.). CRD defines a schema to describe the structure and validation rules of new resources, thereby ensuring the correctness and consistency of resources.
[0121] Step S904, modify the name of the source node in the configuration file copied to the target cluster to the name of the target node, and open the modified configuration file to complete the switching of the source node where the pod resource is located to the target node.
[0122] Optionally, if the source node node1 where the pod resource is located is in k8s cluster 1, you need to switch to the target node node2, which is in k8s cluster 2. When the node is switched, you need to change the name of the source node node1 in the configuration file copied to k8s cluster 2 to the name of the target node node2, and open the modified configuration file.
[0123] For example, the source node node1 where the pod1 resource is located is in k8s cluster 1 and needs to be switched to the target node node2; the source node node3 where the pod2 resource is located is in k8s cluster 1 and needs to be switched to the target node node4, which is in k8s cluster 3. When the node is switched, the name of the source node node1 in the configuration file copied to k8s cluster 2 needs to be changed to the name of the target node node2; and the name of the source node node3 in the configuration file copied to k8s cluster 3 needs to be changed to the name of the target node node4, and the modified configuration file is opened to complete the node switching. After the node is switched, the configuration file of the cluster where the source node is located is destroyed.
[0124] In this embodiment, a configuration file is generated through redundant replication, and the node name in the configuration file is modified to complete the node switching, thereby ensuring the continuity of the node switching and the continuity of the business, thereby improving the high availability of the system.
[0125] In an exemplary embodiment, Figure 6As shown, the server obtains multiple performance indicators of each physical machine in at least one k8s cluster. For example, the server obtains multiple performance indicators of each physical machine in k8s cluster 1; at the same time, the server can also obtain multiple performance indicators of each physical machine in k8s cluster 2. The server determines the abnormal physical machine based on the multiple performance indicators of each physical machine in the same cluster. For example, there are 5 physical machines in k8s cluster 1. Among them, the service architecture of four physical machines is arm architecture, and the service architecture of one physical machine is non-arm architecture, such as x86. The physical machine of non-arm architecture is an abnormal physical machine. The server removes the performance indicators of the abnormal physical machine and obtains multiple performance indicators of each normal target physical machine. The server sets the average value of each performance indicator in each cluster as a reference value; the server compares the multiple performance indicators of each target physical machine in the same cluster with the reference value to determine the score corresponding to each performance indicator of each target physical machine. For example, the reference value of the service architecture in k8s cluster 2 is Kirin; there are two physical machines in k8s cluster 2, namely physical machine 1 and physical machine 2. If the service architecture of physical machine 1 is Kylin, the score is 100 points. If the service architecture of physical machine 2 is not Kylin, the score is deducted accordingly, for example, 50 points. The weight of each performance indicator is obtained. For example, the service architecture and the health status of the k8s cluster are the most important, followed by the load level, and the others. The server performs weighted calculation based on the initial score and weight corresponding to the performance indicator to determine the score.
[0126] The server determines the optimization goal and evaluation function of the target genetic algorithm according to the instructions. For example, the optimization goal is to maximize cluster performance and schedule pods to more idle and healthy nodes. The evaluation function corresponding to each performance indicator is determined according to each performance indicator, such as memory usage evaluation function, storage usage evaluation function, etc. The target genetic algorithm initializes the population according to the scores corresponding to each performance indicator, randomly generates an initial solution set, and the server determines the genetic encoding of each chromosome individual (initial solution), for example, using bit string or real number encoding to represent different configuration parameters. All goals of each chromosome individual (initial solution) are scored according to the evaluation function, and the Pareto ranking and non-dominated level of each chromosome individual (initial solution) are calculated. According to the Pareto ranking and non-dominated level of each chromosome individual (initial solution) and other selection pressures (such as crowding distance), excellent chromosome individuals (initial solutions) are selected to enter the next generation. The selected excellent chromosome individuals (initial solutions) are paired, and a crossover operation is applied to generate new offspring chromosome individuals (initial solutions). A mutation operation is applied to the new offspring chromosome individuals (initial solutions) to introduce new genetic diversity and generate a new initial solution set. The server uses the evaluation function to perform adaptive calculations on the new initial solution set, the Pareto ranking and non-dominated level of each chromosome individual (initial solution), and performs selection, crossover and mutation processing based on the Pareto ranking and non-dominated level to generate a new initial solution set. Until the preset conditions are met, such as whether the predetermined number of iterations is reached or whether other termination conditions are met (such as whether the Pareto front change is less than a certain threshold), the new initial solution set that meets the preset conditions is used as the candidate solution set. Among them, the candidate solution set includes at least one candidate solution. The server determines a unique target solution from at least one candidate solution in the candidate solution set according to the selection rules. Among them, the selection rules are determined according to business needs. The target solution represents the scheduling plan for pod resources, including the target node corresponding to the pod resources.
[0127] Continue as Figure 6 As shown, the server judges the target solution through the arbitration scheduling module. When the target node corresponding to the pod resource in the target solution is in the same cluster as the source node where the pod resource is located, the server backs up the pod resources of the source node and checks whether there are any abnormalities in the environment of the target node; if there are no abnormalities in the environment of the target node, the backed-up pod resources are switched from the source node to the target node. After that, the source node is destroyed and the target node is released to the outside. There are multiple types of pod resources, all of which follow the principle of backing up the pod resources of the source node before switching and checking whether there are any abnormalities in the environment of the target node; if there are no abnormalities in the environment of the target node, the backed-up pod resources are switched from the source node to the target node; after switching, the source node is destroyed and the target node is released to the outside.
[0128] If the pod resource is a pod that relies on other services for connectivity and does not provide connectivity services itself, such as a virtual machine, use QEMU's KVM virtualization solution. Among them, KVM (Kernel-based Virtual Machine) is a Linux kernel module based on hardware virtualization technology, which is mainly responsible for CPU and memory virtualization. QEMU (Quick Emulator) is an open source virtualization software responsible for I / O virtualization. It can simulate any hardware device and make the virtual machine think that it is interacting with real hardware. The combination of the two can significantly improve the performance of virtualization. If the pod resource is a pod that provides connectivity services, such as a network element pod, first establish a backup pod, set a network floating IP, and then cut traffic ARP broadcast and other operations. If the pod resource is for other service components, select scheduling through the node scheduling method. If the pod resource is for a storage pod, ensure that the pool is connected while ensuring that the storage disk of another node is successfully mounted.
[0129] For the continuity of network services: the server sets the state of the source network element to switching, and sets the state of the target network element to standby state. The Internet Protocol (IP) address of the source network element is modified to the first Internet Protocol address, wherein the first Internet Protocol address includes a virtual Internet Protocol (VIP) address or a floating Internet Protocol address. That is, the IP address of the source network element is modified to VIP or floating IP. The server changes the target network element from standby state to enabled state, configures the first Internet Protocol address and the second Internet Protocol address to the target network element, and after the configuration is completed, refreshes the routing rules of the configured target network element. If the static IP of the source network element is modified to VIP, the server configures VIP to the target network element through the controller, and determines the interconnection IP according to the VIP, and the server configures the interconnection IP to the target network element through the controller. By configuring VIP or floating IP to the target network element, the traffic of other network elements can be realized to flow to the target network element. By configuring the interconnection IP to the target network element, the traffic of the source network element can be realized to flow to the target network element. The server announces the first Internet Protocol address and the second Internet Protocol address of the configured target network element so that traffic flows to the configured target network element. Figure 8 As shown, the server notifies the switch and the local area network of the first Internet Protocol address and the second Internet Protocol address. After completion, the source network element can be deleted.
[0130] In the target solution, if the target node corresponding to the pod resource and the source node where the pod resource is located are in different clusters, the configuration file of the cluster where the source node is located is redundantly copied to the target cluster. Before the target cluster represents the cluster where the target node is located, the server also monitors whether it needs to cross clusters through the hypervisor component. If the node switching needs to cross clusters, that is, before the switching of nodes between different clusters, the server also monitors whether the target node status is alive through the hypervisor component. If the status of the target node is alive, the configuration file of the cluster where the source node is located, such as CRD configuration, is redundantly copied to the target cluster. For example, the source node node1 where the pod resource is located is located in k8s cluster 1, and it needs to switch to the target node node2, which is located in k8s cluster 2. The configuration file of k8s cluster 1 is redundantly copied to k8s cluster 2. When the node is switched, the name of the source node node1 in the configuration file copied to k8s cluster 2 needs to be changed to the name of the target node node2, and the modified configuration file is opened.
[0131] For example, the source node node1 where the pod1 resource is located is in k8s cluster 1 and needs to be switched to the target node node2; the source node node3 where the pod2 resource is located is in k8s cluster 1 and needs to be switched to the target node node4, which is in k8s cluster 3. Then the configuration file of the cluster where the source node is located, that is, the CRD configuration of k8s cluster 1, is redundantly copied to k8s cluster 2 and k8s cluster 3.
[0132] When switching nodes, you need to change the source node name node1 in the configuration file copied to k8s cluster 2 to the target node name node2; and change the source node name node3 in the configuration file copied to k8s cluster 3 to the target node name node4, and open the modified configuration file to complete the node switching. After the node is switched, the configuration file of the cluster where the source node is located is destroyed.
[0133] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0134] Based on the same inventive concept, the embodiment of the present application also provides a node switching device for implementing the node switching method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more node switching device embodiments provided below can refer to the limitations on the node switching method above, and will not be repeated here.
[0135] In an exemplary embodiment, Fig.10 As shown, a node switching device is provided, including: a score acquisition module 1001, a target solution acquisition module 1002 and a switching module 1003, wherein:
[0136] The score acquisition module 1001 is used to acquire scores corresponding to multiple performance indicators of the target physical machine;
[0137] The target solution acquisition module 1002 is used to input the scores of multiple performance indicators into the multi-objective genetic algorithm model and obtain the target solution output by the multi-objective genetic algorithm model; the target solution represents the scheduling plan of the pod resources, including the target node corresponding to the pod resources;
[0138] The switching module 1003 is used to switch the source node where the pod resource is located to the target node according to the target solution.
[0139] In an exemplary embodiment, a node switching device includes:
[0140] The processing module is used to randomly generate an initial solution set according to the scores corresponding to each performance indicator through a target genetic algorithm, where the initial solution set includes at least one initial solution, and each initial solution represents an initial scheduling plan for pod resources; perform adaptability calculation on each initial solution through an evaluation function, and perform selection, crossover and mutation processing according to the calculation results to generate a new initial solution set; until a preset condition is met, the new initial solution set that meets the preset condition is used as a candidate solution set; and determine the target solution from the candidate solution set according to the selection rule.
[0141] In an exemplary embodiment, the score acquisition module 1001 further includes:
[0142] The acquisition unit is used to acquire multiple performance indicators of each physical machine.
[0143] The abnormality determination unit is used to determine an abnormal physical machine according to multiple performance indicators of each physical machine in the same cluster.
[0144] The elimination unit is used to eliminate multiple performance indicators of abnormal physical machines to obtain multiple performance indicators of each target physical machine.
[0145] The score determination unit is used to determine the score corresponding to each performance indicator of each target physical machine according to multiple performance indicators of each target physical machine in the same cluster.
[0146] In an exemplary embodiment, the switching module 1003 includes:
[0147] The backup check unit is used to back up the pod resources of the source node and check whether there is any abnormality in the environment of the target node when the target node corresponding to the pod resources in the target solution and the source node where the pod resources are located are in the same cluster.
[0148] The switching unit is used to switch the backed-up pod resources from the source node to the target node if there is no abnormality in the environment of the target node.
[0149] In an exemplary embodiment, a node switching device further includes:
[0150] A network element configuration module is used to modify the Internet Protocol address of the source network element to a first Internet Protocol address, wherein the first Internet Protocol address includes a virtual Internet Protocol address or a floating Internet Protocol address; configure the first Internet Protocol address and the second Internet Protocol address to the target network element, and refresh the routing rules of the configured target network element; wherein the second Internet Protocol address represents the first Internet Protocol address as a destination address corresponding to the source address; and announce the first Internet Protocol address and the second Internet Protocol address of the configured target network element so that traffic flows to the configured target network element.
[0151] In an exemplary embodiment, the switching module 1003 includes:
[0152] The configuration file replication unit is used to redundantly replicate the configuration file of the cluster where the source node is located to the target cluster when the target node corresponding to the pod resource in the target solution and the source node where the pod resource is located are in different clusters. The target cluster represents the cluster where the target node is located.
[0153] The node name modification unit is used to modify the name of the source node in the configuration file copied to the target cluster to the name of the target node, and to open the modified configuration file to complete the switching of the source node where the pod resource is located to the target node.
[0154] Each module in the above-mentioned node switching device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0155] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Fig.11 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store performance indicators and node switching data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a node switching method is implemented.
[0156] Those skilled in the art will understand that Fig.11 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0157] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0158] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0159] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0160] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0161] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0162] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A node switching method, characterized in that: The method comprises: Obtain scores corresponding to multiple performance indicators of the target physical machine; Input the scores of the multiple performance indicators into a multi-objective genetic algorithm model, and obtain a target solution output by the multi-objective genetic algorithm model; the target solution represents a scheduling solution for pod resources, including a target node corresponding to the pod resources; According to the target solution, the source node where the pod resource is located is switched to the target node.
2. The method according to claim 1, characterized in that The method further comprises: An initial solution set is randomly generated according to the scores corresponding to each of the performance indicators by a target genetic algorithm, wherein the initial solution set includes at least one initial solution, and each initial solution represents an initial scheduling scheme for pod resources; Performing adaptability calculation on each of the initial solutions through an evaluation function, and performing selection, crossover and mutation processing according to the calculation results to generate a new set of initial solutions; Until the preset conditions are met, a new initial solution set that meets the preset conditions is used as a candidate solution set; The target solution is determined from the candidate solution set according to a selection rule.
3. The method according to claim 1, characterized in that The obtaining of scores corresponding to the multiple performance indicators of the target physical machine includes: Obtaining a plurality of performance indicators of each physical machine; Determine an abnormal physical machine according to multiple performance indicators of each of the physical machines in the same cluster; Eliminating the multiple performance indicators of the abnormal physical machine to obtain multiple performance indicators of each of the target physical machines; According to the multiple performance indicators of each of the target physical machines in the same cluster, a score corresponding to each of the performance indicators of each of the target physical machines is determined.
4. The method according to claim 1, characterized in that The step of switching the source node where the pod resource is located to the target node according to the target solution includes: When the target node corresponding to the pod resource in the target solution and the source node where the pod resource is located are in the same cluster, back up the pod resource of the source node and check whether there is any abnormality in the environment of the target node; If there is no abnormality in the environment of the target node, the backed up pod resources are switched from the source node to the target node.
5. The method according to claim 4, characterized in that The source node corresponds to a source network element, and the target node corresponds to a target network element; the method further includes: Modifying the Internet Protocol address of the source network element to a first Internet Protocol address, wherein the first Internet Protocol address includes a virtual Internet Protocol address or a floating Internet Protocol address; configuring the first Internet Protocol address and the second Internet Protocol address to the target network element, and refreshing the configured routing rule of the target network element; wherein the second Internet Protocol address represents the destination address corresponding to the first Internet Protocol address as the source address; The first Internet Protocol address and the second Internet Protocol address of the configured target network element are announced so that traffic flows to the configured target network element.
6. The method according to claim 1, characterized in that The step of switching the source node where the pod resource is located to the target node according to the target solution includes: In the case where the target node corresponding to the pod resource in the target solution and the source node where the pod resource is located are in different clusters, redundantly copying the configuration file of the cluster where the source node is located to the target cluster, where the target cluster represents the cluster where the target node is located; The name of the source node in the configuration file copied to the target cluster is modified to the name of the target node, and the modified configuration file is opened to complete the switching of the source node where the pod resource is located to the target node.
7. A node switching device, characterized in that: The device comprises: A score acquisition module, used to obtain scores corresponding to multiple performance indicators of the target physical machine; A target solution acquisition module, used to input the scores of the multiple performance indicators into the multi-objective genetic algorithm model, and obtain the target solution output by the multi-objective genetic algorithm model; the target solution represents the scheduling plan of the pod resources, including the target node corresponding to the pod resources; A switching module is used to switch the source node where the pod resource is located to the target node according to the target solution.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Instance scheduling method and device, hybrid scheduling component, storage medium and product
CN121996360A
An example scheduling method, apparatus, hybrid scheduling component, storage medium, and product
CN121996360B