Kubernetes resource quota verification method and device and storage medium
By performing real-time quota verification of tenants' resource requests in Kubernetes cluster, the resource over-allocation problem is solved, and the flexibility and security of resource management are improved.
Patent Information
- Application Number
- CN202411428298.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-14
- Publication Date
- 2024-11-12
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The lack of real-time quota verification methods in the Kubernetes cluster when tenants create resources, resulting in the inability to effectively prevent resource over-allocation.
When receiving the resource request, the resource usage values of each namespace are obtained based on the namespace information, and the overall resource usage values of the tenant are accumulated, and the preset resource quota limit value is checked, the verification results are determined and feedback to Insulate the cluster to ensure that resource requests do not exceed quota limits.
Effectively prevent resource over-allocation, improve the granularity and flexibility of resource management, and ensure the safe and reasonable resource use in a multi-tenant environment.
Smart Images

Figure CN118939436A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a verification method, device, and storage medium for Kubernetes resource quotas. Background Art
[0002] Kubernetes is an open source container orchestration platform for automating the deployment, expansion, and management of containerized applications. With the rapid development of cloud computing technology, resource management in a multi-tenant environment is one of the key challenges facing cloud platforms. In the Kubernetes cluster, although the ResourceQuota mechanism is provided for resource quota management, it is mainly aimed at the entire namespace rather than the tenant level, which limits the granularity and flexibility of resource management. Therefore, since the relevant solutions lack the means to perform real-time quota verification when tenants create resources, it is impossible to effectively prevent the occurrence of resource over-allocation.
[0003] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0004] The present application provides a Kubernetes resource quota verification method, device, and storage medium, aiming to solve the problem that related solutions cannot effectively prevent resource over-allocation.
[0005] To achieve the above purpose, the present application provides a Kubernetes resource quota verification method, which is applied to the main cluster. The Kubernetes resource quota verification method includes the following steps: Upon receiving a resource request, determining attribute information in all namespaces according to the namespace information corresponding to the resource request; Acquire the resource usage value of each namespace according to the attribute information, and obtain the overall resource usage value of the current tenant by accumulating the resource usage value of each namespace; Obtaining a preset resource quota limit value, and verifying the resource request according to the resource quota limit value and the overall resource usage value; Determine the verification result and feed the verification result back to the management cluster.
[0006] In one embodiment, the step of obtaining a preset resource quota limit value and verifying the resource request according to the resource quota limit value and the overall resource usage value includes: Obtaining the preset resource quota limit value; Determine the target resource required by the resource request, and obtain the expected resource according to the sum of the target resource and the overall resource usage value; The expected resources are compared with the resource quota limit value of the current tenant to complete the verification process of the resource request.
[0007] In one embodiment, the step of determining the verification result and feeding back the verification result to the management cluster includes: When the expected resources are greater than the resource quota limit value, it is determined that the verification fails, and a verification result of the request error is fed back to the management cluster; When the expected resource is less than or equal to the resource quota limit value, it is determined that the verification is passed, and the target resource corresponding to the resource request is allocated to the corresponding tenant.
[0008] In one embodiment, before the step of determining the attribute information in all namespaces according to the namespace information corresponding to the resource request, the method further includes: After the managed cluster receives the resource request, the managed cluster sends the resource request to the main cluster; The main cluster transmits the resource request to the verification service to execute the step of determining the attribute information in all namespaces according to the namespace information corresponding to the resource request.
[0009] In one embodiment, the method comprises: Create a custom resource object, which records the resource quota limit value and resource usage value of the current tenant; When detecting that a tenant creates a resource object in the resource space, determining the resources to be used that are required to create the resource object; Determine remaining resources according to the custom resource object, and judge whether the resources to be used are exceeded according to the remaining resources; If the resources to be used are exceeded, the tenant's request to create an object in the resource space is rejected.
[0010] In one embodiment, the step of determining remaining resources according to the custom resource object includes: Obtain the resource quota limit value and the resource usage value recorded in the custom resource object; A difference between the resource quota limit value and the resource usage value is determined, and the difference is determined as the remaining resources.
[0011] In one embodiment, before the step of determining the attribute information in all namespaces according to the namespace information corresponding to the resource request when receiving the resource request, the step further includes: Creating a namespace resource object, wherein the attribute information in the namespace resource object stores a resource usage value; The overall resource usage value is obtained by detecting the attribute information of each namespace resource object.
[0012] In one embodiment, after the step of obtaining the overall resource usage value by detecting the attribute information of each namespace resource object, the method further includes: When the overall resource usage value exceeds the value of the tenant's custom resource object, the service priority of each verification request in the verification queue is determined; The verification requests in the verification queue are reordered according to the service priority, and the verification process is executed according to the ordered verification requests.
[0013] In addition, to achieve the above-mentioned purpose, the present application also provides a Kubernetes resource quota verification device, the Kubernetes resource quota verification device comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being configured to implement the steps of the Kubernetes resource quota verification method as described above.
[0014] In addition, to achieve the above-mentioned purpose, the present application also provides a storage medium, which is a computer-readable storage medium, and a computer program is stored on the computer-readable storage medium. When the computer program is executed by the processor, the steps of the Kubernetes resource quota verification method as described above are implemented.
[0015] The present application provides a verification method for Kubernetes resource quotas, a verification device and a storage medium for Kubernetes resource quotas. When a resource request is received, the attribute information in all namespaces is determined according to the namespace information corresponding to the resource request, and then the resource usage value of each namespace is obtained according to the attribute information, and the overall resource usage value of the current tenant is obtained by accumulating the resource usage value of each namespace, and then the preset resource quota limit value is obtained, and the resource request is verified according to the resource quota limit value and the overall resource usage value, and finally the verification result is determined, and the verification result is fed back to the managed cluster. The present application verifies the resource request by obtaining the resource usage value of the attribute information in the namespace, thereby effectively preventing the occurrence of resource over-allocation. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0018] Figure 1 This is a flow chart of the first embodiment of the verification method for Kubernetes resource quota in this application; Figure 2 This is a flow chart of resource quota control involved in the embodiment of the present application; Figure 3 This is a flow chart of the second embodiment of the method for verifying Kubernetes resource quotas in this application; Figure 4 This is a flow chart of the third embodiment of the method for verifying Kubernetes resource quotas in this application; Figure 5 This is a flow chart of a fourth embodiment of a method for verifying Kubernetes resource quotas in this application; Figure 6 This is a schematic diagram of the architecture of the hardware operating environment of the Kubernetes resource quota verification device involved in the embodiment of the present application.
[0019] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0020] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0021] In order to better understand the above technical solution, exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0022] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0023] The main solution of the present application is: upon receiving a resource request, determining attribute information in all namespaces according to the namespace information corresponding to the resource request; Acquire the resource usage value of each namespace according to the attribute information, and obtain the overall resource usage value of the current tenant by accumulating the resource usage value of each namespace; Obtaining a preset resource quota limit value, and verifying the resource request according to the resource quota limit value and the overall resource usage value; Determine the verification result and feed the verification result back to the management cluster.
[0024] Kubernetes is an open source container orchestration platform for automating the deployment, expansion, and management of containerized applications. With the rapid development of cloud computing technology, resource management in a multi-tenant environment is one of the key challenges facing cloud platforms. In the Kubernetes cluster, although the ResourceQuota mechanism is provided for resource quota management, it is mainly aimed at the entire namespace rather than the tenant level, which limits the granularity and flexibility of resource management. Therefore, since the relevant solutions lack the means to perform real-time quota verification when tenants create resources, it is impossible to effectively prevent the occurrence of resource over-allocation.
[0025] When receiving a resource request, the present application determines the attribute information in all namespaces according to the namespace information corresponding to the resource request, and then obtains the resource usage value of each namespace according to the attribute information, and obtains the overall resource usage value of the current tenant by accumulating the resource usage value of each namespace, and then obtains the preset resource quota limit value, verifies the resource request according to the resource quota limit value and the overall resource usage value, and finally determines the verification result, and feeds the verification result back to the managed cluster. The present application verifies the resource request by obtaining the resource usage value of the attribute information in the namespace, thereby effectively preventing the occurrence of resource over-allocation.
[0026] Embodiment 1 Please refer to Figure 1 In the first embodiment, the Kubernetes resource quota verification method includes the following steps: Step S10: when a resource request is received, attribute information in all namespaces is determined according to the namespace information corresponding to the resource request.
[0027] In this embodiment, the processing action is performed by the main cluster, and in the Kubernetes platform, the main cluster and the managed cluster are connected respectively. The resource request can be sent from the managed cluster to the main cluster, or it can be sent from a single user terminal to the main cluster. The main cluster is the Kubernetes cluster where the multi-tenant application system is located, and the managed cluster is an external cluster that is directly managed by the multi-tenant application system or connected to the multi-tenant application system in other ways. A deployment verification service is provided in the main cluster, and when the main cluster receives a resource request, the deployment verification service verifies the resource request. When the verification service detects a resource request, it will obtain the tenant information of the resource request, and then obtain the namespace information associated with the tenant information based on the tenant information, and retrieve the attribute information in all the namespace information. In addition, an access WebhooK is also provided in the main cluster, and the access WebhooK is used to collect changes in resource creation or update within the cluster. When a user creates resources such as Pods and Services in a namespace created by a tenant association, dynamic admission control is triggered and the request is sent to the verification service. The verification service then checks the tenant's resource usage to ensure that the resource usage does not exceed the hard resource limit customized by the tenant.
[0028] Optionally, in this embodiment, before the step of determining the attribute information in all namespaces according to the namespace information corresponding to the resource request, the step further includes: After the managed cluster receives the resource request, the managed cluster sends the resource request to the main cluster; the main cluster passes the resource request to the verification service to execute the step of determining attribute information in all namespaces according to the namespace information corresponding to the resource request.
[0029] Specifically, Figure 2 As shown, Figure 2 This is a flow chart of resource quota control involved in the implementation scheme of the present application. A verification service is also provided in the managed cluster and is connected to the verification service of the main cluster. When a user creates a resource under a namespace created by tenant association, a resource request is sent to the managed cluster. After receiving the resource request, the managed cluster first passes the resource request to the verification service. The verification service of the managed cluster sends the resource request to the verification service of the main cluster, so that the verification service of the main cluster executes the step of determining the attribute information in all namespaces according to the namespace information corresponding to the resource request.
[0030] Step S20: acquiring the resource usage value of each namespace according to the attribute information, and obtaining the overall resource usage value of the current tenant by accumulating the resource usage value of each namespace.
[0031] In this embodiment, the attribute information stores a value that changes according to the resource usage of the namespace, and by obtaining this value in the attribute information, the resource usage value of the namespace can be obtained. In this way, the resource usage values of all namespaces are obtained, and the overall resource usage value of the current tenant is calculated by accumulating the resource usage of each namespace.
[0032] Specifically, the value of the resource situation recorded in the attribute information can be detected in real time by a detection tool to detect the resource situation of the namespace, and then obtain the resource usage value, and update the value of the resource situation recorded in the attribute information. It can also be obtained through the namespace-level ResourceQuota object provided by Kubernetes for recording resource usage. The ResourceQuota object stores the resource usage value in real time. Kubernetes provides an API interface for users to query the various types of resource usage stored in the ResourceQuota object, so that the resource usage value can be obtained. It can be understood that the various attributes of the ResourceQuota object refer to different resource types, such as CPU, memory, etc.
[0033] Step S30: Obtain a preset resource quota limit value, and verify the resource request according to the resource quota limit value and the overall resource usage value.
[0034] In this embodiment, the resource quota limit value of the namespace is preset, and the resource quota limit value can be obtained by obtaining the attribute of an object in the namespace. Then the verification service verifies whether the resource request meets the requirements based on the obtained resource quota limit value and the overall resource usage value.
[0035] Specifically, the resource quota limit value can be obtained according to the target attribute in the ResourceQuota object in each namespace, wherein the ResourceQuota object is an object used to limit the resource usage in the namespace. When creating a tenant, the ResourceQuota object can configure the resource upper limit of each tenant, for example, the maximum CPU usage and the maximum memory usage, so as to determine the resource quota limit value. The ResourceQuota object allows administrators to set the upper limit of resource usage for each namespace, thereby helping to control resource consumption and prevent resource abuse. The ResourceQuota object can limit the resource usage within the namespace, including but not limited to CPU, memory, storage volume, etc. By setting the ResourceQuota object, it can be ensured that the application in each namespace does not consume resources excessively, and it also provides a guarantee for resource allocation in a multi-tenant environment. The ResourceQuota object can limit resources and objects, define the maximum amount of resources that can be used in the namespace to complete resource restrictions; define the maximum number of objects that can be created in the namespace to complete object restrictions; in addition, the quota range of the ResourceQuota object can be applied to different types of resources, such as CPU, memory, storage volume, etc.
[0036] Optionally, in this embodiment, step S30 includes: Obtain the preset resource quota limit value; determine the target resource required for the resource request, and obtain the expected resource based on the sum of the target resource and the overall resource usage value; compare the expected resource with the resource quota limit value of the current tenant to complete the verification process of the resource request.
[0037] Specifically, the preset resource quota limit value is first obtained in the target object, and then the Kubernetes resources required for this request, namely the target resources, and the current tenant's overall resource usage value are accumulated to obtain the expected resources, which are then compared with the current tenant's resource quota limit value to complete the verification process of the resource request.
[0038] Step S40: Determine the verification result, and feed the verification result back to the management cluster.
[0039] In this embodiment, after the verification service completes the verification of the resource request, the main cluster obtains the verification result and feeds the verification result back to the managed cluster. The verification result includes verification passed and verification failed. Different verification results will cause the main cluster to perform corresponding actions. If the verification passes, the next step is entered, which is mainly to allocate resources and create objects in the corresponding request, such as workloads. If it fails, the reason for failure is returned and the next step is refused. At this time, the user's request to create an object will be interrupted, such as application deployment failure.
[0040] Optionally, in this embodiment, step S30 includes: When the expected resources are greater than the resource quota limit value, the verification is determined to have failed, and the verification result of the request error is fed back to the managed cluster; when the expected resources are less than or equal to the resource quota limit value, the verification is determined to have passed, and the target resources corresponding to the resource request are allocated to the corresponding tenant end.
[0041] Specifically, when the expected resources are greater than the resource quota limit value, it means that the resources in the current namespace are insufficient to support the allocation of excess resources, and the verification is determined to have failed, and the verification result of the request error is fed back to the management cluster, and the management cluster then feeds back the request error information to the corresponding tenant end. Conversely, when the expected resources are less than or equal to the resource quota limit value, it means that the resources in the current namespace are sufficient, and the verification is determined to have passed, and the target resources corresponding to the resource request are allocated to the corresponding tenant end.
[0042] In the technical solution provided in this embodiment, when a resource request is received, the attribute information in all namespaces is determined according to the namespace information corresponding to the resource request, and then the resource usage value of each namespace is obtained according to the attribute information, and the overall resource usage value of the current tenant is obtained by accumulating the resource usage values of each namespace, and then the preset resource quota limit value is obtained, and the resource request is verified according to the resource quota limit value and the overall resource usage value. Finally, the verification result is determined and fed back to the management cluster. The solution of this embodiment verifies the resource request by obtaining the resource usage value of the attribute information in the namespace, thereby effectively preventing the occurrence of resource over-allocation.
[0043] Embodiment 2 Please refer to Figure 3 In a third embodiment, the method comprises: Step S50: Create a custom resource object, which records the resource quota limit value and resource usage value of the current tenant.
[0044] Step S60: when it is detected that the tenant creates a resource object in the resource space, the resources to be used required for creating the resource object are determined.
[0045] Step S70: determining the remaining resources according to the user-defined resource object, and judging whether the resources to be used are exceeded according to the remaining resources.
[0046] Step S80: If the resources to be used are exceeded, the tenant's request to create an object in the resource space is rejected.
[0047] In this embodiment, the tenant resource quota limit is declared by creating a tenant custom object. The custom resource object records the resource quota limit value and resource usage value of the current tenant. When it is detected that the tenant creates a resource object in the resource space, the main cluster will determine in real time the resources to be used required to create the resource object. Then, the remaining resources are determined based on the custom resource object, and the resources to be used required to create the resource object are verified based on the remaining resources, that is, whether the resources to be used are exceeded. If the resources to be used are exceeded, the tenant's request to create an object in the resource space is rejected, that is, the tenant is prevented from creating an object in the resource space.
[0048] The purpose of the custom resource object created by the tenant is to record the upper limit of the resources that each tenant can use. After the admission control verification service counts the resources that the tenant has used, it compares the data with the tenant's custom resource object to determine whether the current resources have exceeded the upper limit.
[0049] In addition, the creation of tenant-defined objects is implemented through the CustomResourceDefinition (CRD) mechanism of Kubernetes. This object covers all the attributes in the Kubernetes namespace resource quota object ResourceQuota, and its scope is the entire cluster. Its lifecycle is consistent with the tenant's lifecycle. This object records the resource quota limit and resource usage of the current tenant. By calculating the resources already used and the resource quota limit, the remaining available resources of the current tenant can be obtained. When a user under a tenant creates a Kubernetes resource object in the namespace, such as a workload, by comparing the remaining available resources of the current tenant with the resources required by the current request, it can be calculated whether the resources are exceeded. If the resources are exceeded, the processing logic of the resource excess is consistent with that of the Kubernetes namespace resource quota object ResourceQuota, such as rejecting the request or reducing the number of request objects created.
[0050] Specifically, the CustomResourceDefinition (CRD) mechanism is an extension mechanism in Kubernetes that allows users to define their own resource types and controllers to meet specific application requirements. Through the CRD mechanism, developers and system administrators can create custom resources (Custom Resources), which can be created, deleted, and managed like built-in Kubernetes resources.
[0051] Optionally, in this embodiment, the step of determining remaining resources according to the custom resource object includes: The resource quota limit value and the resource usage value of the custom resource object record are obtained; a difference between the resource quota limit value and the resource usage value is determined, and the difference is determined as the remaining resources.
[0052] Specifically, the remaining resources are determined by obtaining the resource quota limit value and the resource usage value recorded in the custom resource object, and subtracting the resource usage value from the resource quota limit value to obtain the difference as the remaining resources.
[0053] In the technical solution provided in this embodiment, a custom resource object is created, and the custom resource object records the resource quota limit value and resource usage value of the current tenant, and when it is detected that the tenant creates a resource object in the resource space, the resources to be used required to create the resource object are determined, and then the remaining resources are determined according to the custom resource object, and it is judged whether the resources to be used are exceeded according to the remaining resources. If the resources to be used are exceeded, the tenant's request to create an object in the resource space is rejected. The solution of this embodiment realizes multi-tenant resource quota control by creating a custom resource object and verifying the tenant's creation of the resource object through the remaining resources in the custom resource object.
[0054] Embodiment 3 Please refer to Figure 4 In the third embodiment, before step S10, the method further includes: Step S90: creating a namespace resource object, wherein the attribute information in the namespace resource object stores the resource usage value.
[0055] Step S100: Obtain the overall resource usage value by detecting the attribute information of each namespace resource object.
[0056] In this embodiment, the namespace object is created through the tenant quota control mechanism and tenant association, wherein the attribute information in the namespace resource object stores the resource usage value. Therefore, the attribute information of the namespace resource object can be detected to obtain the resource usage value of a single namespace, and the resource usage values of all namespaces can be accumulated to obtain the overall resource usage value.
[0057] Specifically, after the namespace resource object is created, the resource object ResourceQuota is created by default. The attributes and values of the ResourceQuota object are completely consistent with the attributes and values in the tenant-defined resource object by default, because the tenant quota control is to obtain the attribute values in the tenant-defined resource object by accumulating the attribute values of the ResourceQuota objects in each namespace. A ResourceQuota object represents the resource usage of a namespace. This usage includes multiple types of resources, such as the cpu attribute, which represents how much cpu is used.
[0058] In addition, once a ResourceQuota object is created successfully, it will no longer change with the modification of the tenant's customized resource objects. Users can modify the ResourceQuota object in a separate way, and the value of the ResourceQuota object can exceed the tenant's customized resource object. When the cumulative value of the ResourceQuota objects of all namespaces under the tenant exceeds the upper limit of the tenant's customized resource objects, the resource requests that were applied first will be satisfied first, and the resource requests that were applied later will be rejected or reduced.
[0059] Optionally, in this embodiment, after the step of obtaining the overall resource usage value by detecting the attribute information of each namespace resource object, the step further includes: When the overall resource usage value exceeds the value of the tenant-defined resource object, determine the business priority of each resource request in the verification queue; reorder the resource requests in the verification queue according to the business priority, and execute the verification process according to the ordered resource requests.
[0060] Specifically, when the overall resource usage value exceeds the value of the tenant's custom resource object, the currently available resources have exceeded the limit. At this time, obtain each resource request in the verification queue and determine the business priority of the resource request, wherein the business priority can be obtained by obtaining the tag information of the tenant corresponding to the resource request, and the business priority is determined according to the priority in the tag information of each tenant. Then, the resource requests in the verification queue are reordered according to the business priority, and the ordered resource requests are placed in the verification queue. Finally, the resource requests are called in sequence according to the ordered verification queue to execute the verification process.
[0061] In the technical solution provided in this embodiment, a namespace resource object is first created, and the attribute information in the namespace resource object stores the resource usage value, and the overall resource usage value is obtained by detecting the attribute information of each namespace resource object. This embodiment creates a namespace resource object, thereby obtaining the attribute information of the namespace resource object and obtaining the overall resource usage value, so as to improve the subsequent verification efficiency of resource requests.
[0062] Embodiment 4 Please refer to Figure 5 In the fifth embodiment, as Figure 5 As shown, Figure 5 This is a flow chart of the fourth embodiment of the method for verifying Kubernetes resource quotas in this application. Figure 5 It shows the verification process of the verification service. At the beginning of the verification process, the resource request sent is first received, and the dynamic admission controller is triggered at the same time. The dynamic admission controller can collect the changes in resource creation or update in the cluster in real time to provide support for the verification process of the verification service. Then it is detected whether the cluster receiving the resource request is the main cluster. If not, the resource request is sent to the verification service of the main cluster, or the verification service of the main cluster is called. Then the tenant information is obtained, and the namespace information associated with the tenant information is obtained according to the tenant information, and the ResourceQuota resource quota object is obtained to determine the resource quota limit value. And the resource usage value of the namespace is determined according to the attribute information in the namespace information, so as to obtain the overall resource usage value of the current tenant by accumulating the resource usage values of each namespace. Then it is determined whether the request violates the quota constraint, that is, whether the sum of the target resource and the overall resource usage value exceeds the resource quota limit value. If it exceeds, the request error is fed back, and if it does not exceed, the prompt information of successful verification is fed back.
[0063] Since the system introduced in the embodiment of the present application is a system used to implement the method of the embodiment of the present application, based on the method introduced in the embodiment of the present application, the person skilled in the art can understand the specific structure and deformation of the system, so it is not repeated here. All systems used in the method of the embodiment of the present application belong to the scope of protection of this application.
[0064] The present application provides a Kubernetes resource quota verification device, the Kubernetes resource quota verification device includes: at least one processor; and a memory connected to the at least one processor in communication; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the Kubernetes resource quota verification method in the above-mentioned embodiment 1.
[0065] Reference below Figure 6 , which shows a schematic diagram of the structure of a verification device for Kubernetes resource quotas suitable for implementing an embodiment of the present application. The verification device for Kubernetes resource quotas in the embodiment of the present application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The Kubernetes resource quota verification device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0066] like Figure 6As shown, the verification device for Kubernetes resource quotas may include a processing device 1001 (e.g., a core processor, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. Various programs and data required for the operation of the verification device for Kubernetes resource quotas are also stored in RAM1004. The processing device 1001, ROM1002, and RAM1004 are connected to each other via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 1003 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 1009. The communication device 1009 can allow the verification device of the Kubernetes resource quota to communicate wirelessly or wired with other devices to exchange data. Although the figure shows the verification device of the Kubernetes resource quota with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or have alternatively.
[0067] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0068] The Kubernetes resource quota verification device provided by this application adopts the Kubernetes resource quota verification method in the above embodiment, which can solve the technical problem that the relevant scheme cannot effectively prevent the occurrence of resource over-allocation. Compared with the prior art, the beneficial effects of the Kubernetes resource quota verification device provided by this application are the same as the beneficial effects of the Kubernetes resource quota verification method provided by the above embodiment, and the other technical features in the Kubernetes resource quota verification device are the same as the features disclosed in the previous embodiment method, which will not be repeated here.
[0069] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0070] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0071] The present application provides a computer-readable storage medium having computer-readable program instructions (i.e., computer programs) stored thereon, and the computer-readable program instructions are used to execute the Kubernetes resource quota verification method in the above-mentioned embodiment.
[0072] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.
[0073] The computer-readable storage medium may be included in the Kubernetes resource quota verification device; or may exist independently without being assembled into the Kubernetes resource quota verification device.
[0074] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the Kubernetes resource quota verification device, the Kubernetes resource quota verification device: when receiving a resource request, determines the attribute information in all namespaces according to the namespace information corresponding to the resource request; obtains the resource usage value of each namespace according to the attribute information, and obtains the overall resource usage value of the current tenant by accumulating the resource usage value of each namespace; obtains a preset resource quota limit value, and verifies the resource request according to the resource quota limit value and the overall resource usage value; determines the verification result, and feeds the verification result back to the managed cluster.
[0075] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, SmallK, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code 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 and 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 via 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., via the Internet using an Internet service provider).
[0076] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that 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 boxes represented in succession 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 flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0077] The modules involved in the embodiments of the present application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself under certain values.
[0078] The readable storage medium provided in this application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned Kubernetes resource quota verification method, which can solve the technical problem that the relevant solutions cannot effectively prevent the occurrence of resource over-allocation. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the Kubernetes resource quota verification method provided in the above-mentioned embodiment, and will not be repeated here.
[0079] An embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the above-mentioned Kubernetes resource quota verification method.
[0080] The computer program product provided in this application can solve the technical problem that related solutions cannot effectively prevent resource over-allocation. Compared with the prior art, the beneficial effects of the computer program product provided in the embodiment of this application are the same as the beneficial effects of the Kubernetes resource quota verification method provided in the above embodiment, which will not be repeated here.
[0081] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent processing scope of the present application.
Claims
1. A Kubernetes resource quota verification method, characterized in that: Applied to the main cluster, the method comprises the following steps: Upon receiving a resource request, determining attribute information in all namespaces according to the namespace information corresponding to the resource request; Acquire the resource usage value of each namespace according to the attribute information, and obtain the overall resource usage value of the current tenant by accumulating the resource usage value of each namespace; Obtaining a preset resource quota limit value, and verifying the resource request according to the resource quota limit value and the overall resource usage value; Determine the verification result and feed the verification result back to the management cluster.
2. The method according to claim 1, characterized in that The step of obtaining a preset resource quota limit value and verifying the resource request according to the resource quota limit value and the overall resource usage value comprises: Obtaining the preset resource quota limit value; Determine the target resource required by the resource request, and obtain the expected resource according to the sum of the target resource and the overall resource usage value; The expected resources are compared with the resource quota limit value of the current tenant to complete the verification process of the resource request.
3. The method according to claim 2, characterized in that The step of determining the verification result and feeding back the verification result to the management cluster includes: When the expected resources are greater than the resource quota limit value, it is determined that the verification fails, and a verification result of the request error is fed back to the management cluster; When the expected resource is less than or equal to the resource quota limit value, it is determined that the verification is passed, and the target resource corresponding to the resource request is allocated to the corresponding tenant.
4. The method according to claim 1, characterized in that Before the step of determining the attribute information in all namespaces according to the namespace information corresponding to the resource request, the method further includes: After the managed cluster receives the resource request, the managed cluster sends the resource request to the main cluster; The main cluster transmits the resource request to the verification service to execute the step of determining the attribute information in all namespaces according to the namespace information corresponding to the resource request.
5. The method according to claim 1, characterized in that The method comprises: Create a custom resource object, which records the resource quota limit value and resource usage value of the current tenant; When detecting that a tenant creates a resource object in the resource space, determining the resources to be used that are required to create the resource object; Determine remaining resources according to the custom resource object, and judge whether the resources to be used are exceeded according to the remaining resources; If the resources to be used are exceeded, the tenant's request to create an object in the resource space is rejected.
6. The method according to claim 5, characterized in that The step of determining the remaining resources according to the custom resource object comprises: Obtain the resource quota limit value and the resource usage value recorded in the custom resource object; A difference between the resource quota limit value and the resource usage value is determined, and the difference is determined as the remaining resources.
7. The method according to claim 1, characterized in that Before the step of determining the attribute information in all namespaces according to the namespace information corresponding to the resource request when receiving the resource request, the method further includes: Creating a namespace resource object, wherein the attribute information in the namespace resource object stores a resource usage value; The overall resource usage value is obtained by detecting the attribute information of each namespace resource object.
8. The method according to claim 7, characterized in that After the step of obtaining the overall resource usage value by detecting the attribute information of each namespace resource object, the method further includes: When the overall resource usage value exceeds the value of the tenant's custom resource object, the service priority of each verification request in the verification queue is determined; The verification requests in the verification queue are reordered according to the service priority, and the verification process is executed according to the ordered verification requests.
9. A Kubernetes resource quota verification device, characterized in that: The Kubernetes resource quota verification device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the Kubernetes resource quota verification method as described in any one of claims 1 to 8.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the Kubernetes resource quota verification method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Application deployment method based on container cloud platform and electronic equipment
CN115756499A
Kubernetes cluster management method and device, equipment, medium and program product
CN118337437A
Authority control method and device for multi-tenant shared cluster, medium and equipment
CN118713869A
Cited By
Timeslot-based namespace allocation method and device, equipment and storage medium
CN122204820A
