Resource modification method, device, electronic device and storage medium

By receiving user-defined resource instances and modification strategies, the resource is filtered and modified, and the problem of insufficient flexibility and efficiency in resource modification in the existing technology is solved, and the flexibility and efficiency of resource modification are improved.

CN118585338BActive Publication Date: 2025-04-29安徽省大数据中心
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410812450.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2025-04-29
Estimated Expiration
2044-06-21

AI Technical Summary

Technical Problem

In the prior art, resource modification usually requires source code modification, resulting in poor flexibility and efficiency.

Method used

Provides a resource modification method, by receiving user-defined resource instances and modification policies, filtering and modifying resources based on these policies, and supports dynamic addition of user-defined resource instances to achieve targeted modification.

Benefits of technology

On the basis of not modifying the source code, the flexibility and efficiency of resource modification are improved, and the required configuration can be automatically added to the resource, and directional modifications are made when the specified conditions are met.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118585338B_ABST
    Figure CN118585338B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of computer technology, and provides a resource modification method, device, electronic device and storage medium, the method comprising: receiving an instance of a user-defined resource carried in a resource publishing request, the instance of the resource including a modification policy of the resource; based on the modification policy, screening the resource, obtaining a target resource that satisfies the modification policy, and modifying the target resource. The resource modification method, device, electronic device and storage medium provided by the present invention define the resource modification policy in a user-defined resource manner, without modifying the source code, only by dynamically adding an instance of the user-defined resource, and can flexibly and meticulously perform targeted modifications when the resource is published, so that when the specified conditions are met, the required configuration can be automatically added to the resource, with better flexibility and higher efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a resource modification method, device, electronic device and storage medium. Background Art

[0002] Gatekeeper is a component in the Kubernetes ecosystem. Gatekeeper is a customizable Kubernetes admission controller webhook that executes policies defined by Open Policy Agent (OPA). OPA is a policy engine for cloud native environments hosted by the Cloud Native Computing Foundation (CNCF). Gatekeeper leverages the power of OPA to provide a flexible and scalable policy enforcement framework for Kubernetes.

[0003] In related technologies, resource modification usually involves modifying source code, resulting in poor flexibility and efficiency. Summary of the invention

[0004] The present invention provides a resource modification method, device, electronic device and storage medium, which are used to solve the defects in the prior art that source code needs to be modified, resulting in poor flexibility and efficiency.

[0005] The present invention provides a resource modification method, which is applied to an admission control component in a container orchestration system, and the method comprises:

[0006] Receiving an instance of a user-defined resource carried in a resource publishing request, wherein the instance of the resource includes a modification policy of the resource;

[0007] Based on the modification strategy, the resources are screened to obtain target resources that meet the modification strategy, and the target resources are modified.

[0008] According to the resource modification method provided by the present invention, the resource is screened based on the modification strategy to obtain the target resource that meets the modification strategy, including:

[0009] Based on the resource attributes defined in the modification strategy, the resource attributes corresponding to the resource are screened to obtain the initial resource.

[0010] The resource attributes include resource group, version and type;

[0011] Based on the modification conditions defined in the modification policy, the initial resources are screened for the corresponding modification conditions to obtain the target resources.

[0012] According to the resource modification method provided by the present invention, the modification conditions include operators and operands of logical expressions, the operators include at least one of equals, not equals, all conditions must be met, all conditions are not met, only one condition needs to be met, and one condition is not met, and the operands include variables.

[0013] The resource modification method provided by the present invention further includes:

[0014] If no initial resource satisfying the resource attribute is screened out, or no target resource satisfying the modification condition is screened out, the resource publishing request is rejected.

[0015] According to the resource modification method provided by the present invention, the modifying of the target resource comprises:

[0016] The target resource is modified based on the modification specification defined in the modification policy. The modification specification includes a modification method, a path of a modification location, and a modification content. The modification method includes adding, deleting, and replacing.

[0017] According to the resource modification method provided by the present invention, the modification content includes the variable value extracted from the target resource.

[0018] According to the resource modification method provided by the present invention, the method further includes:

