Resource status monitoring method, device and electronic equipment
By introducing a resource status monitoring server into the Kubernetes cluster to monitor and notify application resource object status changes, the problem of overburdening the interface server caused by polling is solved and cluster performance is improved.
Patent Information
- Application Number
- CN202011110131.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-16
- Publication Date
- 2024-10-08
- Estimated Expiration
- 2040-10-16
AI Technical Summary
In a Kubernetes cluster, applications usually use the method of polling the interface server to obtain resource status, which causes the interface server to be overburdened, which may cause response delays and affect cluster performance.
Provide a resource status monitoring method that receives data requests from applications through the resource status monitoring server, monitors the status of resource objects, and sends notification messages to applications when the status changes to the desired status, reducing dependence on the interface server and reducing cluster costs. operating pressure.
This method can effectively reduce the polling operation of the Kubernetes cluster interface server, provide reliable resource status notification, improve cluster performance, and reduce operating pressure.
Smart Images

Figure CN112346926B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of cloud computing technology, and more specifically, to a resource status monitoring method, device, equipment and medium. Background Art
[0002] Kubernetes, abbreviated as K8S, is a container-based cluster management platform. A Kubernetes cluster generally includes a master node (Master) and multiple computing nodes (Node) that communicate with the master node respectively. The master node is generally used to manage and control multiple computing nodes. As a workload node, the computing node contains the original application program directly deployed in the node and multiple container groups (Pod). Each container group encapsulates one or more containers (Container) for carrying the application program. Pod is the basic operation unit of Kubernetes and the smallest deployment unit that can be created, debugged, and managed.
[0003] Currently, when an application needs to obtain the status of resources in a Kubernetes cluster, it generally obtains the status of the resource through the cluster's interface server, namely, the apiserver. At the same time, resource objects in each node within the cluster also need to communicate through the interface server. Therefore, in a Kubernetes cluster, the interface server usually faces huge operating pressure. Among them, the apiserver is a system component of the Kubernetes cluster. It provides an http rest interface for adding, deleting, modifying, querying, and monitoring services for various resource objects in the Kubernetes cluster. It is the data bus and data center of the Kubernetes cluster.
[0004] However, currently when an application needs to obtain a specific state of resources in a Kubernetes cluster, it usually polls the interface server to obtain the specific state, which usually puts a huge burden on the interface server and may cause the interface server to delay response to data requests from other objects in the cluster, thereby indirectly affecting cluster performance. Summary of the invention
[0005] One purpose of the embodiments of the present disclosure is to provide a new technical solution for resource status monitoring.
[0006] According to a first aspect of the present disclosure, a resource status monitoring method is provided, which is applied to a resource status monitoring server of a Kubernetes cluster, and the method includes:
[0007] Receive a data request sent by an application to monitor the status of a resource object in the Kubernetes cluster, wherein the data request includes the application's expected status of the resource object;
[0008] In response to the data request, monitoring the status of the resource object;
[0009] When the state of the resource object is changed to the expected state, a notification message is sent to the application program indicating that the state of the resource object has been changed to the expected state.
[0010] Optionally, the monitoring the state of the resource object in response to the data request includes:
[0011] In response to the data request, generating a state object recording a state change of the resource object, wherein the state object includes identification information of the resource object and a real-time state of the resource object;
[0012] The status of the resource object is monitored according to the status object.
[0013] Optionally, monitoring the status of the resource object according to the status object includes:
[0014] Obtain the timeout duration corresponding to the resource object;
[0015] During the timeout period, the state of the resource object is monitored according to the state object.
[0016] Optionally, monitoring the state of the resource object according to the state object within the timeout period includes:
[0017] If the real-time state in the state object is updated to the expected state within the timeout period, the monitoring of the state of the resource object is terminated.
[0018] Optionally, the method updates the real-time status in the status object by the following steps:
[0019] Sending a data request to the interface server of the Kubernetes cluster to monitor the status of the resource object;
[0020] The real-time status in the status object is updated according to the status data for the resource object provided by the interface server.
[0021] Optionally, after the step of ending the monitoring of the state of the resource object, the method further includes:
[0022] The real-time status of the resource object is stored in a local cache area.
[0023] Optionally, the Kubernetes cluster includes multiple resource status monitoring servers;
[0024] The method further comprises:
[0025] The multiple resource status monitoring servers monitor the status of the resource object simultaneously, and when the status of the resource object changes to the expected status, the main resource status monitoring server among the multiple resource status monitoring servers sends a notification message to the target object that the status of the resource object has changed to the expected status.
[0026] Optionally, the master resource status monitoring server is determined by the multiple resource status monitoring servers based on a consensus algorithm.
[0027] According to a second aspect of the present disclosure, a resource status monitoring device is provided, which is applied to a resource status monitoring server of a Kubernetes cluster, including:
[0028] A data request receiving module, configured to receive a data request sent by an application program to monitor the status of a resource object in the Kubernetes cluster, wherein the data request includes the application program's expected status of the resource object;
[0029] A monitoring module, configured to monitor the status of the resource object in response to the data request;
[0030] The notification module is used to send a notification message to the application program indicating that the state of the resource object has changed to the expected state when the state of the resource object has changed to the expected state.
[0031] According to a third aspect of the present disclosure, there is further provided an electronic device, comprising the apparatus according to the second aspect; or,
[0032] The electronic device comprises:
[0033] A memory for storing executable instructions;
[0034] A processor is used to operate the electronic device to execute the method as described in any one of the first aspects under the control of the instructions.
[0035] According to a fourth aspect of the present disclosure, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores a computer program that can be read and executed by a computer, and the computer program is used to execute the method as described in any one of the first aspects when read and executed by the computer.
[0036] According to an embodiment of the present disclosure, when an application needs to obtain a certain expected state of a resource object in a Kubernetes cluster, it only needs to send a data request to the resource state monitoring server of the Kubernetes cluster to monitor the state of the resource object; thereafter, the server responds to the data request to monitor the state of the resource object, and when the state of the resource object changes to the expected state that the application expects to obtain, a corresponding notification message is sent to the application, and the application can easily obtain the state of the resource object. This method does not poll the interface server of the Kubernetes cluster, but the resource state monitoring server responds to the data request of the application to monitor the state of the resource object, which can not only provide reliable resource status to the application, but also reduce the operating pressure of the cluster and improve cluster performance.
[0037] Other features and advantages of the present disclosure will become apparent from the following detailed description of exemplary embodiments of the present disclosure with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0039] Figure 1 It is a flowchart of a resource status monitoring method according to an embodiment.
[0040] Figure 2 It is a processing diagram of a resource status monitoring method according to an embodiment.
[0041] Figure 3 It is a first structural diagram of resource status monitoring processing according to an embodiment.
[0042] Figure 4 It is a second structural diagram of resource status monitoring processing according to an embodiment.
[0043] Figure 5 It is a principle block diagram of a resource status monitoring device according to an embodiment.
[0044] Figure 6 is a schematic diagram of the hardware structure of an electronic device according to an embodiment. DETAILED DESCRIPTION
[0045] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present disclosure unless otherwise specifically stated.
[0046] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present disclosure, its application, or uses.
[0047] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered as part of the specification.
[0048] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not limiting. Therefore, other examples of the exemplary embodiments may have different values.
[0049] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0050] <Method Example>
[0051] Please see Figure 1 , which is a flow chart of a resource status monitoring method according to an embodiment. The resource status monitoring method provided in this embodiment can be applied to a resource status monitoring server of a Kubernetes cluster, and the server can be located in any node in the Kubernetes cluster. Figure 1 As shown, the method may include the following steps S1100-S1300, which are described in detail below.
[0052] Step S1100: receiving a data request sent by an application for monitoring the status of a resource object in the Kubernetes cluster, wherein the data request includes the application's expected status of the resource object.
[0053] In this embodiment, the application may be an application outside the Kubernetes cluster, that is, an external application, which may perform subsequent business processing when the state of the resource object of interest is changed to the expected state.
[0054] For example, the application can be an application in a management server used to uniformly manage clusters. The application can create a resource object in the Kubernetes cluster, for example, a container group, by calling the interface server of the Kubernetes cluster, i.e., apiserver, based on the received user trigger operation. After the application creates the container group, when the container group is created and changed to normal operation, i.e., when it enters the running state, the application sends a prompt message to the terminal device used by the user that the container group has been successfully created and is running normally.
[0055] In this embodiment, the resource object in the Kubernetes cluster can be an application (APP) in the Kubernetes cluster, for example, one or more resources such as a deployment (Deployment), a stateful replica set (StatefulSet), and a route (Ingress), a container group (pod), a container (container), a service (Service), and a replication controller (RC, Replication Controller).
[0056] In a specific implementation, when an application sends a data request for monitoring the status of a resource object to a resource status monitoring server, it may simultaneously send a data request for monitoring the status of multiple resource objects. For example, in one data request, it may simultaneously request monitoring of the status of container group 1, container group 2, and container group 3, and the request includes the expected status of container group 1, the expected status of container group 2, and the expected status of container group 3.
[0057] It should be noted that, in this embodiment, for the convenience of explanation, the resource object is taken as a container group, namely, Pod, for example.
[0058] After step S1100, step S1200 is executed to monitor the status of the resource object in response to the data request.
[0059] Please see Figure 2 , which is a processing diagram of a resource status monitoring method according to an embodiment. In a specific implementation, the monitoring of the status of the resource object in response to the data request includes: generating a status object recording the status change of the resource object in response to the data request, wherein the status object includes the identification information of the resource object and the real-time status of the resource object; and monitoring the status of the resource object according to the status object.
[0060] Specifically, after receiving a data request sent by an application, the resource status monitoring server can instantiate a status object for monitoring the resource object in the data request. For example, Figure 2 The Reflector() function shown instantiates a state object corresponding to the resource object, and the state object may include identification information of the resource object, real-time state of the resource object and other information.
[0061] After the resource status monitoring server instantiates the status object corresponding to the resource object, since the resource status monitoring server may monitor the status of multiple different resource objects at the same time, the resource status monitoring server can maintain a status change queue in its own local cache area and add the above status object to the queue, where the queue can be Figure 2 The DeltaFIFO queue shown may be a first-in-first-out queue for recording the state changes of resource objects. When the state of a resource object changes to a desired state, the resource state monitoring server sends a corresponding notification message to the application.
[0062] In a specific implementation, when an application sends a data request to a resource status monitoring server to monitor the status of a resource object, a timeout period can be set accordingly. Only when the application waits for the resource status monitoring server to provide a corresponding notification message within the timeout period, and when the waiting time exceeds the timeout period, the application can consider that the processing result of the data request is abnormal. At this time, the application can, according to the situation, either send a prompt message indicating that the status of the resource object is abnormal to the terminal device used by the user, or can send a data request to the resource status monitoring server again to monitor the status of the resource object.
[0063] That is, monitoring the state of the resource object according to the state object includes: obtaining a timeout duration corresponding to the resource object; and monitoring the state of the resource object according to the state object within the timeout duration.
[0064] In this embodiment, the timeout period can be obtained in the data request; of course, in a specific implementation, different timeout periods can also be preset for different resource objects, which is not specifically limited here.
[0065] In this embodiment, the monitoring of the state of the resource object according to the state object within the timeout period includes: if the real-time state in the state object is updated to the expected state within the timeout period, then ending the monitoring of the state of the resource object,
[0066] like Figure 2As shown, in this embodiment, for different resource objects, when the resource status monitoring server monitors the status of the resource object according to the instantiated status object, it can create different events accordingly. The event can be a creation event, i.e., Event:Create, an update event, i.e., Event:Update, and a deletion event, i.e., Event:Delete, and add the event to the processing queue, i.e., Workqueue, for the event processing framework, i.e. Figure 2 The processItem shown is used to process different events.
[0067] A creation event refers to an event that is created to monitor the status of a resource object in a data request sent by an application after the status object of the resource object in the data request is instantiated, that is, Event:Create. In this event, a timeout period is set, and the status of the resource object is monitored within the timeout period. If the status of the resource object, that is, the real-time status in its corresponding status object, changes to the expected status within the timeout period, a notification message is sent to the application.
[0068] In addition, for a creation event of a resource object, there are usually multiple corresponding update events. For example, when creating a container group, the container group usually corresponds to multiple states according to different stages of creation, for example, it may correspond to preprocessing completion state, creation success state, normal operation state and other states; in specific implementation, when the state of a resource object changes, the real-time state in the state object corresponding to the resource object can be updated according to the triggered update event, and when the real-time state changes to the expected state, the monitoring of the resource object is ended to avoid repeated sending of notification messages to the application.
[0069] In specific implementation, the resource status monitoring method of this embodiment updates the real-time status in the status object through the following steps: sending a data request to the interface server of the Kubernetes cluster to monitor the status of the resource object; and updating the real-time status in the status object according to the status data for the resource object provided by the interface server.
[0070] Specifically, different from the method of polling the interface server to obtain the real-time status of the resource object in the prior art, the method provided in this embodiment does not need to use polling when the real-time status of the resource object needs to be obtained. Instead, a data request for monitoring the status of the resource object is sent to the interface server. When the interface server receives the data request, a monitoring task is set to monitor the status of the resource object, and when the status of the resource object changes, the changed real-time status is sent to the resource monitoring server.
[0071] For example, when the interface server receives a data request for obtaining the real-time status of a resource object, the ListerWatcher() interface can be used to instantiate a monitoring object corresponding to the resource object; thereafter, the interface server adds the monitoring object to the monitoring task list (List) to monitor the status of the resource object; when the interface server monitors the change in the status of the resource object through the instantiated monitoring object, the watchHandler can be used to send the updated status of the resource object to the resource monitoring server in the form of a message, where ListerWatcher() is an interface function in the client-go development library of Kubernetes, which is used to continuously obtain incremental change information of resource objects, and watchHandler is a message handle used to transmit monitoring messages.
[0072] In this embodiment, when the interface server monitors that the state of the resource object has changed, the interface server can send the real-time state of the resource object to the interface server by calling the callback function corresponding to the data request.
[0073] Of course, when the interface server monitors that the state of the resource object has changed, other methods can also be used to send the state to the resource monitoring server, which will not be repeated here.
[0074] In addition, after the resource scheduling server monitors that the state of the resource object has changed to the expected state of the application and ends the monitoring of the state of the resource object, the state can also be stored in the local cache area, that is, after the step of ending the monitoring of the state of the resource object, the method also includes: storing the real-time state of the resource object in the local cache area.
[0075] After step S1200, step S1300 is executed, in which, when the state of the resource object is changed to the expected state, a notification message is sent to the application program indicating that the state of the resource object has been changed to the expected state.
[0076] Please see Figure 3 , which is a first structural diagram of resource status monitoring processing provided according to an embodiment. Figure 3 As shown, a resource status monitoring server can be set in the Kubernetes cluster, and the server can be any node server in the cluster. When the resource status monitoring server monitors that the state of the resource object has changed to the expected state of the application, a notification message that the state of the resource object has changed to the expected state can be sent to the application, so that the application can perform subsequent processing according to the notification message.
[0077] It should be noted that the Kubernetes cluster can include multiple resource status monitoring servers at the same time; the method also includes: the multiple resource status monitoring servers simultaneously monitor the status of the resource object, and when the status of the resource object changes to the expected state, the main resource status monitoring server among the multiple resource status monitoring servers sends a notification message to the target object that the status of the resource object has changed to the expected state.
[0078] Please see Figure 4 , which is a second structural diagram of resource status monitoring processing provided according to an embodiment. Specifically, in order to stably provide the status of monitored resource objects to the application, multiple resource status monitoring servers can be set in the Kubernetes cluster, such as Figure 4 The resource status monitoring servers 1, 2, ..., n are shown, and the multiple resource status monitoring servers can be located in multiple nodes of the Kubernetes cluster respectively; the multiple resource status monitoring servers can run simultaneously, and simultaneously respond to the data requests received and sent by the application for monitoring the resource objects in the Kubernetes cluster, and monitor the status of the resource objects, and cache the acquired status of the resource objects in their respective local cache areas; in addition, in order to ensure that only one resource status monitoring server provides status notification service to the application at the same time, the multiple resource status monitoring servers can be based on a consensus algorithm (Consensus Glgorithm), for example, the main resource status monitoring server can be selected based on the Raft protocol, for example, the resource status monitoring server 2 can be selected as the main resource status monitoring server, and at the same time, the main resource status monitoring server provides notification service to the application, wherein, in this embodiment, the consensus in the consensus algorithm refers to the consensus reached by multiple resource status monitoring servers on a task, even in the case of failure of some servers, network delay or network segmentation.
[0079] According to the above steps S4100-S4300, when the application needs to obtain a certain expected state of a resource object in the Kubernetes cluster, the method of this embodiment only needs to send a data request to the resource status monitoring server of the Kubernetes cluster to monitor the state of the resource object; after that, the server responds to the data request to monitor the state of the resource object, and when the state of the resource object changes to the expected state that the application expects to obtain, a corresponding notification message is sent to the application, and the application can easily obtain the state of the resource object. This method does not need to poll the interface server of the Kubernetes cluster, but the resource status monitoring server responds to the data request of the application to monitor the state of the resource object, which can not only provide reliable resource status to the application, but also reduce the operating pressure of the cluster and improve cluster performance.
[0080] <Device Example>
[0081] Corresponding to the above method embodiment, in this embodiment, a resource status monitoring device is also provided, which can be applied to a resource status monitoring server of a Kubernetes cluster, such as Figure 5 As shown, the device 5000 may include a data request receiving module 5100 , a monitoring module 5200 and a notification module 5300 .
[0082] The data request receiving module 5100 is used to receive a data request sent by an application to monitor the status of a resource object in the Kubernetes cluster, wherein the data request includes the application's expected status of the resource object.
[0083] The monitoring module 5200 is used to monitor the status of the resource object in response to the data request.
[0084] In one embodiment, when the monitoring module 5200 monitors the state of the resource object in response to the data request, it can be used to:
[0085] In response to the data request, generating a state object recording a state change of the resource object, wherein the state object includes identification information of the resource object and a real-time state of the resource object;
[0086] The status of the resource object is monitored according to the status object.
[0087] In one embodiment, when monitoring the status of the resource object according to the status object, the monitoring module 5200 can be used to:
[0088] Obtain the timeout duration corresponding to the resource object;
[0089] During the timeout period, the state of the resource object is monitored according to the state object.
[0090] In one embodiment, within the timeout period, when the monitoring module 5200 monitors the state of the resource object according to the state object, it can be used to:
[0091] If the real-time state in the state object is updated to the expected state within the timeout period, the monitoring of the state of the resource object is terminated.
[0092] In one embodiment, the apparatus 5000 further includes a status updating module, configured to:
[0093] Sending a data request to the interface server of the Kubernetes cluster to monitor the status of the resource object;
[0094] The real-time status in the status object is updated according to the status data for the resource object provided by the interface server.
[0095] In one embodiment, the device 5000 further includes a state storage module for storing the real-time state of the resource object in a local cache area after the monitoring module 5200 finishes monitoring the state of the resource object.
[0096] The notification module 5300 is used to send a notification message to the application program that the state of the resource object has changed to the expected state when the state of the resource object has changed to the expected state.
[0097] <Equipment Embodiment>
[0098] Corresponding to the above method embodiments, in this embodiment, an electronic device is also provided, which may include a resource status monitoring device 5000 according to any embodiment of the present disclosure, for implementing a resource status monitoring method according to any embodiment of the present disclosure.
[0099] like Figure 6 As shown, the electronic device 6000 may also include a processor 6200 and a memory 6100, wherein the memory 6100 is used to store executable instructions; the processor 6200 is used to run the electronic device according to the control of the instructions to execute the resource status monitoring method according to any embodiment of the present disclosure.
[0100] Each module of the above electronic device 6000 can be implemented by the processor 6200 running the instruction to execute the resource status monitoring method according to any embodiment of the present disclosure.
[0101] <Medium Example>
[0102] In this embodiment, a computer-readable storage medium is further provided, which stores a computer program that can be read and executed by a computer, and the computer program is used to execute the method described in any of the above embodiments of the present disclosure when read and executed by the computer.
[0103] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.
[0104] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the above. More specific examples (a non-exhaustive list) of computer-readable storage media include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the above. The computer-readable storage medium used herein is not to be interpreted as a transient signal itself, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.
[0105] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0106] The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. The computer-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect through the Internet). In some embodiments, by using the state information of the computer-readable program instructions to personalize an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), the electronic circuit may execute the computer-readable program instructions, thereby implementing various aspects of the present disclosure.
[0107] Various aspects of the present disclosure are described herein with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of boxes in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0108] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0109] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0110] The flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of an instruction, and the module, a program segment or a part of an instruction contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of the boxes in the block diagram and / or the flowchart can be implemented by a dedicated hardware-based system that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions. It is well known to those skilled in the art that it is equivalent to implement it by hardware, implement it by software, and implement it by combining software and hardware.
[0111] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The choice of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the marketplace, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein. The scope of the present disclosure is defined by the appended claims.
Claims
1. A resource status monitoring method, characterized in that: Resource status monitoring server for Kubernetes clusters, including: Receive a data request sent by an application to monitor the status of a resource object in the Kubernetes cluster, wherein the data request includes the application's expected status of the resource object; In response to the data request, monitoring the status of the resource object; When the state of the resource object is changed to the expected state, a notification message is sent to the application indicating that the state of the resource object has been changed to the expected state. Wherein, in response to the data request, monitoring the state of the resource object includes: A data request for monitoring the status of the resource object is sent to the interface server of the Kubernetes cluster; wherein, when the interface server receives the data request for monitoring the status of the resource object, the interface server sets a monitoring task to monitor the status of the resource object, and when the status of the resource object changes, the real-time status of the changed resource object is sent to the resource status monitoring server.
2. The method according to claim 1, characterized in that The step of monitoring the state of the resource object in response to the data request includes: In response to the data request, generating a state object recording a state change of the resource object, wherein the state object includes identification information of the resource object and a real-time state of the resource object; The status of the resource object is monitored according to the status object.
3. The method according to claim 2, characterized in that The monitoring the state of the resource object according to the state object includes: Obtain the timeout duration corresponding to the resource object; During the timeout period, the state of the resource object is monitored according to the state object.
4. The method according to claim 3, characterized in that The monitoring of the state of the resource object according to the state object within the timeout period includes: If the real-time state in the state object is updated to the expected state within the timeout period, the monitoring of the state of the resource object is terminated.
5. The method according to claim 4, characterized in that The method updates the real-time status in the status object by the following steps: Sending a data request to the interface server of the Kubernetes cluster to monitor the status of the resource object; The real-time status in the status object is updated according to the status data for the resource object provided by the interface server.
6. The method according to claim 4, characterized in that After the step of ending the monitoring of the state of the resource object, the method further includes: The real-time status of the resource object is stored in a local cache area.
7. The method according to claim 1, characterized in that The Kubernetes cluster includes multiple resource status monitoring servers; The method further comprises: The multiple resource status monitoring servers monitor the status of the resource object simultaneously, and when the status of the resource object changes to the expected status, the main resource status monitoring server among the multiple resource status monitoring servers sends a notification message to the target object that the status of the resource object has changed to the expected status.
8. The method according to claim 7, characterized in that The master resource status monitoring server is determined by the multiple resource status monitoring servers based on a consensus algorithm.
9. A resource status monitoring device, characterized in that: Resource status monitoring server for Kubernetes clusters, including: A data request receiving module, configured to receive a data request sent by an application program to monitor the status of a resource object in the Kubernetes cluster, wherein the data request includes the application program's expected status of the resource object; A monitoring module, configured to monitor the status of the resource object in response to the data request; a notification module, configured to send a notification message to the application program indicating that the state of the resource object has changed to the expected state when the state of the resource object has changed to the expected state; Status update module, used to: A data request for monitoring the status of the resource object is sent to the interface server of the Kubernetes cluster, wherein, when the interface server receives the data request from the status update module, sets a monitoring task to monitor the status of the resource object, and when the status of the resource object changes, sends the real-time status of the changed resource object to the monitoring module.
10. An electronic device, characterized in that: comprising the device of claim 9; or, The electronic device comprises: A memory for storing executable instructions; A processor is used to operate the electronic device to execute the method according to any one of claims 1-8 under the control of the instruction.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program that can be read and executed by a computer, and the computer program is used to execute the method according to any one of claims 1 to 8 when being read and executed by the computer.
