Kubernetes cluster pod traffic visualization method, system and device
The Kubernetes cluster pod traffic visualization method dynamically adjusts pod replicas based on real-time traffic data, addressing inefficiencies in existing TCP-centric monitoring and optimizing resource utilization across TCP and non-TCP scenarios.
Patent Information
- Application Number
- CN202411230977.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2024-12-20
AI Technical Summary
Existing Kubernetes cluster monitoring technologies are limited to TCP traffic monitoring and do not efficiently handle non-TCP scenarios such as UDP, and the number of containers cannot be adjusted according to real-time traffic demands, leading to inefficient resource utilization.
A Kubernetes cluster pod traffic visualization method that includes deploying central computing, graphic display, and traffic collection programs, dynamically adjusting pod replicas based on traffic data, and visualizing pod traffic data, applicable to both TCP and non-TCP scenarios.
Enables real-time monitoring and dynamic adjustment of pod replicas to optimize resource utilization, supporting both TCP and non-TCP traffic, and providing graphical visualization for maintenance personnel.
Smart Images

Figure CN119172269A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of pod traffic management, and in particular to a Kubernetes cluster pod traffic visualization method, system and device. Background Art
[0002] Currently, in the Kubernetes field, container traffic is monitored by collecting the TCP traffic of the container and recording the source information of the TCP traffic, including the source IP address and source port. In practical applications, the existing container traffic monitoring methods have the following shortcomings: 1. They are not suitable for non-TCP traffic access scenarios such as UDP scenarios; 2. The number of containers cannot be adjusted according to the real-time status of the container traffic, and the cluster resource utilization is low.
[0003] Therefore, how to provide a container traffic monitoring method that has wider applicability and can improve cluster resource utilization has become a technical problem that needs to be solved urgently. Summary of the invention
[0004] In view of this, in order to overcome the deficiencies of the prior art, the present invention aims to provide a method and a system.
[0005] According to a first aspect of the present invention, a Kubernetes cluster pod traffic visualization method is provided, the method comprising:
[0006] Deploy central computing programs, graphic display programs, and multiple traffic collection programs in the Kubernetes cluster;
[0007] Collect pod data of the node through the traffic collection program, and send the collected pod data to the central computer program;
[0008] The collected pod data is written into the database through a central computer program, and the number of pod replicas is dynamically adjusted according to the pod traffic data when the pod data is written into the database;
[0009] The pod data is obtained from the database through a graphic display program, and the pod data traffic is visualized based on the obtained pod data.
[0010] Preferably, in the kubernetes cluster pod traffic visualization method of the present invention, multiple traffic collection programs are deployed one-to-one on each node of the kubernetes cluster.
[0011] Preferably, the kubernetes cluster pod traffic visualization method of the present invention collects pod data of the node through a traffic collection program, including: when the network type of the pod is a host network, configuring iptables rules on the host through the port exposed by the pod and recording the traffic data of accessing the pod, and sending the recorded traffic data to the traffic collection program.
[0012] Preferably, the kubernetes cluster pod traffic visualization method of the present invention collects pod data of the node through a traffic collection program, including: when the network type of the pod is a container network, reading the traffic data on the corresponding virtual network card on the container network through the traffic collection program.
[0013] Preferably, in the kubernetes cluster pod traffic visualization method of the present invention, the pod data includes: pod name, pod label and pod traffic data.
[0014] Preferably, in the kubernetes cluster pod traffic visualization method of the present invention, the pod label includes the name of the service to which the pod belongs, and pods belonging to the same service have the same pod label.
[0015] Preferably, the kubernetes cluster pod traffic visualization method of the present invention writes the collected pod data into a database through a central computer program, including: before the central computer program writes the collected pod data into the database, adding the pod traffic data of pods with the same pod label, and writing the added pod traffic data into the database.
[0016] Preferably, the Kubernetes cluster pod traffic visualization method of the present invention dynamically adjusts the number of pod copies according to the pod traffic data when writing the pod data into the database, including: setting a threshold for the traffic data of the service, when the pod data traffic of the corresponding service collected by the central computer program exceeds the set threshold, requesting the Kubernetes API server to increase the number of pod copies of the corresponding service, when the pod data traffic of the corresponding service collected by the central computer program is lower than the set threshold, requesting the Kubernetes API server to reduce the number of pod copies of the corresponding service.
[0017] According to a second aspect of the present invention, a Kubernetes cluster pod traffic visualization system is provided, the system includes a visualization server, and the visualization server is used to: deploy a central computing program, a graphic display program, and multiple traffic collection programs in the Kubernetes cluster; collect pod data of the node through the traffic collection program, and send the collected pod data to the central computer program; write the collected pod data into a database through the central computer program, and dynamically adjust the number of pod copies according to the pod traffic data when writing the pod data into the database; obtain the pod data from the database through the graphic display program, and visualize the pod data traffic according to the obtained pod data.
[0018] According to a third aspect of the present invention, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect of the present invention when executing the program.
[0019] The Kubernetes cluster pod traffic visualization method, system and device of the present invention can record the traffic data processed by each pod in real time in the Kubernetes cluster, which is used for subsequent elastic increase or decrease in the number of pods. When the service processing traffic is too large, the number of service pods is automatically increased to share the processing requests. When the service processing traffic is too low, the service pod data is automatically reduced, thereby saving cluster resources, improving resource utilization, and realizing automatic expansion and contraction. At the same time, the traffic data of the pod is displayed to the user for viewing, and the operation and maintenance personnel can view the current and historical processed traffic of each service through a graphical program. It is no longer limited to TCP traffic monitoring scenarios, but is also applicable to non-TCP access scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0021] Figure 1 This is an example diagram of the architecture of a Kubernetes cluster pod traffic visualization system according to an embodiment of the present invention;
[0022] Figure 2 A flowchart of a kubernetes cluster pod traffic visualization method according to an embodiment of the present invention;
[0023] Figure 3This is an example diagram of deploying a central computing program, a graphic display program, and multiple traffic collection programs in a Kubernetes cluster according to the method of this embodiment;
[0024] Figure 4 This is an example diagram of dynamically adjusting the number of pod replicas according to the method of an embodiment of the present invention;
[0025] Figure 5 This is an example diagram of visualizing pod data traffic according to the method of an embodiment of the present invention;
[0026] Figure 6 A schematic diagram of the structure of the device provided by the present invention. DETAILED DESCRIPTION
[0027] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0028] It should be noted that the following embodiments and features in the embodiments may be combined with each other in the absence of conflict; and, based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without making any creative work are within the scope of protection of the present disclosure.
[0029] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein may be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present disclosure, it should be understood by those skilled in the art that an aspect described herein may be implemented independently of any other aspect, and two or more of these aspects may be combined in various ways. For example, any number of aspects described herein may be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein may be used to implement this device and / or practice this method.
[0030] Figure 1 FIG. 1 is an example diagram of the architecture of a Kubernetes cluster pod traffic visualization system according to an embodiment of the present invention. Figure 1 As shown, the system may include a visualization server 101, a communication network 102 and / or one or more visualization clients 103. Figure 1 The example shown is a plurality of visualization clients 103 .
[0031] The visualization server 101 can be any appropriate server for storing information, data, programs and / or any other suitable type of content. In some embodiments, the visualization server 101 can perform appropriate functions. For example, in some embodiments, the visualization server 101 can be used to visualize the pod traffic of the kubernetes cluster. As an optional example, in some embodiments, the visualization server 101 can be used to visualize the pod traffic of the kubernetes cluster by deploying a central computing program, a graphic display program, and multiple traffic collection programs. For example, the visualization server 101 can be used to: deploy a central computing program, a graphic display program, and multiple traffic collection programs in a kubernetes cluster; collect pod data of the node through the traffic collection program, and send the collected pod data to the central computer program; write the collected pod data to the database through the central computer program, and dynamically adjust the number of pod copies according to the pod traffic data when writing the pod data to the database; obtain pod data from the database through a graphic display program, and visualize the pod data traffic according to the obtained pod data.
[0032] As another example, in some embodiments, the visualization server 101 may send the kubernetes cluster pod traffic visualization method to the visualization client 103 for user use based on the request of the visualization client 103 .
[0033] As an optional example, in some embodiments, the visualization client 103 is used to provide a visualization interface, which is used to receive a user's selection input operation for visualizing the Kubernetes cluster pod traffic, and, in response to the selection input operation, obtain a visualization interface corresponding to the option selected by the selection input operation from the visualization server 101 and display the visualization interface, wherein the visualization interface at least displays information for visualizing the Kubernetes cluster pod traffic and operation options for visualizing the information for visualizing the Kubernetes cluster pod traffic.
[0034] In some embodiments, the communication network 102 can be any suitable combination of one or more wired and / or wireless networks. For example, the communication network 102 can include any one or more of the following: the Internet, an intranet, a wide area network (WAN), a local area network (LAN), a wireless network, a digital subscriber line (DSL) network, a frame relay network, an asynchronous transfer mode (ATM) network, a virtual private network (VPN), and / or any other suitable communication network. The visualization client 103 can be connected to the communication network 102 via one or more communication links (e.g., communication link 104), and the communication network 102 can be linked to the visualization server 101 via one or more communication links (e.g., communication link 105). The communication link can be any communication link suitable for transmitting data between the visualization client 103 and the visualization server 101, such as a network link, a dial-up link, a wireless link, a hard-wired link, any other suitable communication link, or any suitable combination of such links.
[0035] The visualization client 103 may include any one or more clients that present an interface related to visualization of Kubernetes cluster pod traffic in an appropriate form for user use and operation. In some embodiments, the visualization client 103 may include any suitable type of device. For example, in some embodiments, the visualization client 103 may include a mobile device, a tablet computer, a laptop computer, a desktop computer, and / or any other suitable type of client device.
[0036] Although the visualization server 101 is illustrated as one device, in some embodiments, any suitable number of devices may be used to perform the functions performed by the visualization server 101. For example, in some embodiments, multiple devices may be used to implement the functions performed by the visualization server 101. Alternatively, the functions of the visualization server 101 may be implemented using a cloud service.
[0037] Based on the above system, an embodiment of the present invention provides a Kubernetes cluster pod traffic visualization method, which is described below through the following embodiments.
[0038] Figure 2 FIG. 1 is a flowchart of a method for visualizing pod traffic in a kubernetes cluster according to an embodiment of the present invention. Figure 2 As shown, the kubernetes cluster pod traffic visualization method of this embodiment can be executed on the visualization server, and the kubernetes cluster pod traffic visualization method includes the following steps:
[0039] Step S201: deploy a central computing program, a graphic display program, and multiple traffic collection programs in a kubernetes cluster.
[0040] Figure 3 This is an example diagram of deploying a central computing program, a graphic display program, and multiple traffic collection programs in a Kubernetes cluster according to the method of this embodiment. Figure 3 As shown, in this embodiment, multiple traffic collection programs are deployed one-to-one on each node of the kubernetes cluster.
[0041] Step S202: collect pod data of the node through the traffic collection program, and send the collected pod data to the central computer program.
[0042] As an optional example, in this embodiment, when the network type of the pod is the host network, the iptables rules are configured on the host through the port exposed by the pod and the traffic data accessing the pod is recorded, and the recorded traffic data is sent to the traffic collection program. In this embodiment, iptables is a packet filtering framework in the Linux kernel, which is used to set, maintain and check the IPv4 packet filtering rule table; iptables rules are instructions that define how packets should be processed. Rules can match specific packet features and specify corresponding actions.
[0043] When the network type of the pod is a container network, the traffic data on the corresponding virtual network card on the container network is read through the traffic collection program. It should be noted that in this embodiment, the pod data includes: pod name, pod label and pod traffic data. For example, the pod label includes the name of the service to which the pod belongs, and the pods belonging to the same service have the same pod label. It should be noted that the traffic collection program in this embodiment is no longer limited to TCP traffic for the collection of traffic data, and is also applicable to some non-TCP access scenarios such as UDP. TCP (Transmission Control Protocol) is a connection-oriented, reliable, byte-stream-based transport layer communication protocol. TCP traffic refers to a data stream transmitted through the TCP protocol. TCP traffic generally includes the process of establishing a connection, data transmission and connection termination. UDP (User Datagram Protocol) is a connectionless, unreliable transport layer communication protocol. In this embodiment, Kubernetes is an open source container orchestration platform for automatically deploying, scaling and managing containerized applications. A pod is a collection of one or a group of closely related containers that share storage / network and life cycle.
[0044] Step S203: The collected pod data is written into a database through a central computer program, and the number of pod replicas is dynamically adjusted according to the pod traffic data when the pod data is written into the database.
[0045] As an optional example, in this embodiment, before the central computer program writes the collected pod data into the database, the pod traffic data of the pods with the same pod label are added, and the added pod traffic data are written into the database.
[0046] As an optional example, when writing pod data to the database, a threshold is set for the traffic data of the service. When the pod data traffic of the corresponding service collected by the central computer program exceeds the set threshold, a request is made to the Kubernetes API server to increase the number of pod copies of the corresponding service. When the pod data traffic of the corresponding service collected by the central computer program is lower than the set threshold, a request is made to the Kubernetes API server to reduce the number of pod copies of the corresponding service. Figure 4 This is an example diagram of dynamically adjusting the number of pod replicas according to the method of an embodiment of the present invention, as shown in FIG. Figure 4 As shown in the figure, when the traffic corresponding to service 1 exceeds the set threshold, the central computer program expands the capacity of service 1 by requesting the kubernetes apiserver to add podC; when the traffic corresponding to service 2 is lower than the set threshold, the central computer program shrinks the capacity of service 2 by requesting the kubernetes apiserver to delete pod3.
[0047] Step S204: obtaining pod data from a database through a graphic display program, and visualizing pod data traffic based on the obtained pod data.
[0048] Figure 5 This is an example diagram of visualizing pod data traffic according to the method of an embodiment of the present invention, such as Figure 5 As shown, in actual applications, the operation and maintenance personnel access the graphic display program, read the corresponding pod traffic data from the database through the graphic display program, and display it to the operation and maintenance personnel in a graphical form.
[0049] According to the kubernetes cluster pod traffic visualization method and system of this embodiment, the traffic data processed by each pod in the kubernetes cluster can be recorded in real time for the subsequent elastic increase or decrease of the number of pods. When the service processing traffic is too large, the number of service pods is automatically increased to share the processing requests. When the service processing traffic is too low, the service pod data is automatically reduced to save cluster resources, improve resource utilization, and realize automatic expansion and contraction. At the same time, the pod traffic data is displayed to the user for viewing, and the operation and maintenance personnel can view the current and historical processing traffic of each service through the graphical program. It is no longer limited to TCP traffic monitoring scenarios, but is also applicable to non-TCP access scenarios.
[0050] like Figure 6 As shown, the present invention also provides a device, including a processor 310, a communication interface 320, a memory 330 for storing a processor executable computer program, and a communication bus 340. The processor 310, the communication interface 320, and the memory 330 communicate with each other through the communication bus 340. The processor 310 implements the above-mentioned kubernetes cluster pod traffic visualization method by running the executable computer program.
[0051] Among them, the computer program in the memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0052] The system embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected based on actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.
[0053] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.
[0054] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A Kubernetes cluster pod traffic visualization method, characterized in that: The method comprises: Deploy central computing programs, graphic display programs, and multiple traffic collection programs in the Kubernetes cluster; Collect pod data of the node through the traffic collection program, and send the collected pod data to the central computer program; The collected pod data is written into the database through a central computer program, and the number of pod replicas is dynamically adjusted according to the pod traffic data when the pod data is written into the database; The pod data is obtained from the database through a graphic display program, and the pod data traffic is visualized based on the obtained pod data.
2. The kubernetes cluster pod traffic visualization method according to claim 1, characterized in that: Multiple traffic collection programs are deployed one by one on each node of the Kubernetes cluster.
3. The kubernetes cluster pod traffic visualization method according to claim 1, characterized in that: The pod data of the node is collected through the traffic collection program, including: when the network type of the pod is the host network, the iptables rules are configured on the host through the port exposed by the pod and the traffic data accessing the pod is recorded, and the recorded traffic data is sent to the traffic collection program.
4. The kubernetes cluster pod traffic visualization method according to claim 1, characterized in that: The pod data of the node is collected through the traffic collection program, including: when the network type of the pod is the container network, the traffic data on the corresponding virtual network card on the container network is read through the traffic collection program.
5. The kubernetes cluster pod traffic visualization method according to claim 1, characterized in that: Pod data includes: pod name, pod label, and pod traffic data.
6. The kubernetes cluster pod traffic visualization method according to claim 5, characterized in that: The pod label includes the name of the service to which the pod belongs. Pods belonging to the same service have the same pod label.
7. The kubernetes cluster pod traffic visualization method according to claim 1, characterized in that: Writing the collected pod data into a database through a central computer program includes: before the central computer program writes the collected pod data into the database, adding the pod flow data of pods with the same pod label, and writing the added pod flow data into the database.
8. The kubernetes cluster pod traffic visualization method according to claim 1, characterized in that: When writing pod data to the database, dynamically adjust the number of pod copies according to the pod traffic data, including: setting a threshold for the traffic data of the service, when the pod data traffic of the corresponding service collected by the central computer program exceeds the set threshold, request the kubernetes apiserver to increase the number of pod copies of the corresponding service, when the pod data traffic of the corresponding service collected by the central computer program is lower than the set threshold, request the kubernetes apiserver to reduce the number of pod copies of the corresponding service.
9. A kubernetes cluster pod traffic visualization system, characterized in that: The system includes a visualization server, which is used to: deploy a central computing program, a graphic display program, and multiple traffic collection programs in a kubernetes cluster; collect pod data of the node through the traffic collection program, and send the collected pod data to the central computer program; write the collected pod data into a database through the central computer program, and dynamically adjust the number of pod copies according to the pod traffic data when writing the pod data into the database; obtain the pod data from the database through the graphic display program, and visualize the pod data traffic according to the obtained pod data.
10. A computer device, characterized in that: The computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the method according to any one of claims 1 to 8 when executing the program.