[0019] Based on the external plug-in address defined in the modification strategy, the resource is sent to the external plug-in address to modify the resource, and the modified resource returned by the external plug-in address is received.

[0020] The present invention also provides a resource modification device, which is applied to an admission control component in a container orchestration system, and the device includes:

[0021] An instance receiving unit receives an instance of a user-defined resource carried in a resource publishing request, wherein the instance of the resource includes a modification policy of the resource;

[0022] The resource screening unit is used to screen the resources based on the modification strategy, obtain target resources that meet the modification strategy, and modify the target resources.

[0023] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any one of the resource modification methods described above is implemented.

[0024] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the resource modification method described in any one of the above is implemented.

[0025] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the resource modification methods described above.

[0026] The resource modification method, device, electronic device and storage medium provided by the present invention define the resource modification strategy in the form of user-defined resources. Without modifying the source code, it is only necessary to dynamically add instances of user-defined resources, so that directional modifications can be flexibly and meticulously performed when the resources are published, so that when the specified conditions are met, the required configuration can be automatically added to the resources, which has better flexibility and higher efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0028] Figure 1 This is one of the flow charts of the resource modification method provided by the present invention.

[0029] Figure 2 It is a flowchart of step 120 in the resource modification method provided by the present invention.

[0030] Figure 3 This is the second flow chart of the resource modification method provided by the present invention.

[0031] Figure 4 It is a system architecture diagram of the admission control component provided by the present invention.

[0032] Figure 5 It is a structural schematic diagram of the resource modification device provided by the present invention.

[0033] Figure 6 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0034] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0035] Gatekeeper has two main functions:

[0036] Admission Controller: When the Gatekeeper component is deployed in the Kubernetes cluster, all requests to create, update, or delete resources on the API server will trigger the Gatekeeper admission webhook. These requests will be processed by Gatekeeper, and if they do not meet the defined policies, the requests will be rejected. This helps ensure that only resources that meet specific policies can be created or modified.

[0037] Audit: Gatekeeper also provides an audit function that allows administrators to see which resources are violating which policies. This helps administrators understand the overall state of the cluster, not just the state of a single object. With the audit function, administrators can better monitor and manage the compliance of the cluster.

[0038] In related technologies, Gatekeeper's modification of resources usually involves modifying source code, resulting in poor flexibility and efficiency.

[0039] In order to solve the problem of poor flexibility and efficiency in resource modification, the inventive concept of the present invention is to: receive an instance of a user-defined resource carried in a resource release request, the instance of the resource includes a modification policy for the resource; screen the resources based on the modification policy, obtain the target resource that satisfies the modification policy, and modify the target resource. Use user-defined resources (Custom Resource Definition, CRD) to define the modification method of a certain type of resource in the container orchestration system (Kubernetes, k8s). Without modifying the source code, you only need to dynamically add crd to flexibly and meticulously perform targeted modifications when the resource is released, so that when the specified conditions are met, the required configuration can be automatically added to the resource, which is more flexible and efficient.

[0040] Based on the above-mentioned inventive concept, the present invention provides a resource modification method, device, electronic device and storage medium, which can be applied to resource dynamic modification scenarios in the field of cloud native technology to provide a more flexible and efficient resource modification solution.

[0041] The technical solution of the present invention will be described in detail below with reference to the accompanying drawings. Figure 1This is one of the flow charts of the resource modification method provided by the present invention. The execution subject of each step in the method can be a resource modification device, which can be implemented by software. The device can be integrated in an electronic device, which can be a terminal device (such as a smart phone, a personal computer, etc.), a server (such as a local server or a cloud server, or a server cluster, etc.), a processor, or a chip, etc. This embodiment takes the resource modification device deployed in the admission control component Gatekeeper in the container orchestration system as an example. Figure 1 As shown, the method comprises the following steps:

[0042] Step 110: Receive a user-defined resource instance carried in a resource publishing request, where the resource instance includes a resource modification policy.

[0043] Specifically, container orchestration systems (such as Kubernetes, Docker Swarm, etc.) usually provide an API interface to receive requests to create, update, or delete resources for the API server. All requests will trigger the Gatekeeper's admission webhook.

