Application deployment methods and electronic devices based on container cloud platforms
By determining the reserved function status of the namespace and the resource usage of the target tenant, the resource quota configuration of the namespace on the container cloud platform is simplified, solving the problem of complex operation in the existing technology and realizing flexible resource management.
Patent Information
- Application Number
- CN202211332072.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-27
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2042-10-27
AI Technical Summary
On container cloud platforms, configuring resource quotas for namespaces is a cumbersome process. Users need to strictly set resource quotas for each namespace, which is complex and inflexible.
By determining whether the namespace reservation function is enabled, resources are reserved for the target namespace if enabled, and if not enabled, the application is deployed based on the available resource value of the target tenant, thus simplifying the resource quota configuration process.
It simplifies the configuration of resource quotas for namespaces, allowing resources to be reserved for critical namespaces without setting strict total resource limits for namespaces where the reservation function is not enabled, thus improving operational flexibility and efficiency.
Smart Images

Figure CN115756499B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of container cloud technology, and in particular relates to an application deployment method and electronic device based on a container cloud platform. Background Technology
[0002] With the rise of cloud services, collaborative work via cluster-based container cloud platforms has gradually become the mainstream choice for enterprises and individuals. In container cloud platforms, namespaces logically isolate resource objects, serving as an abstract collection of resources and objects. Currently, on container cloud platforms, users need to strictly set resource quotas for each namespace, a cumbersome process. Summary of the Invention
[0003] This application provides an application deployment method and electronic device based on a container cloud platform, which can simplify the process of configuring resource quotas for namespaces.
[0004] The first aspect of this application provides an application deployment method based on a container cloud platform. The method includes: upon receiving a deployment request to deploy a target application in a target namespace, determining whether the reservation function of the target namespace is enabled; if the determination result is that the reservation function of the target namespace is enabled, then in response to the sum of the resource usage value of the target namespace and the resource request value of the target application not exceeding the total resource limit value of the target namespace, deploying the target application in the target namespace; if the determination result is that the reservation function of the target namespace is not enabled, then in response to the current available resource value of the target tenant not being less than the resource request value of the target application, deploying the target application in the target namespace; wherein, the target tenant corresponds to at least one namespace including the target namespace, the current available resource value of the target tenant is equal to the total tenant resource value of the target tenant minus the total resource limit value of all first namespaces and the resource usage value of all second namespaces, the first namespace is a namespace corresponding to the target tenant and currently having its reservation function enabled, and the second namespace is a namespace corresponding to the target tenant and currently not having its reservation function enabled.
[0005] A second aspect of this application provides an electronic device, which includes a processor, a memory, and a communication circuit. The processor is coupled to the memory and the communication circuit, respectively. The memory stores program data, and the processor executes the program data in the memory to implement the steps in the above method.
[0006] A third aspect of this application provides a computer-readable storage medium storing a computer program that can be executed by a processor to implement the steps in the above-described method.
[0007] The beneficial effects are as follows: In the solution proposed in this application, for a tenant, when it needs to reserve resources for a namespace, it only needs to enable the reservation function. The tenant does not need to set strict total resource limits for other namespaces where reservation is not enabled. This allows for both resource reservation for critical namespaces and simplifies the resource quota configuration process for namespaces. Furthermore, even if the tenant's total resource limit is subsequently updated, it is not necessary to adjust the total resource limit for each namespace corresponding to that tenant. Attached Figure Description
[0008] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort, wherein:
[0009] Figure 1 This is a flowchart illustrating one implementation method of the application deployment method based on a container cloud platform in this application;
[0010] Figure 2 This is a flowchart illustrating another implementation of the application deployment method based on a container cloud platform in this application;
[0011] Figure 3 This is a partial flowchart illustrating another implementation method of the application deployment method based on a container cloud platform in this application;
[0012] Figure 4 This is a schematic diagram of the structure of one embodiment of the electronic device of this application;
[0013] Figure 5 This is a schematic diagram of another embodiment of the electronic device of this application;
[0014] Figure 6 This is a schematic diagram of one embodiment of the computer-readable storage medium of this application. Detailed Implementation
[0015] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0016] It should be noted that the terms "first" and "second" in this application are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0017] Before introducing the solution of this application, let's first introduce some of the technical terms involved in this application:
[0018] First, for ease of explanation, the container cloud platform in this application will be described based on Kubernetes (k8S for short), and the application deployment method in this application will be executed by the container cloud platform.
[0019] In a cluster of a Kubernetes-based container cloud platform, multiple namespaces can be created, which can logically isolate resource objects. Furthermore, within a cluster, a tenant can manage multiple namespaces, while a namespace can only be managed by one tenant.
[0020] In this process, the cluster allocates resources to each tenant, specifying how many resources each tenant is allowed to use, and then the tenant allocates the allocated resources to the corresponding namespace.
[0021] See Figure 1 In one embodiment of this application, the application deployment method based on a container cloud platform includes:
[0022] S110: Receive a deployment request to deploy the target application within the target namespace.
[0023] Specifically, when a user wants to deploy an application in a namespace within the cluster, they send a deployment request to the container cloud platform. The application the user wants to deploy is defined as the target application, and the namespace where the target application is to be deployed is defined as the target namespace.
[0024] Step S110 is executed by the apiserver component in Kubernetes. In existing technologies, Kubernetes provides ResourceQuota to declare the total resource limit for a namespace, and simultaneously uses kube-controller-manager to calculate the used resources within that namespace. The total resource limit for a namespace refers to the maximum amount of resources allocated to that namespace; the used resources within a namespace refer to the amount of resources already used by that namespace out of the allocated resources.
[0025] In existing technologies, when a user wants to deploy an application in a namespace, the apiserver component determines whether the application can be deployed within the namespace based on the resource request value of the application to be deployed (i.e., the amount of resources required to deploy the application), the total resource limit of the namespace, and the resource usage value of the namespace. This process specifically includes: calculating the total resource limit of the namespace minus the resource usage value of the namespace to obtain the remaining resource value of the namespace; determining whether the resource request value of the application to be deployed does not exceed the remaining resource value of the namespace. If it does not exceed the remaining resource value of the namespace, the application can be deployed within the namespace. Otherwise, with the current quota of the namespace, it is not possible to deploy the application within the namespace.
[0026] S120: Determine whether the reservation function of the target namespace is enabled.
[0027] If the determination result is that the reservation function of the target namespace is enabled, then step S130 is executed; if the determination result is that the reservation function of the target namespace is not enabled, then step S140 is executed.
[0028] Specifically, for any given namespace, whether or not to enable its reservation feature is up to the user, who can decide at any time whether or not to enable the namespace's reservation feature.
[0029] For any given namespace, when its reservation feature is enabled, resources declared by that namespace are reserved within the quota of the tenant corresponding to that namespace, allowing the namespace to exclusively use those resources. Specifically, taking the target namespace as an example, the tenant corresponding to the target namespace is defined as the target tenant. When the reservation feature for the target namespace is enabled, resources equal to the total resource limit of the target namespace are reserved within the target tenant's quota, allowing the target namespace to exclusively use those reserved resources. Other namespaces within the target tenant share the remaining resources after deducting the resources reserved for the target namespace. For ease of understanding, the following example illustrates this:
[0030] The target tenant has a total resource limit of 2GB. The target tenant corresponds to three namespaces: namespace A, namespace B, and namespace C. Namespace A is the target namespace. Assuming that the total resource limit of namespace A is 1GB, after enabling the reservation function of namespace A, 1GB of resources will be reserved for namespace A in the target tenant's quota, allowing namespace A to exclusively use this 1GB of resources. Namespaces B and C share the remaining 1GB of resources. That is, at any time, no more than 1GB of resources can be used in namespace A, thus ensuring that there are sufficient resources available for namespace A.
[0031] S130: Determine whether the sum of the resource usage value of the target namespace and the resource request value of the target application exceeds the total resource limit of the target namespace.
[0032] If the result is no more than, then proceed to step S150; otherwise, proceed to step S160.
[0033] Specifically, when the reservation function of the target namespace is enabled, the resources declared by the target tenant are reserved for it, so that the target namespace can exclusively occupy the reserved resources, that is, the target namespace can exclusively occupy resources of a size equal to the total resource limit value corresponding to it.
[0034] The resource usage value of the target namespace refers to the total amount of resources already used in the target namespace, while the resource request value of the target application refers to the amount of resources required to deploy the target application.
[0035] Since a target namespace can exclusively occupy resources of a size equal to its corresponding total resource limit, when the sum of the used resources of the target namespace and the resource request value of the target application does not exceed the total resource limit of the target namespace, it indicates that the remaining resources reserved for the target namespace (excluding the resources already used by the target namespace) are still sufficient to support the deployment of the target application within the target namespace. However, when the sum of the used resources of the target namespace and the resource request value of the target application exceeds the total resource limit of the target namespace, it indicates that the remaining resources reserved for the target namespace are insufficient to support the deployment of the target application within the target namespace, suggesting that the allocated quota for the target namespace is insufficient. Therefore, step S160 is executed to inform the user that the deployment of the target application in the target namespace is not supported. Of course, in other embodiments, the reason for not supporting the deployment of the target application may not be explained to the user; instead, a direct prompt may be displayed indicating that the deployment of the target application is currently not supported.
[0036] S140: Determine whether the current available resource value of the target tenant is less than the resource request value of the target application.
[0037] If the result is not less than, then proceed to step S150; if the result is less than, then proceed to step S170.
[0038] The target tenant corresponds to at least one namespace, including the target namespace. The target tenant's currently available resource value is equal to the target tenant's total tenant resource value minus the total resource limit of all currently enabled reserved namespaces corresponding to the target tenant, and the resource usage value of all currently disabled reserved namespaces corresponding to the target tenant. For ease of explanation, the namespace corresponding to the target tenant and currently enabled reserved is defined as the first namespace, and the namespace corresponding to the target tenant and currently disabled reserved is defined as the second namespace. Then, the target tenant's currently available resource value is equal to the target tenant's total tenant resource value minus the total resource limit of all first namespaces and the resource usage value of all second namespaces.
[0039] Specifically, if the reservation function of the target namespace is not enabled, the target namespace needs to share with other namespaces of the target tenant that do not have the reservation function enabled. The remaining resources after deducting the resources reserved for the namespaces with the reservation function enabled from the target tenant's quota are the unused resources. Therefore, if the target application is deployed in the target namespace, the resources that can actually be used are the remaining resources after deducting the resources reserved for the namespaces with the reservation function enabled from the target tenant's quota.
[0040] Therefore, if the reservation function of the target namespace is not enabled, the current available resource value of the target tenant is determined to be equal to the total tenant resource value of the target tenant minus the total resource limit value of all namespaces in the target tenant that currently have the reservation function enabled, and then minus the resource usage value of the namespaces in the target tenant that currently do not have the reservation function enabled.
[0041] If the target tenant's current available resources are not less than the target application's resource request value, it means that the current available resources support the deployment of the target application, and therefore the target application can be deployed in the target namespace. Otherwise, it means that the current available resources do not support the deployment of the target application, and the reason for this is that the target tenant's current resources are insufficient. In order to let the user know why the target application cannot be deployed, the target tenant can be prompted that the quota is insufficient, and the user can be advised to allocate more quota to the target tenant, i.e., execute step S170. Of course, when it is determined that the current available resources do not support the deployment of the target application, the target tenant can be prompted that the quota is insufficient instead of prompting the target tenant.
[0042] S150: Deploy the target application within the target namespace.
[0043] S160: Insufficient target namespace quota.
[0044] S170: Indicates insufficient quota for the target tenant.
[0045] See Figure 2 In another embodiment of this application, the application deployment method based on a container cloud platform includes:
[0046] S210: Receive a deployment request to deploy the target application within the target namespace.
[0047] S220: Determine whether the reservation function of the target namespace is enabled.
[0048] If the determination result is that the reservation function of the target namespace is enabled, then proceed to step S230; if the determination result is that the reservation function of the target namespace is not enabled, then proceed to step S240.
[0049] S230: Determine whether the sum of the resource usage value of the target namespace and the resource request value of the target application exceeds the total resource limit of the target namespace.
[0050] If the judgment result is not greater than, then proceed to step S260; if the judgment result is greater than, then proceed to step S270.
[0051] S240: Determine whether the current available resource value of the target tenant is less than the resource request value of the target application.
[0052] If the result is not less than, then proceed to step S250; otherwise, proceed to step S280.
[0053] The target tenant corresponds to at least one namespace including the target namespace. The current available resource value of the target tenant is equal to the total tenant resource value of the target tenant minus the total resource limit value of all first namespaces and the resource usage value of all second namespaces. The first namespace is the namespace corresponding to the target tenant that currently has the reservation function enabled, and the second namespace is the namespace corresponding to the target tenant that currently does not have the reservation function enabled.
[0054] S250: Determine whether the sum of the resource request value of the target application and the resource usage value of the target namespace is not greater than the total resource limit of the target namespace.
[0055] If the result is not greater than, then proceed to step S260; otherwise, proceed to step S270.
[0056] S260: Deploy the target application within the target namespace.
[0057] S270: Insufficient target namespace quota.
[0058] S280: Indicates insufficient quota for the target tenant.
[0059] Unlike the above implementation, in this implementation, after determining that the target tenant's currently available resource value is not less than the target application's resource request value, it further determines whether the sum of the target application's resource request value and the target namespace's used resource value is not greater than the target namespace's total resource limit. If it is greater, it indicates that the target namespace's remaining resources do not support the deployment of the target application, and a message indicating insufficient quota for the target namespace is displayed; otherwise, the target application is deployed within the target namespace. It should be noted that if the target namespace does not have a total resource limit, the target application can be directly deployed within the target namespace after determining that the target tenant's currently available resource value is not less than the target application's resource request value. Specifically, when creating a namespace, if the user can guarantee that the namespace's reservation function will not be needed later, a total resource limit value does not need to be set for it. However, if the namespace's reservation function needs to be enabled later, a total resource limit value must be set for it so that resources are reserved for it according to its total resource limit value.
[0060] Meanwhile, step S250 is not a necessary step. In other embodiments, when there is a total resource limit value in the target namespace, if the judgment result in step S240 is not less than, step S260 can be executed directly.
[0061] Meanwhile, steps S270 and S280 above both indicate the reason why the target application is not supported for deployment. However, in other implementations, if it is determined that the target application is not supported for deployment, the user can be informed that the target application is not supported for deployment without indicating the reason why it is not supported.
[0062] The following example demonstrates the namespace creation process. Please refer to [link / reference]. Figure 3 The process includes:
[0063] S310: After receiving the creation request to create the target namespace, determine the total tenant resource value of the target tenant and subtract the total resource limit value of all first namespaces to obtain the remaining allocable resources of the target tenant.
[0064] S320: Provide the target tenant with the remaining allocable resources of the target tenant so that the target tenant can set a total resource limit for the target namespace based on the remaining allocable resources of the target tenant.
[0065] Specifically, since resources need to be reserved for namespaces with the reservation function enabled, the resources that the target tenant can allocate to the target namespace are the total tenant resources allocated to the target tenant minus the resources allocated to all namespaces with the reservation function enabled.
[0066] Therefore, after receiving the creation request, the total resource limit of all namespaces with reserved functions enabled in the target tenant (i.e., the first namespace) is subtracted from the total resource limit of the target tenant. This gives the remaining resource value that can be allocated to the target tenant. Then, when setting the total resource limit of the target namespace, the user only needs to ensure that the total resource limit of the target namespace does not exceed the remaining resource value that can be allocated to the target tenant.
[0067] In this embodiment, after receiving a request to enable the reservation function of the target namespace, the container cloud platform determines whether the total resource limit of the target namespace exceeds the target resource value of the target tenant. If it is determined that the total resource limit of the target namespace does not exceed the target resource value, the reservation function of the target namespace is enabled. The target resource value of the target tenant is equal to the total tenant resource value of the target tenant minus the total resource limit of all first namespaces and the resource usage value of all third namespaces. The third namespaces are the namespaces corresponding to the target tenant that do not currently have the reservation function enabled, excluding the target namespace.
[0068] Among them, the target tenant can decide whether to enable the reservation function of the target namespace when creating the target namespace, or they can decide not to enable the reservation function of the target namespace when creating it, and then decide to enable the reservation function of the target namespace during subsequent use.
[0069] Specifically, the resources that can be allocated to the target namespace from the target tenant are the total tenant resources of the target tenant minus the resources reserved for the namespaces in the target tenant that have enabled the reservation function and the resources used by other namespaces that do not have the reservation function enabled, excluding the target namespace. Here, the total tenant resources of the target tenant are defined as the total resource limit of all first namespaces and the resource usage of all third namespaces are subtracted in sequence to obtain the target resource value of the target tenant.
[0070] If the total resource limit of the target namespace does not exceed the target resource value of the target tenant, the target tenant can reserve the declared resources for the target namespace, thus enabling the reservation function of the target namespace. Otherwise, if the target tenant cannot reserve the declared resources for the target namespace, the user will be prompted that the reservation function of the target namespace cannot be enabled, and the reason for the inability to enable it may be that the target tenant's quota is insufficient.
[0071] To facilitate understanding, examples are provided below:
[0072] The target tenant has a total resource limit of 2GB and three namespaces: A, B, and C. Namespace A has a resource limit of 1GB, while namespaces B and C each have a resource limit of 0.8GB. Assuming only namespace A's reservation function is enabled initially, if the target tenant wants to enable namespace B's reservation function at a certain time, and namespace C uses 0.1GB of resources, then the target tenant's target resource limit is 0.9GB (2-1-0.1=0.9). Since 0.8GB is less than 0.9GB, enabling namespace B's reservation function is supported. However, if namespace C uses 0.5GB of resources, then the target tenant's target resource limit is 0.5GB (2-1-0.5=0.5). Since 0.8GB is greater than 0.5GB, enabling namespace B's reservation function is not supported.
[0073] For example, if the target tenant's total resource value is 5G, when namespace C is created, namespaces A and B corresponding to the target tenant have already been created, and the reservation function of namespace A is enabled, with a total resource limit of 2G. The reservation function of namespace B is not enabled, but it has already used 0.5G of resources. Then the target tenant's target resource value is 2.5G (5-2-0.5=2.5). If the reservation function of namespace C is to be enabled, the total resource limit of namespace C cannot exceed 2.5G; otherwise, the reservation function of namespace C cannot be enabled.
[0074] Users can choose whether to enable the reservation function of the target namespace through a button provided by the container cloud platform. This button can be enabled by adding a label to the resource quota.
[0075] When creating a namespace, the target identifier of the target tenant is added to the tag of any namespace corresponding to the target tenant. When querying the namespace corresponding to the target tenant, the namespace carrying the target identifier can be directly searched, thus identifying the namespace corresponding to the target tenant. In other words, namespaces corresponding to the same tenant carry the same target identifier, while namespaces corresponding to different tenants carry different target identifiers.
[0076] Furthermore, in one application scenario, when it's necessary to query the actual resource usage of a target tenant, this can be obtained by querying the resource usage of the namespace carrying the target identifier. Specifically, by querying all pods in the namespace carrying the target identifier, the resource usage of the target tenant is statistically analyzed, yielding the actual resource usage value of the target tenant. This actual resource usage value can then be provided to the target tenant for reference. It's understandable that the actual resource usage value of the target tenant here represents the amount of resources actually used by the target tenant; that is, the sum of the resource usage values of all namespaces corresponding to the target tenant.
[0077] In Kubernetes, a custom resource tenant quota (TenantQuota) can be defined to calculate the actual resource usage of a tenant and the total resource usage of that tenant. The actual resource usage of a tenant can be calculated following the process described above.
[0078] The total tenant resource value is set by the user. During the operation of the container cloud platform, the user can also adjust the total tenant resource value. The following uses the target tenant as an example to introduce the process of changing the total tenant resource value:
[0079] When a target tenant feels that its resources are insufficient, it can fill out an application form. When filling out the application form, the container cloud platform can display the target tenant's current actual resource usage value, and then allow the user to fill out the application form according to the actual situation and its own needs.
[0080] After the user fills out the application form, the container cloud platform receives a request to adjust the total tenant resources of the target tenant. The container cloud platform then provides the total cluster resources of the target cluster where the target tenant resides and the resource usage of the target cluster to the cluster administrator, so that the cluster administrator can determine whether to approve the change request based on the total cluster resources of the target cluster and the resource usage of the target cluster. After the cluster administrator selects to approve the change request, the total tenant resources of the target tenant are updated.
[0081] Specifically, the sum of the total tenant resources of all tenants corresponding to the target cluster will not exceed the total cluster resources of the target cluster; at the same time, the resource usage of the target cluster is equal to the sum of the actual resource usage of all tenants corresponding to the target cluster.
[0082] After receiving a request from a target tenant to change the total tenant resources value, the container cloud platform provides the cluster administrator with the total cluster resources value of the target cluster where the target tenant resides and the resource usage value of the target cluster. The cluster administrator can then determine whether to approve the change request based on the total cluster resources value, the resource usage value, the total tenant resources value of the target tenant after the request, and the actual resource usage value of the target tenant. If the cluster administrator approves the change request, the container cloud platform updates the total tenant resources value of the target tenant to the requested adjusted value. If the administrator does not approve, the user is notified that the change request is not approved.
[0083] When the cluster administrator approves the change request, the TenantQuota will update the total number of tenant resources for the target tenant.
[0084] When a cluster administrator judges a change request, if the request is to increase the resources allocated to the target tenant, and the requested increase exceeds the difference between the total resources of the target cluster and the used resources (the remaining resources of the target cluster), then it indicates that the remaining resources of the target cluster do not support the change request, and the cluster administrator will not approve the change request and can inform the user of the reason for rejection. However, if the requested increase does not exceed the remaining resources of the target cluster, the cluster administrator may not necessarily approve the change request. For example, although the requested increase does not exceed the remaining resources of the target cluster, if the ratio of the target tenant's currently available resources to the total tenant resources exceeds a first threshold, it means that the target tenant has a lot of unused resources. In this case, to avoid allocating excessive resources to the target tenant and affecting other tenants, the cluster administrator may also choose not to approve the change request. Similarly, if the ratio of the target tenant's actual used resources to the total tenant resources is less than a second threshold, it means that the target tenant is not actually using many resources, and the cluster administrator may also reject the change request.
[0085] In summary, this application does not impose specific restrictions on the rules that cluster administrators use to determine whether to approve a change request.
[0086] In existing technologies, tenants set resource limits for each namespace to restrict the maximum resource usage of each namespace. The sum of the resource limits for namespaces belonging to the same tenant can exceed the tenant's total resource limit. For example, tenant 1 has a total resource limit of 2GB and three namespaces: A, B, and C. The resource limits for each of these namespaces are 1GB, meaning that the total resources used by these three namespaces cannot exceed 2GB, and the resources used by any one namespace individually cannot exceed 1GB. Therefore, in existing technologies, when a tenant wants to reserve sufficient resources for a specific namespace, it needs to strictly set the resource limits for other namespaces. Using the example above: when a tenant wants to reserve 1GB of resources for namespace A, it must ensure that the sum of the resource limits set for namespace B and namespace C does not exceed 1GB.
[0087] However, as can be seen from the above, in the solution of this application, for a tenant, when it needs to reserve resources for a critical and important namespace, it only needs to enable the reservation function. The tenant does not need to set strict total resource limits for other namespaces where reservation is not enabled. Using the example above: when a tenant wants to reserve 1GB of resources for namespace A, it only needs to enable the reservation function for namespace A. The tenant can then freely set total resource limits for namespaces B and C. For example, the total resource limit for namespaces B and C can still be set to 1GB, or one can be set to 1GB and the other to 0.5GB, or even no total resource limit can be set for namespaces B and C. Therefore, the solution of this application can both reserve resources for critical namespaces and simplify the process of configuring namespace resource quotas. Furthermore, even if the tenant's total resource limit is updated subsequently, it is not necessary to adjust the total resource limit for each namespace corresponding to that tenant.
[0088] Meanwhile, in the solution of this application, if the reservation function of a namespace is not enabled, the meaning of its corresponding total resource limit value is the same as that of the prior art, that is, using no more than the total resources of the tenant and no more than the total resource limit value of the tenant.
[0089] In addition, this application will also collect statistics on the actual resource usage value and total resource value of each tenant, which can prevent a situation where a certain tenant occupies a large amount of resources and affects the use of other tenants, and ensure that multiple tenants use resources reasonably.
[0090] To implement the solution in this application, an admission control plugin can be added to the apiserver component in Kubernetes. When a target tenant wants to deploy a target application in a target namespace, this new admission control plugin can be used to determine whether the target namespace has the reservation function enabled, and to determine the specific process of whether the target application can be deployed in the target namespace.
[0091] See Figure 4 , Figure 4 This is a schematic diagram of one embodiment of the electronic device of this application. The electronic device 200 includes a processor 210, a memory 220, and a communication circuit 230. The processor 210 is coupled to the memory 220 and the communication circuit 230 respectively. The memory 220 stores program data. The processor 210 executes the program data in the memory 220 to implement the steps in any of the above embodiments. The detailed steps can be found in the above embodiments and will not be repeated here.
[0092] The electronic device 200 can be any device with algorithm processing capabilities, such as a computer or a mobile phone, and a container cloud platform can be deployed on the electronic device 200. Specifically, the container cloud platform deployed on the electronic device 200 executes the method steps in any of the above embodiments when it is working.
[0093] See Figure 5 , Figure 5 This is a schematic diagram of another embodiment of the electronic device of this application. The electronic device 300 includes a receiving module 310, a judging module 320, and a deployment module 330.
[0094] The receiving module 310 is used to receive a deployment request to deploy the target application within the target namespace.
[0095] The judgment module 320 is connected to the receiving module 310 and is used to determine whether the reservation function of the target namespace is enabled after the receiving module 310 receives the deployment request. If the judgment result is that the reservation function of the target namespace is enabled, it continues to determine whether the sum of the resource used value of the target namespace and the resource request value of the target application does not exceed the total resource limit value of the target namespace. If the judgment result is that the reservation function of the target namespace is not enabled, it determines whether the current available resource value of the target tenant is not less than the resource request value of the target application.
[0096] The deployment module 330 is used to deploy the target application in the target namespace when the judgment module 320 determines that the sum of the resource usage value of the target namespace and the resource request value of the target application does not exceed the total resource limit of the target namespace, and to deploy the target application in the target namespace when the judgment module 320 determines that the current available resource value of the target tenant is not less than the resource request value of the target application.
[0097] The target tenant corresponds to at least one namespace including the target namespace. The current available resource value of the target tenant is equal to the total tenant resource value of the target tenant minus the total resource limit value of all first namespaces and the resource usage value of all second namespaces. The first namespace is the namespace corresponding to the target tenant that currently has the reservation function enabled, and the second namespace is the namespace corresponding to the target tenant that currently does not have the reservation function enabled.
[0098] The electronic device 300 can be any device with algorithm processing capabilities, such as a computer or mobile phone, and a container cloud platform can be deployed on the electronic device 300. When the container cloud platform deployed on the electronic device 300 is working, it can execute the method steps in any of the above embodiments. For detailed steps, please refer to the above-mentioned related content.
[0099] See Figure 6 , Figure 6 This is a schematic diagram of one embodiment of the computer-readable storage medium of this application. The computer-readable storage medium 400 stores a computer program 410, which can be executed by a processor to implement the steps in any of the above methods.
[0100] Specifically, the computer-readable storage medium 400 can be a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, or a device that can store the computer program 410. Alternatively, it can be a server that stores the computer program 410, which can send the stored computer program 410 to other devices for execution, or it can run the stored computer program 410 itself.
[0101] The above description is merely an embodiment of this application and does not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A method for application deployment based on a container cloud platform, characterized by, The method comprises: after receiving a deployment request of deploying a target application in a target namespace, judging whether a reservation function of the target namespace is enabled; if the judgment result is that the reservation function of the target namespace is enabled, and the sum of a resource used value of the target namespace and a resource application value of the target application does not exceed a resource total quantity limit value of the target namespace, deploying the target application in the target namespace in response to the sum; if the judgment result is that the reservation function of the target namespace is not enabled, and a current available resource value of a target tenant is not less than the resource application value of the target application, deploying the target application in the target namespace in response to the current available resource value of the target tenant. The target tenant corresponds to at least one namespace including the target namespace, and the current available resource value of the target tenant is equal to a tenant resource total quantity value of the target tenant minus resource total quantity limit values of all first namespaces and resource used values of all second namespaces in sequence, the first namespace is a namespace corresponding to the target tenant and currently having the enabled reservation function, and the second namespace is a namespace corresponding to the target tenant and currently not having the enabled reservation function.
2. The method of claim 1, wherein, The step of deploying the target application in the target namespace in response to the current available resource value of the target tenant being not less than the resource application value of the target application comprises: in response to the current available resource value of the target tenant being not less than the resource application value of the target application, acquiring the resource total quantity limit value of the target namespace; in response to the sum of the resource application value of the target application and the resource used value of the target namespace being not greater than the resource total quantity limit value of the target namespace, deploying the target application in the target namespace.
3. The method of claim 2, wherein, The method further comprises: in response to the current available resource value of the target tenant being less than the resource application value of the target application, prompting that the target tenant is insufficient in quota; and / or, in response to the sum of the resource application value of the target application and the resource used value of the target namespace being greater than the resource total quantity limit value of the target namespace, prompting that the target namespace is insufficient in quota.
4. The method of claim 1, wherein, Before the step of judging whether the reservation function of the target namespace is enabled after receiving the deployment request of deploying the target application in the target namespace, the method further comprises: after receiving a creation request of creating the target namespace, determining a resource allocatable remaining value of the target tenant by subtracting resource total quantity limit values of all the first namespaces from a tenant resource total quantity value of the target tenant; providing the resource allocatable remaining value of the target tenant to the target tenant, so that the target tenant sets the resource total quantity limit value for the target namespace according to the resource allocatable remaining value of the target tenant.
5. The method of claim 1, wherein, The method further comprises: after receiving an enabling request of enabling the reservation function of the target namespace, judging whether the resource total quantity limit value of the target namespace exceeds a target resource value of the target tenant. If it is determined that the total resource limit of the target namespace does not exceed the target resource value, the reservation function of the target namespace is started; The target resource value of the target tenant is equal to the total tenant resource value of the target tenant minus the total resource limit of all the first namespaces and the resource used value of all the third namespaces in sequence, and the third namespace is a namespace corresponding to the target tenant and excluding the target namespace and currently not starting the reservation function.
6. The method of claim 1, wherein, The method further comprises: After receiving the change request for adjusting the total tenant resource value of the target tenant, providing the cluster total resource value of the target cluster where the target tenant is located and the resource used value of the target cluster to a cluster administrator, so that the cluster administrator determines whether to pass the change request according to the cluster total resource value of the target cluster and the resource used value of the target cluster; After the cluster administrator selects to pass the change request, updating the total tenant resource value of the target tenant.
7. The method of claim 1, wherein, The method further comprises: The namespace carrying the target identifier is determined as corresponding to the target tenant, wherein the target identifier corresponds to the target tenant.
8. The method of claim 7, wherein, The method further comprises: The resource used values of all the namespaces carrying the target identifier are counted to obtain the actual resource usage value of the target tenant.
9. An electronic device, comprising: The electronic device comprises a processor, a memory and a communication circuit, the processor is coupled with the memory and the communication circuit respectively, the memory stores program data, and the processor executes the program data in the memory to realize the steps in the method of any one of claims 1-8.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program can be executed by the processor to realize the steps in the method of any one of claims 1-8.
Citation Information
Patent Citations
A cluster resource management method and device
CN109189568A
Business deployment method and device for multiple Kubernetes clusters
CN114625535A