Traffic allocation method and system for kubernetes cluster
By deploying multiple services with different billing methods in a Kubernetes cluster and dynamically switching the target billing method, the problem of service unavailability during load balancing configuration changes is solved, improving user experience and reducing cloud costs.
Patent Information
- Application Number
- CN202111307356.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-05
- Publication Date
- 2026-01-09
- Estimated Expiration
- 2041-11-05
AI Technical Summary
In a Kubernetes cluster, load balancers experience brief service unavailability issues during billing mode changes, impacting user experience.
Deploy multiple services in a Kubernetes cluster, each service corresponding to a load balancer with a different billing method. By monitoring traffic usage, dynamically switch the target billing method to ensure that at least one load balancer is always available. Use the same domain name to resolve multiple load balancer addresses.
It solves the problem of service unavailability during load balancing transitions, improves user experience, and reduces cloud costs through dynamic switching.
Smart Images

Figure CN114153558B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer software technology application, and in particular, relates to a traffic distribution method and system of a kubernetes cluster. BACKGROUND
[0002] Load balance is a service for distributing traffic on demand. After deploying an application in a kubernetes cluster, load balance is generally used for traffic access. The load balance distributes traffic to multiple cloud servers in the back end according to a forwarding strategy.
[0003] The cost of a web site on traffic is often very large. Cloud service providers generally provide two types of load balancing billing methods: fixed bandwidth billing and traffic billing. In the fixed bandwidth billing method, the bandwidth of the load balance is a fixed value. This method does not need to charge according to the size of the transmission traffic, so it has an advantage in large traffic. However, due to bandwidth limitations, the traffic transmission rate is slow. In the traffic billing method, small traffic is more cost-effective. When the usage traffic increases to a certain value, the charge is more expensive than the fixed bandwidth billing.
[0004] In related technologies, cloud costs are reduced by changing the load balance, for example, Figure 1 is a schematic diagram of a traffic distribution method of a kubernetes cluster in related technologies. As shown in Figure 1 , a plug-in monitors the traffic usage of the load balance. In the case of small traffic, the plug-in controls the load balance to stop fixed bandwidth billing and start traffic billing. In the case of large traffic, the plug-in controls the load balance to stop traffic billing and start fixed bandwidth billing, thereby effectively reducing cloud costs.
[0005] However, in the process of changing the load balance, if the load balance needs to use traffic in the gap period after stopping one billing method and before starting another billing method, the load balance will face a short period of service unavailability, resulting in service access failure and poor user experience.
[0006] In related technologies, in the process of changing the load balance, the load balance will face a short period of service unavailability, and no effective solution has been proposed. SUMMARY
[0007] Embodiments of the present application provide a traffic distribution method and system of a kubernetes cluster to at least solve the problem in related technologies that the load balance will face a short period of service unavailability in the process of changing the load balance.
[0008] In a first aspect, the embodiments of the present application provide a traffic distribution method of a kubernetes cluster, the kubernetes cluster being deployed with a pod and a plurality of services, each service corresponding to a load balancing corresponding to a different charging mode, addresses of the plurality of load balancings using a same domain name, and the method comprising:
[0009] calling an interface of a cloud service provider to obtain traffic usage of each service corresponding to a load balancing;
[0010] determining a target charging mode according to the usage, and determining a current actual charging mode;
[0011] in a case where the current actual charging mode is not the target charging mode, enabling a load balancing corresponding to the target charging mode;
[0012] in a case where the load balancing is enabled, disabling the remaining load balancings.
[0013] In some embodiments, the charging modes include fixed-bandwidth charging and traffic charging, and the process of determining the target charging mode according to the usage comprises:
[0014] determining a traffic usage in a preset time period;
[0015] in a case where the traffic usage is greater than or equal to a preset threshold, determining the target charging mode as the fixed-bandwidth charging; and in a case where the traffic usage is less than the preset threshold, determining the target charging mode as the traffic charging.
[0016] In a second aspect, the embodiments of the present application further provide a traffic distribution method of a kubernetes cluster, the kubernetes cluster being deployed with a pod and a plurality of services, each service corresponding to a load balancing corresponding to a different charging mode, addresses of the plurality of load balancings using a same domain name, and the method comprising:
[0017] determining a target charging mode of a time period in which a current time is located according to a preset correspondence between time periods and charging modes, and determining a current actual charging mode;
[0018] in a case where the current actual charging mode is not the target charging mode, enabling a load balancing corresponding to the target charging mode;
[0019] in a case where the load balancing is enabled, disabling the remaining load balancings.
[0020] In some embodiments, the charging modes include fixed-bandwidth charging and traffic charging, and the preset process of the correspondence between the time periods and the charging modes comprises:
[0021] The cloud service provider interface is called to obtain the load balancing traffic usage of each service;
[0022] Peak and valley periods of the traffic usage are determined, and a correspondence between the periods and charging modes is determined, wherein the charging mode of the peak period is charging by fixed bandwidth, and the charging mode of the valley period is charging by traffic.
[0023] In a third aspect, an embodiment of the present application provides a traffic distribution system of a kubernetes cluster, the kubernetes cluster being deployed with a pod and a plurality of services, load balancing corresponding to each service corresponding to different charging modes one by one, and addresses of the plurality of load balancers using the same domain name, and the system comprising:
[0024] The obtaining module is configured to call a cloud service provider interface to obtain the load balancing traffic usage corresponding to each service;
[0025] The determining module is configured to determine a target charging mode according to the usage, and determine a current actual charging mode;
[0026] The enabling module is configured to enable the load balancing corresponding to the target charging mode in a case where the current actual charging mode is not the target charging mode;
[0027] The disabling module is configured to disable the remaining load balancing in a case where the load balancing is enabled.
[0028] In some embodiments, the charging modes include charging by fixed bandwidth and charging by traffic, and the process of determining the target charging mode according to the usage includes:
[0029] Determining the traffic usage in a preset time period;
[0030] In a case where the traffic usage is greater than or equal to a preset threshold, determining the target charging mode as charging by fixed bandwidth; and in a case where the traffic usage is less than the preset threshold, determining the target charging mode as charging by traffic.
[0031] In a fourth aspect, an embodiment of the present application further provides a traffic distribution system of a kubernetes cluster, the kubernetes cluster being deployed with a pod and a plurality of services, load balancing corresponding to each service corresponding to different charging modes one by one, and addresses of the plurality of load balancers using the same domain name, and the system comprising:
[0032] determining module, configured to determine a target charging mode of a time period in which a current time is located according to a preset correspondence between time periods and charging modes, and determine a current actual charging mode;
[0033] enabling module, configured to enable a load balancing corresponding to the target charging mode in a case where the current actual charging mode is not the target charging mode;
[0034] stopping module, configured to stop remaining load balancings in a case where the load balancing is enabled.
[0035] In some embodiments, the charging modes include charging by fixed bandwidth and charging by traffic, and a preset process of the correspondence between time periods and charging modes includes:
[0036] calling an interface of a cloud service provider to obtain traffic usage of each service corresponding to a load balancing;
[0037] determining a peak period and a valley period of the traffic usage, and determining the correspondence between time periods and charging modes, wherein the charging mode of the peak period is charging by fixed bandwidth, and the charging mode of the valley period is charging by traffic.
[0038] In a fifth aspect, an electronic device is provided, including a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to execute the traffic distribution method of the kubernetes cluster.
[0039] In a sixth aspect, an embodiment of the present application provides a storage medium, which stores a computer program, wherein the computer program is configured to execute the traffic distribution method of the kubernetes cluster when running.
[0040] Compared with the related art, the traffic distribution method of the kubernetes cluster provided by the embodiments of the present application, by deploying pods and multiple services in the kubernetes cluster, load balancings corresponding to each service correspond to different charging modes one by one, addresses of the multiple load balancings use the same domain name, when the method is executed, an interface of a cloud service provider is called to obtain traffic usage of each service corresponding to a load balancing; a target charging mode is determined according to the usage; a current actual charging mode is determined, and in a case where the current actual charging mode is not the target charging mode, a load balancing corresponding to the target charging mode is enabled; in a case where the load balancing is enabled, remaining load balancings are stopped, which solves the problem that the load balancing faces a short service unavailability in the process of changing the load balancing in the related art, and improves user experience. BRIEF DESCRIPTION OF DRAWINGS
[0041] The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application. In the drawings:
[0042] Figure 1 is a schematic diagram of a traffic distribution method of a kubernetes cluster according to the related art;
[0043] Figure 2 is a schematic diagram of an application environment of a traffic distribution method of a kubernetes cluster according to an embodiment of the application;
[0044] Figure 3 is a flowchart of a traffic distribution method of a kubernetes cluster according to a first embodiment of the application;
[0045] Figure 4 is a schematic diagram of switching load balancing according to a first embodiment of the application;
[0046] Figure 5 is a schematic diagram of switching load balancing according to a second embodiment of the application;
[0047] Figure 6 is a flowchart of a traffic distribution method of a kubernetes cluster according to a second embodiment of the application;
[0048] Figure 7 is a structural block diagram of a traffic distribution system of a kubernetes cluster according to a third embodiment of the application;
[0049] Figure 8 is a structural block diagram of a traffic distribution system of a kubernetes cluster according to a fourth embodiment of the application;
[0050] Figure 9 is a schematic diagram of the internal structure of an electronic device according to an embodiment of the application. DETAILED DESCRIPTION
[0051] In order to make the objects, technical solutions and advantages of the application clearer, the application is described and explained below in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the application and do not limit the application. Based on the embodiments provided in the application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of protection of the application.
[0052] It is apparent that the drawings in the following description merely show some examples or embodiments of the present application, and for those skilled in the art, the present application can be applied to other similar situations without creative labor on the basis of these drawings. In addition, it can be understood that although the efforts made in this development process can be complex and lengthy, some design, manufacture or production changes made on the basis of the technology disclosed in the present application are only routine technical means for those skilled in the art related to the disclosure of the present application, and should not be understood as insufficient disclosure of the present application.
[0053] Reference to "an embodiment" in this application means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are they necessarily mutually exclusive of one another. It is explicitly contemplated that embodiments described herein can be combined with other embodiments in a non- conflicting manner.
[0054] Unless otherwise defined, technical terms or scientific terms used in the present application should be understood as their common meanings to those skilled in the art. The terms "a", "an", "one", "the", and similar terms in the present application do not represent quantity limitation, but can represent singular or plural. The terms "include", "contain", "have", and any variations thereof in the present application are intended to cover non-exclusive inclusion; for example, a process, method, system, product or device including a series of steps or modules (units) is not limited to the listed steps or units, but can also include steps or units not listed, or can also include other steps or units inherent to the process, method, product or device. The terms "connect", "connect", "couple" and similar terms in the present application are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. The term "multiple" in the present application means two or more. The association between the associated objects is described by the term "and / or", which means that there can be three relationships, for example, "A and / or B" can mean that A exists alone, A and B exist together, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects. The terms "first", "second", "third" and the like in the present application are merely to distinguish similar objects, and do not represent a specific order for the objects.
[0055] The traffic distribution method of the kubernetes cluster provided by the present application can be applied to the application environment as shown in Figure 2 . Figure 2is a schematic diagram of an application environment of a traffic allocation method of a kubernetes cluster according to an embodiment of the present application, as shown in Figure 2 When deploying an application in a kubernetes cluster, a pod and two services (service1 and service2) can be deployed in the kubernetes cluster through a CRD, and the access mode of the two services is LoadBalance, so two load balances (LoadBalance1 and LoadBalance2) are created, and service1 corresponds to LoadBalance1 and service2 corresponds to LoadBalance2; LoadBalance1 is set to be charged by traffic, and the default state of LoadBalance1 is stopped, and LoadBalance2 is set to be charged by fixed bandwidth; a plug-in is developed in the development management interface of the cluster, and after the load balance is deployed, the plug-in is notified of the ID of the successfully created load balance, so that the plug-in can monitor the traffic usage on the load balance; when the user resolves the DNS record, two records with the same domain name but different record values of the backend service are configured, one record points to LoadBalance1, and the other record points to LoadBalance2;
[0056] In the actual traffic usage process, the user accesses a specific application service through a domain name, and the plug-in monitors the traffic usage on the load balance by calling the API interface of the cloud service provider; the plug-in determines whether to switch the load balance according to the traffic usage of the load balance, so as to start or stop the corresponding load balance, for example, using the load balance charged by fixed bandwidth in the case of large traffic, and using the load balance charged by traffic in the case of small traffic.
[0057] Among them, kubernetes is a container orchestration framework, pod is the smallest management element in kubernetes, service defines a logical set of a group of pods and a strategy for accessing the pods, and CRD is a reusable Kubernetes API Server, which does not need to write additional API Server and can be used for custom API resources.
[0058] The embodiment provides a traffic allocation method of a kubernetes cluster, Figure 3 is a flowchart of a traffic allocation method of a kubernetes cluster according to the first embodiment of the present application, as shown in Figure 3 The flowchart includes the following steps:
[0059] Step S301, calling a cloud service provider interface to obtain the traffic usage of the load balance corresponding to each service;
[0060] Step S302, determining a target charging mode according to the usage; determining a current actual charging mode;
[0061] For example, the charging modes include a fixed bandwidth charging and a flow charging, and the process of determining the target charging mode includes: continuously determining a flow usage amount in a preset time period; determining the target charging mode as the fixed bandwidth charging when the flow usage amount is greater than or equal to a preset threshold; and determining the target charging mode as the flow charging when the flow usage amount is less than the preset threshold.
[0062] Step S303: enabling the load balancing corresponding to the target charging mode when the current actual charging mode is not the target charging mode.
[0063] Step S304: disabling the remaining load balancings when the load balancing is enabled.
[0064] As a preferred embodiment, the remaining load balancings can be disabled after the load balancing corresponding to the target charging mode is enabled, for example, Figure 4 is a schematic diagram of switching load balancing according to the first embodiment of the present application, as shown in Figure 4 the original load balancing is kept in use, the load balancing corresponding to the target charging mode is enabled, and then the original load balancing is closed, so as to ensure that the service is not interrupted; or in other embodiments, the remaining load balancings can be disabled at the same time when the load balancing corresponding to the target charging mode is enabled, for example, Figure 5 is a schematic diagram of switching load balancing according to the second embodiment of the present application, as shown in Figure 5 the original load balancing is closed and the load balancing corresponding to the target charging mode is enabled at the same time, and the purpose of service interruption can also be achieved.
[0065] Through steps S301 to S304, compared with the prior art, in the process of changing the load balancing, the load balancing faces the problem of short-term service unavailability, the embodiment analyzes the problem, because in the related art, there is only one load balancing, when the load balancing switches the charging mode, the previous charging mode must be closed first, and then the other charging mode is started, thereby causing the load balancing to face the problem of short-term service unavailability, therefore, in the embodiment, multiple access modes for load balancing services are deployed, and the embodiment disables the remaining load balancing only when the target charging mode corresponding to the load balancing is enabled, therefore, at any time, at least one load balancing is available, and in the embodiment, the addresses of multiple load balancers are configured to use the same domain name, therefore, when a user accesses an application service through a domain name, the domain name corresponds to multiple resolution records, and then the polling mechanism of DNS is used, when one load balancing cannot be accessed, the service is accessed through another load balancing that can be accessed, therefore, the service does not appear to be interrupted, thereby solving the problem that in the related art, in the process of changing the load balancing, the load balancing faces the problem of short-term service unavailability, and improving the user experience.
[0066] In addition, in the embodiment, most of the time, only one load balancing is running, and the remaining load balancers are in a disabled state, and the load balancing in the disabled state is free of charge, at the same time, the plug-in switches the load balancing according to the traffic usage of the load balancing, so as to reduce the cloud cost, therefore, without changing the use of the user, the embodiment not only solves the problem that the load balancing appears to be short-term service unavailable, but also reduces the cloud cost of the user using the load balancing of kubernetes.
[0067] The embodiment also provides a traffic distribution method of a kubernetes cluster, which can also achieve the above purposes and effects, Figure 6 is a flowchart of the traffic distribution method of the kubernetes cluster according to the second embodiment of the present application, as Figure 6 shown, the flow includes the following steps:
[0068] Step S601, determining a target charging mode of a time period in which a current time is located according to a preset correspondence relationship between the time period and the charging mode; determining a current actual charging mode;
[0069] For example, the charging mode includes fixed bandwidth charging and traffic charging, and the preset process of the correspondence relationship between the time period and the charging mode includes: calling a cloud service provider interface to obtain traffic usage of load balancing corresponding to each service; determining a peak time period and a valley time period of the traffic usage, and determining the correspondence relationship between the time period and the charging mode, wherein the charging mode of the peak time period is the fixed bandwidth charging, and the charging mode of the valley time period is the traffic charging;
[0070] Step S602, in the case that the current actual charging mode is not the target charging mode, enabling the load balancing corresponding to the target charging mode;
[0071] Step S603, in the case that the load balancing is enabled, disabling the remaining load balancings.
[0072] Through steps S601 to S603, the embodiment is applicable to the case that the peak period and the valley period of traffic usage are relatively obvious, the embodiment analyzes the peak period and the valley period of traffic usage according to the collected traffic data of the cloud service provider, and presets the correspondence between the time period and the charging mode, so that when performing specific traffic control, it is not necessary to monitor the load balancing and constantly determine the traffic usage amount in the nearest preset time period, and it is only necessary to determine the target charging mode of the time period in which the current time is located according to the preset correspondence between the time period and the charging mode, thereby saving a large amount of running resources of the system.
[0073] The embodiment of the application further provides a traffic distribution system of a kubernetes cluster, the kubernetes cluster is deployed with a pod and a plurality of services, load balancings corresponding to each service correspond to different charging modes one by one, addresses of the plurality of load balancings use a same domain name, Figure 7 is a structural block diagram of the traffic distribution system of the kubernetes cluster according to the third embodiment of the application, as Figure 7 shown, the system comprises an acquisition module 701, a determination module 702, an enabling module 703 and a disabling module 704, wherein:
[0074] The acquisition module 701 is configured to call a cloud service provider interface to acquire traffic usage of load balancings corresponding to each service;
[0075] The determination module 702 is configured to determine a target charging mode and a current actual charging mode according to the usage;
[0076] The enabling module 703 is configured to enable a load balancing corresponding to the target charging mode in the case that the current actual charging mode is not the target charging mode;
[0077] The disabling module 704 is configured to disable the remaining load balancings in the case that the load balancing is enabled.
[0078] In some embodiments, the charging mode comprises fixed-bandwidth charging and traffic charging, and the process of determining the target charging mode according to the usage comprises:
[0079] determining a traffic usage amount in a preset time period;
[0080] In a case where the traffic usage is greater than or equal to the preset threshold, the target charging mode is determined as charging by fixed bandwidth; and in a case where the traffic usage is less than the preset threshold, the target charging mode is determined as charging by traffic.
[0081] The embodiments of the present application further provide another traffic distribution system of a kubernetes cluster, the kubernetes cluster deploying a pod and a plurality of services, each service corresponding to a load balancing corresponding to a different charging mode, addresses of the plurality of load balancings using a same domain name, Figure 8 is a structural block diagram of the traffic distribution system of the kubernetes cluster according to the fourth embodiment of the present application, as shown in the figure, the system comprises a determination module 801, an enabling module 802 and a disabling module 803, wherein: Figure 8
[0082] The determination module 801 is configured to determine a target charging mode of a time period in which a current time is located according to a preset correspondence between time periods and charging modes; and determine a current actual charging mode.
[0083] The enabling module 802 is configured to enable a load balancing corresponding to the target charging mode in a case where the current actual charging mode is not the target charging mode.
[0084] The disabling module 803 is configured to disable the remaining load balancings in a case where the load balancing is enabled.
[0085] In some embodiments, the charging mode comprises charging by fixed bandwidth and charging by traffic, and the preset process of the correspondence between time periods and charging modes comprises: calling a cloud service provider interface to obtain traffic usage of the load balancing corresponding to each service; determining a peak time period and a valley time period of the traffic usage, and determining the correspondence between time periods and charging modes, wherein the charging mode of the peak time period is charging by fixed bandwidth, and the charging mode of the valley time period is charging by traffic.
[0086] In addition, in combination with the traffic distribution method of the kubernetes cluster in the above embodiments, the embodiments of the present application can provide a storage medium for implementation. The storage medium stores a computer program; the computer program is executed by a processor to implement any one of the traffic distribution methods of the kubernetes cluster in the above embodiments.
[0087] In one embodiment, a computer device is provided, which can be a terminal. The computer device comprises a processor, a memory, a network interface, a display screen and an input device connected through a system bus. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is configured to communicate with external terminals through network connections. The computer program is executed by the processor to implement a traffic allocation method for a kubernetes cluster. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the housing of the computer device, or an external keyboard, touchpad or mouse, etc.
[0088] In one embodiment, Figure 9 is a schematic diagram of the internal structure of an electronic device according to an embodiment of the present application, as Figure 9 shown, an electronic device is provided, which can be a server, and the internal structure diagram thereof can be as Figure 9 shown. The electronic device comprises a processor, a network interface, an internal memory and a non-volatile memory connected through an internal bus, wherein the non-volatile memory stores an operating system, a computer program and a database. The processor is configured to provide computing and control capabilities, the network interface is configured to communicate with external terminals through network connections, the internal memory is configured to provide an environment for running the operating system and the computer program, the computer program is executed by the processor to implement a traffic allocation method for a kubernetes cluster, and the database is configured to store data.
[0089] Those skilled in the art can understand that Figure 9 the structure shown in the above embodiment is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. The specific electronic device can comprise more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0090] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods 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 above-mentioned embodiment methods. Any reference to memory, storage, database or other medium used in the embodiments provided in the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0091] Those skilled in the art should understand that each technical feature of the above-mentioned embodiments can be combined arbitrarily, and in order to make the description simple, not all possible combinations of each technical feature in the above-mentioned embodiments are described, however, as long as the combination of these technical features does not exist contradictory, it should be considered as the scope of the present application.
[0092] The above-mentioned embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the patent. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the scope of the present application. Therefore, the scope of protection of the patent of the present application should be subject to the appended claims.
Claims
1. A method for traffic distribution of a kubernetes cluster, characterized in that, The kubernetes cluster is deployed with a pod and multiple services, each service corresponding to a load balancing corresponding to a different charging mode. When DNS resolution records, two records with the same domain name but different record values of the backend service are configured, one record points to load balancing 1, and one record points to load balancing 2. The load balancing 1 is charged by traffic, and the load balancing 2 is charged by fixed bandwidth. The same domain name is used for the addresses of multiple load balancers. The method comprises: Calling a cloud service provider interface to obtain the traffic usage of each service corresponding to the load balancing; According to the usage, determine the target charging mode; determine the current actual charging mode; In the case where the current actual charging mode is not the target charging mode, enable the load balancing corresponding to the target charging mode; In the case where the load balancing is enabled, the remaining load balancing is disabled, and the remaining load balancing includes the original load balancing.
2. The method of claim 1, wherein, The charging mode includes charging by fixed bandwidth and charging by traffic. The process of determining the target charging mode according to the usage comprises: Determine the traffic usage in a preset time period; In the case where the traffic usage is greater than or equal to a preset threshold, determine the target charging mode as charging by fixed bandwidth; in the case where the traffic usage is less than the preset threshold, determine the target charging mode as charging by traffic.
3. A method for traffic distribution of a kubernetes cluster, characterized in that, The kubernetes cluster is deployed with a pod and multiple services, each service corresponding to a load balancing corresponding to a different charging mode. When DNS resolution records, two records with the same domain name but different record values of the backend service are configured, one record points to load balancing 1, and one record points to load balancing 2. The load balancing 1 is charged by traffic, and the load balancing 2 is charged by fixed bandwidth. The same domain name is used for the addresses of multiple load balancers. The method comprises: According to the correspondence between the preset period and the charging mode, determine the target charging mode of the period in which the current time is located; determine the current actual charging mode; In the case where the current actual charging mode is not the target charging mode, enable the load balancing corresponding to the target charging mode; In the case where the load balancing is enabled, the remaining load balancing is disabled, and the remaining load balancing includes the original load balancing.
4. The method of claim 3, wherein, The charging mode includes charging by fixed bandwidth and charging by traffic. The preset process of the correspondence between the period and the charging mode comprises: Calling a cloud service provider interface to obtain the traffic usage of each service corresponding to the load balancing; Determine the peak period and the valley period of traffic usage, and determine the correspondence between the period and the charging mode, wherein the charging mode of the peak period is charging by fixed bandwidth, and the charging mode of the valley period is charging by traffic. 5.A traffic allocation system of a kubernetes cluster, characterized in that, A pod and multiple services are deployed in a kubernetes cluster, each service corresponds to a load balancing corresponding to a different charging mode, when DNS resolution records, two records with the same domain name but different record values of the backend service are configured, one record points to load balancing 1, and one record points to load balancing 2, the load balancing 1 charges according to traffic, and the load balancing 2 charges according to fixed bandwidth, so as to realize that the addresses of multiple load balancers use the same domain name, and the system comprises: The acquisition module is configured to call a cloud service provider interface to acquire traffic usage of each service corresponding to the load balancing. The determination module is configured to determine a target charging mode according to the usage, and determine a current actual charging mode. The enabling module is configured to enable the load balancing corresponding to the target charging mode in the case that the current actual charging mode is not the target charging mode. The disabling module is configured to disable the remaining load balancers in the case that the load balancing is enabled, and the remaining load balancers include the original load balancing.
6. The system of claim 5, wherein, The charging mode includes charging according to fixed bandwidth and charging according to traffic, and the process of determining the target charging mode according to the usage includes: Determine the traffic usage in a preset time period. In the case that the traffic usage is greater than or equal to a preset threshold, the target charging mode is determined to be charging according to fixed bandwidth; in the case that the traffic usage is less than the preset threshold, the target charging mode is determined to be charging according to traffic.
7. A traffic allocation system of a kubernetes cluster, characterized in that, A pod and multiple services are deployed in a kubernetes cluster, each service corresponds to a load balancing corresponding to a different charging mode, when DNS resolution records, two records with the same domain name but different record values of the backend service are configured, one record points to load balancing 1, and one record points to load balancing 2, the load balancing 1 charges according to traffic, and the load balancing 2 charges according to fixed bandwidth, so as to realize that the addresses of multiple load balancers use the same domain name, and the system comprises: The determination module is configured to determine a target charging mode according to a preset correspondence between a time period and a charging mode, and determine a current actual charging mode. The enabling module is configured to enable the load balancing corresponding to the target charging mode in the case that the current actual charging mode is not the target charging mode. The disabling module is configured to disable the remaining load balancers in the case that the load balancing is enabled, and the remaining load balancers include the original load balancing.
8. The system of claim 7, wherein, The charging mode includes charging according to fixed bandwidth and charging according to traffic, and the preset process of the correspondence between the time period and the charging mode includes: The acquisition module is configured to call a cloud service provider interface to acquire traffic usage of each service corresponding to the load balancing. Determine the peak period and the valley period of traffic usage, and determine the correspondence between the time period and the charging mode, wherein the charging mode of the peak period is charging according to fixed bandwidth, and the charging mode of the valley period is charging according to traffic. 9.An electronic device comprising a memory and a processor, the electronic device characterized by, The memory stores a computer program, and the processor is configured to run the computer program to execute the traffic distribution method of the kubernetes cluster in any one of claims 1 to 4.
10. A storage medium, characterized by The storage medium stores a computer program, and the computer program is configured to execute the traffic distribution method of the kubernetes cluster in any one of claims 1 to 4 when running.
Citation Information
Patent Citations
Load balancing method and device based on time adjustment
CN107241380A
Data processing method and device
CN110209492A
Flow processing method and device, computer equipment and storage medium
CN111464602A
Disaster recovery system and method for multiple data centers, computer equipment and medium
CN113242299A