[0044] After receiving a resource publishing request, the container orchestration system sends the request to Gatekeeper, which then processes it further. For example, it can verify the validity of the request, including the format and signature of the request. At the same time, it also needs to verify whether the requester has the authority to publish the resource.

[0045] After verification, the information in the request can be parsed, especially the instances of user-defined resources. These instances usually contain resource definitions, configurations, and modification policies. User-defined resources (Custom Resource Definition, CRD) is a concept in Kubernetes that allows users to define their own resource types, which extend the core object model on the Kubernetes API server. Through CRD, users can create, view, update, and delete instances of custom resources (Custom Resource, CR), just like operating Kubernetes built-in resources (such as Pods, Services, etc.).

[0046] Step 120 , based on the modification policy, screen the resources, obtain the target resources that meet the modification policy, and modify the target resources.

[0047] In this step, the modification policy may be parsed. The modification policy is extracted from the user-defined resource instance. The modification policy may include a series of conditions and actions to specify which resources need to be modified and how to modify them. Preferably, the modification policy includes at least one of modification conditions, modification specifications, resource attributes, and external plug-in addresses.

[0048] According to the modification conditions in the modification policy, existing resources in the system are filtered. These conditions may be based on the type, tag, status, etc. of the resource. The target resource here is the resource that needs to be modified according to the modification policy.

[0049] Prepare to modify the target resource according to the modification specifications in the modification policy. The modification operation may include updating the resource configuration, restarting the resource, deleting the resource, etc.

[0050] On this basis, the modification operation can be performed to execute the prepared modification operation on the filtered target resources. During the execution process, it may be necessary to interact with the container orchestration system or other related systems to ensure the correctness and consistency of the modification operation.

[0051] After the modification is completed, you can further verify whether the modification results meet expectations. For example, check whether the resource status and configuration have been updated according to the modification policy. You can also record the relevant information of the modification operation in the log for subsequent tracking and auditing.

[0052] The method provided by the embodiment of the present invention defines the resource modification strategy in the form of user-defined resources. Without modifying the source code, it only needs to dynamically add instances of user-defined resources, so that targeted modifications can be flexibly and meticulously performed when the resources are released, so that when the specified conditions are met, the required configuration can be automatically added to the resources, which has better flexibility and higher efficiency.

[0053] Based on any of the above embodiments, Figure 2 is a flow chart of step 120 in the resource modification method provided by the present invention, such as Figure 2 As shown, in step 120, based on the modification strategy, resources are screened to obtain target resources that meet the modification strategy, specifically including:

[0054] Step 121, based on the resource attributes defined in the modification policy, the corresponding resource attributes are screened for resources to obtain initial resources, where the resource attributes include resource group, version, and type;

[0055] Step 122: Based on the modification conditions defined in the modification policy, the initial resources are screened for the corresponding modification conditions to obtain the target resources.

[0056] Specifically, considering that in related technologies, without modifying the source code, Gatekeeper can only modify a type of resource YAML simply based on resource attributes, and cannot modify the resource YAML based on more detailed conditions. YAML (YetAnother Markup Language) is a data serialization format commonly used for configuration files, and is widely used in container orchestration systems such as Kubernetes. In Kubernetes, YAML files are used to define and describe resource objects, such as Pods, Deployments, Services, etc.

[0057] For example, if the pod labels are required to have a == b, adding a node affinity setting cannot be achieved without modifying the source code.

[0058] In the embodiment of the present invention, the modification strategy not only defines resource attributes, but also defines more detailed modification conditions, so as to realize resource screening based on both resource attributes and modification conditions. The resource attributes can be screened first, and then, based on the modification conditions, the initial resources obtained by the resource attribute screening can be screened more finely for a second time to obtain the target resource. The resource attributes here can uniquely identify the resource object, specifically including the resource group (Group), version (Version) and type (Kind).

[0059] In k8s, GVK (Group, Version, Kind) is the three attributes used to uniquely identify resource objects. Group refers to the resource group in the Kubernetes API, such as apps, batch, core, etc. Different resource groups may contain different resource types.

[0060] Version refers to the API version of the resource object, such as v1, v1beta1, v2alpha1, etc. Different API versions may represent different definitions or features of the resource object.

[0061] Kind refers to the type of resource object, such as Pod, Service, Deployment, etc. Kind is a key field in the YAML or JSON configuration file that is used to specify the object type of the defined resource.

[0062] These three attributes combined (Group / Version / Kind) can uniquely specify a resource object in Kubernetes. For example, the GVK of the Pod resource object is core / v1 / Pod, where core is the resource group, v1 is the API version, and Pod is the resource object type. In Kubernetes, all resource objects must have a GVK to facilitate operation and management by the Kubernetes controller.

[0063] After obtaining the initial resources through screening based on resource attributes, the initial resources can be screened at a finer granularity based on the modification conditions to obtain the resources that meet the modification strategy, that is, the target resources.

[0064] The method provided by the embodiment of the present invention adds modification conditions on the basis of resource attribute screening, can judge the specific content of the resource, and screen the k8s resources at a finer granularity.

[0065] In some embodiments, the modification condition includes operators and operands of a logical expression, the operators include at least one of equals, not equals, all conditions must be met, all conditions are not met, only one condition needs to be met, and one condition is not met, and the operands include variables.

[0066] Specifically, the modification condition is used to determine whether the resource needs to be modified. The modification condition includes the operator and operand of the logical expression, that is, the user can use the operator and operand to define a complex logical expression, namely the modification condition. Based on the user-defined logical expression, it is determined whether the resource needs to be modified.

[0067] Operator refers to the operator in the logical expression, and operand refers to the value in the logical expression. That is, the modification condition can be composed of three parts: operator, operand value, and values. The operand here can include variables, which can be any entity that can be assigned and compared, such as integers, strings, Boolean values, etc.

[0068] Here, operator operator is an enumeration containing 6 optional values: [Equals, NotEquals, And, AndNot, Or, OrNot].

[0069] Among them, Equals and NotEquals: correspond to equal and unequal judgments. Equals means checking whether two operands are equal, and NotEquals means checking whether two operands are unequal.

[0070] All conditions must be met (And): All sub-conditions must be true for the entire condition to be true.

[0071] All conditions are not met (AndNot): All sub-conditions must be false for the entire condition to be true.

[0072] Only one condition needs to be met (Or): The entire condition is true if at least one of the sub-conditions is true.

[0073] One condition is not satisfied (OrNot): The entire condition is true when at least one of the sub-conditions is false.

[0074] When the operator operator selects equal to (Equals) or not equal to (NotEquals), the operand value is used for judgment.

[0075] If the content is a regular expression, the operand can be isRegex, and the field is set to true. The operand can also be content, which can be a regular expression or a string that indicates the specific value of the content to be matched.

[0076] In other embodiments, if no initial resource satisfying the resource attribute is screened out, or no target resource satisfying the modification condition is screened out, the resource publishing request is rejected.

[0077] Specifically, in this embodiment, an initial screening is first performed based on the resource attribute GVK. If the initial resource that meets the resource attribute is not screened out, it means that there is no resource in k8s that meets the resource attribute setting, that is, no resource modification is required, and the resource release request is rejected.

[0078] For example, the resource attribute set in the instance of a custom resource is core / v1 / Pod. After screening, no initial resource that meets the core / v1 / Pod attribute is found, indicating that the resource does not meet the defined policy, and the resource release request is rejected.

[0079] In addition, if an initial resource that meets the resource attributes is screened, but a target resource that meets the customized modification conditions is not screened during the secondary screening of the initial resource, it means that the resource also does not meet the defined policy, and the resource publishing request is rejected.

[0080] Based on any of the above embodiments, modifying the target resource in step 120 includes:

[0081] The target resource is modified based on the modification specifications defined in the modification policy. The modification specifications include the modification method, the path of the modification location, and the modification content. The modification methods include adding, deleting, and replacing.

[0082] Specifically, considering that Gatekeeper can only add resources but cannot reduce or delete resources without modifying the source code, such as removing the matchExpressions.keys["jdos.jd.com / zone"] and keys["easy-algo"] conditions in affinity nodeAffinity, such requirements cannot be met.

[0083] In this embodiment, a modification specification is also defined in the instance of the customized resource, and the modification specification is used to guide the modification of the target resource. The modification specification includes the modification method, the path of the modification location, and the modification content.

[0084] Among them, the modification mode (op) refers to the modification method, which is an enumeration value, mainly including add, remove and replace. Add refers to adding new content to the resource, delete refers to removing content from the resource, and replace refers to replacing the existing content in the resource with new content.

[0085] The path to the modified location specifies the specific location in the resource that needs to be modified, usually a path or identifier.

[0086] Modified content refers to the specific content that needs to be added, deleted or replaced.

[0087] After identifying the target resource, you can perform modification operations on the target resource according to the modification specifications. For example, first locate the path to the modification location, insert new content at the specified location, or remove the content at the specified location, or replace the existing content with new content, and then save the modified resource. Before saving the modified resource, you can also perform necessary verification to ensure that the modification results meet expectations, which can include content verification, structure verification, or function verification. You can also record detailed information about the modification operation, including modification time, modification content, etc., for subsequent auditing and tracking.

[0088] The method provided in the embodiment of the present invention provides a rich modification method through a custom resource instance, and supports three methods of adding, deleting and replacing resources.

[0089] In some embodiments, the modified content includes variable values ​​extracted from the target resource.

[0090] Specifically, considering that in related technologies, Gatekeeper can only perform simple addition operations without modifying the source code, and the added content is also defined in advance, and variables cannot be defined in advance to determine the value of a variable based on a specific resource. For example, when a pod adds a nodeSelector, the key value is defined as a fixed value in advance, but the value is determined based on a label of the pod, that is, the value is a variable determined by the resource, not a fixed value.

[0091] In this embodiment, the modification content includes the variable value extracted from the target resource, that is, the target resource is parsed to extract the required variable value, and then the extracted variable value is used to perform the modification, rather than extracting a defined fixed value.

[0092] Based on any of the above embodiments, the resource modification method further includes:

[0093] Based on the external plug-in address defined in the modification strategy, the resource is sent to the external plug-in address to modify the resource, and the modified resource returned by the external plug-in address is received.

[0094] Specifically, when the modification requirements of a certain type of resource cannot be met, new functions can only be added by modifying the source code, resulting in poor scalability. In this embodiment, functions are extended by developing a pluggable plug-in application, that is, the instance of the custom resource also includes an external plug-in address, such as a URL or API endpoint.

[0095] When the external plugin address field has a value, the webhook will send the resource to the external plugin address for processing. According to the modification strategy, a request containing the resource is constructed. The request may contain the resource itself, the resource ID, other parameters or authentication information. Use appropriate programming libraries or tools (such as curl, requests library, etc.) to send the request to the external plugin address. The resource sending method here can be HTTP request (such as POST, PUT, etc.), file transfer protocol (such as FTP), or other data transmission methods.

[0096] Wait for the external plug-in to process the request and return the modified resource. Perform necessary processing on the returned resource according to the response format and modification strategy of the external plug-in. Specifically, it includes: capturing the response returned by the external plug-in and checking its status code or error message to confirm whether the processing is successful. Parsing the modified resource according to the response format of the external plug-in (such as JSON, XML, etc.). Verify whether the modified resource meets expectations, including content, structure or function verification.

[0097] The method provided by the embodiment of the present invention performs function expansion through pluggable plug-in applications, thereby improving the flexibility of resource modification.

[0098] Based on any of the above embodiments, Figure 3 This is the second flow chart of the resource modification method provided by the present invention. Figure 4 is the system architecture diagram of the admission control component provided by the present invention, such as Figure 3 and Figure 4 As shown, a resource modification method is provided, which is applied to an admission control component in a container orchestration system, and the method includes:

[0099] S1, receiving a user-defined resource instance (CR) carried in a resource publishing request, where the resource instance includes a resource modification policy.

[0100] S2, based on the modification strategy, filter the resources to obtain the target resources that meet the modification strategy. First, filter all cr lists by resource attribute gvk to select the cr lists that meet the conditions, then match them by modification conditions Conditions to select the final cr list that meets the conditions, and finally modify the resources of each cr in turn according to this list. Specifically, it includes: based on the resource attributes defined in the modification strategy, filter the resources for the corresponding resource attributes to obtain the initial resources. The resource attributes include resource group, version and type;

[0101] Based on the modification conditions defined in the modification strategy, the initial resources are screened for the corresponding modification conditions to obtain the target resources. The modification conditions include the operators and operands of the logical expression. The operators include at least one of equals, not equals, all conditions must be met, all conditions are not met, only one condition needs to be met, and one condition is not met. The operands include variables.

[0102] If the initial resource that meets the resource attributes is not filtered out, or the target resource that meets the modification conditions is not filtered out, the resource publishing request is rejected.

[0103] S3, modify the target resource. Specifically include:

[0104] The target resource is modified based on the modification specifications defined in the modification policy. The modification specifications include the modification method, the path of the modification location, and the modification content. The modification methods include adding, deleting, and replacing. The modification content includes the variable value extracted from the target resource.

[0105] S4, based on the external plug-in address defined in the modification strategy, sending the resource to the external plug-in address to modify the resource, and receiving the modified resource returned by the external plug-in address.

[0106] The method provided by the embodiment of the present invention adopts a dynamic modification strategy without changing the source code. The modification method of a certain type of k8s resource is defined by using a user-defined resource crd. Without modifying the source code, only the crd needs to be dynamically added to flexibly and meticulously modify the current resource when it is released, so that when the specified conditions are met, the required configuration can be automatically added to the resource.

[0107] Adopt more detailed judgment conditions and richer judgment logic. It is no longer a simple matter of modifying resources as long as the settings of gvk are met. Based on the gvk (group\version\kind) filtering, the present invention adds six conditions [Equals, NotEquals, And, AndNot, Or, OrNot] to judge the specific content of resources and classify k8s resources at a finer granularity.

[0108] In addition, it also provides a variety of modification methods. It supports three methods of resource modification: add, remove, and replace, and can extract variable values ​​according to specific resources. A new plug-in interface has been added. When the modification requirements of a certain type of resource cannot be met, a plug-in application can be developed to expand the function.

[0109] The resource modification device provided by the present invention is described below. The resource modification device described below and the resource modification method described above can be referenced to each other.

[0110] Based on any of the above embodiments, Figure 5 is a schematic diagram of the structure of the resource modification device provided by the present invention, such as Figure 5 As shown, the resource modification device includes:

[0111] An instance receiving unit 510 receives an instance of a user-defined resource carried in a resource publishing request, wherein the instance of the resource includes a modification policy of the resource;

[0112] The resource screening unit 520 is used to screen the resources based on the modification policy, obtain target resources that meet the modification policy, and modify the target resources.

[0113] The device provided by the embodiment of the present invention defines the resource modification strategy in the form of user-defined resources. Without modifying the source code, it only needs to dynamically add instances of user-defined resources, and can flexibly and meticulously perform targeted modifications when the resources are released, so that when the specified conditions are met, the required configuration can be automatically added to the resources, which has better flexibility and higher efficiency.

[0114] Based on any of the above embodiments, the resource screening unit is specifically used for:

[0115] Based on the resource attributes defined in the modification policy, the resource is screened for corresponding resource attributes to obtain an initial resource, wherein the resource attributes include a resource group, a version, and a type;

[0116] Based on the modification conditions defined in the modification policy, the initial resources are screened for the corresponding modification conditions to obtain the target resources.

[0117] Based on any of the above embodiments, the modification conditions include operators and operands of a logical expression, the operators include at least one of equals, not equals, all conditions must be met, all conditions are not met, only one condition needs to be met, and one condition is not met, and the operands include variables.

[0118] Based on any of the above embodiments, it also includes a request rejection unit, which is used to reject the resource release request if the initial resource that meets the resource attribute is not screened out, or the target resource that meets the modification condition is not screened out.

[0119] Based on any of the above embodiments, the resource screening unit is specifically used for:

[0120] The target resource is modified based on the modification specification defined in the modification policy. The modification specification includes a modification method, a path of a modification location, and a modification content. The modification method includes adding, deleting, and replacing.

[0121] Based on any of the above embodiments, the modification content includes a variable value extracted from the target resource.

[0122] Based on any of the above embodiments, it also includes a plug-in unit, which is used to send the resource to the external plug-in address to modify the resource based on the external plug-in address defined in the modification strategy, and receive the modified resource returned by the external plug-in address.

[0123] Figure 6 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute the resource modification method, which includes: receiving an instance of a user-defined resource carried in a resource publishing request, the instance of the resource including a modification strategy of the resource; based on the modification strategy, screening the resources to obtain target resources that meet the modification strategy, and modifying the target resources.

[0124] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0125] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the resource modification method provided by the above-mentioned methods, and the method includes: receiving an instance of a user-defined resource carried in a resource publishing request, the instance of the resource including a modification policy of the resource; based on the modification policy, screening the resources to obtain target resources that meet the modification policy, and modifying the target resources.

[0126] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the resource modification method provided by the above-mentioned methods, the method comprising: receiving an instance of a user-defined resource carried in a resource publishing request, the instance of the resource including a modification policy of the resource; based on the modification policy, screening the resources to obtain target resources that meet the modification policy, and modifying the target resources.

[0127] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0128] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0129] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A resource modification method, characterized in that: Applied to an admission control component in a container orchestration system, the method includes: Receiving an instance of a user-defined resource carried in a resource publishing request, wherein the instance of the resource includes a modification policy of the resource; Based on the modification strategy, the resources are screened to obtain target resources that meet the modification strategy, and the target resources are modified, where the target resources refer to the resources that need to be modified; The screening of the resources based on the modification strategy to obtain target resources that meet the modification strategy includes: Based on the resource attributes defined in the modification policy, the resource is screened for corresponding resource attributes to obtain an initial resource, wherein the resource attributes include a resource group, a version, and a type; Based on the modification conditions defined in the modification strategy, the initial resources are screened for the corresponding modification conditions to obtain the target resources. The modification conditions include operators and operands of logical expressions. The modification conditions are used to determine whether the initial resources need to be modified based on a custom logical expression.

2. The resource modification method according to claim 1, characterized in that: The operator includes at least one of equal to, not equal to, all conditions must be met, all conditions are not met, only one condition needs to be met, and one condition is not met, and the operand includes a variable.

3. The resource modification method according to claim 1, characterized in that: Also includes: If no initial resource satisfying the resource attribute is screened out, or no target resource satisfying the modification condition is screened out, the resource publishing request is rejected.

4. The resource modification method according to claim 1, characterized in that: The modifying the target resource includes: The target resource is modified based on the modification specification defined in the modification policy. The modification specification includes a modification method, a path of a modification location, and a modification content. The modification method includes adding, deleting, and replacing.

5. The resource modification method according to claim 4, characterized in that: The modification content includes the variable value extracted from the target resource.

6. The resource modification method according to any one of claims 1 to 5, characterized in that: The method further comprises: Based on the external plug-in address defined in the modification strategy, the resource is sent to the external plug-in address to modify the resource, and the modified resource returned by the external plug-in address is received.

7. A resource modification device, characterized in that: An admission control component applied to a container orchestration system, the device comprising: An instance receiving unit receives an instance of a user-defined resource carried in a resource publishing request, wherein the instance of the resource includes a modification policy of the resource; A resource screening unit, configured to screen the resources based on the modification strategy, obtain target resources satisfying the modification strategy, and modify the target resources, wherein the target resources refer to the resources that need to be modified; The resource screening unit is specifically used for: Based on the resource attributes defined in the modification policy, the resource is screened for corresponding resource attributes to obtain an initial resource, wherein the resource attributes include a resource group, a version, and a type; Based on the modification conditions defined in the modification strategy, the initial resources are screened for the corresponding modification conditions to obtain the target resources. The modification conditions include operators and operands of logical expressions. The modification conditions are used to determine whether the initial resources need to be modified based on a custom logical expression.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the resource modification method according to any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the resource modification method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Resource management method and device, electronic equipment and storage medium

    CN116431354A