Function management method and device, equipment and storage medium
By deploying resource controllers in a multi-cluster architecture, the adjustment and management of custom resources for the cluster functions of the master and slave clusters is solved, and the problem of cross-cluster application function instances in Serverless technology is not supported, which improves application flexibility.
Patent Information
- Application Number
- CN202510272182.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-07
- Publication Date
- 2025-06-27
AI Technical Summary
Existing Serverless technology usually does not support cross-cluster application function instances, resulting in low application flexibility.
A first resource controller is deployed on the main cluster, a second resource controller is deployed in the main cluster and the slave cluster, and a first resource controller is adjusted to the cluster function custom resources of the main cluster and the target slave cluster, and a function instance management is performed based on the adjusted cluster function custom resources through the second resource controller.
It realizes cross-cluster function instance management, improves application flexibility, and solves the problem that cross-cluster application function instances are not supported in existing Serverless technology.
Smart Images

Figure CN120216173A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular, to a function management method, apparatus, device, and storage medium. Background Art
[0002] Serverless is a cloud computing service model that allows developers to run and scale applications without managing and maintaining the underlying servers. With Serverless, users only need to write and upload code, and the platform will automatically prepare the required computing resources and run the code in an elastic and reliable manner. Among them, the platform bills according to the actual resource usage, helping users optimize costs, while providing high availability and scalability, enabling developers to focus on the development of business logic without caring about the management of the infrastructure. Therefore, it is becoming more and more widely used. However, the current Serverless usually only supports running function instances in a single cluster and does not support running function instances across clusters, resulting in low flexibility of applications. Summary of the Invention
[0003] The main purpose of this application is to provide a function management method, apparatus, device, and storage medium, aiming to solve the technical problem that the existing Serverless usually does not support running function instances across clusters and has low flexibility.
[0004] To achieve the above object, this application proposes a function management method. The method is applied to a multi-cluster architecture, and the multi-cluster architecture includes a main cluster and several slave clusters. A first resource controller and a second resource controller are deployed in the main cluster, and the second resource controller is deployed in each slave cluster. The method includes:
[0005] In response to a function instance management request, adjust the multi-cloud function custom resources on the main cluster;
[0006] Determine a target slave cluster based on the adjusted multi-cloud function custom resources;
[0007] Adjust the cluster function custom resources in the main cluster and the target slave cluster through the first resource controller;
[0008] Manage function instances in the main cluster and the target slave cluster through the second resource controller based on the adjusted cluster function custom resources.
[0009] In one embodiment, the function instance management request includes: a function instance creation request. The step of adjusting the multi-cloud function custom resources on the main cluster in response to the function instance management request includes:
[0010] In response to a function instance creation request, create a multi-cloud function custom resource on the primary cluster;
[0011] The step of determining the target secondary cluster based on the adjusted multi-cloud function custom resource includes:
[0012] Obtain the first cluster location information in the created multi-cloud function custom resource;
[0013] Determine a first target secondary cluster based on the first cluster location information, where the first target secondary cluster is the secondary cluster on which a function instance needs to be created.
[0014] In one embodiment, the step of adjusting the cluster function custom resources in the primary cluster and the target secondary cluster through the first resource controller includes:
[0015] Create cluster function custom resources in the primary cluster and the first target secondary cluster through the first resource controller;
[0016] The step of managing function instances in the primary cluster and the target secondary cluster by the second resource controller based on the adjusted cluster function custom resources includes:
[0017] Obtain the created cluster function custom resources through the second resource controller;
[0018] Obtain first function information and first configuration information according to the created cluster function custom resources through the second resource controller;
[0019] Create function instances in the primary cluster and the first target secondary cluster based on the first function information and the first configuration information.
[0020] In one embodiment, the function instance management request includes: a function instance update request; the step of adjusting the multi-cloud function custom resources on the primary cluster in response to the function instance management request includes:
[0021] In response to the function instance update request, update the multi-cloud function custom resources on the primary cluster;
[0022] The step of determining the target secondary cluster based on the adjusted multi-cloud function custom resource includes:
[0023] Obtain the second cluster location information in the updated multi-cloud function custom resource;
[0024] Determine a second target secondary cluster based on the second cluster location information, where the second target secondary cluster is the secondary cluster on which the function instance needs to be updated.
[0025] In one embodiment, the step of adjusting the cluster function custom resources in the master cluster and the target slave cluster by the first resource controller includes:
[0026] Determine whether there are cluster function custom resources in the master cluster and the second target slave cluster;
[0027] Based on the judgment result, perform adjustment operations on the cluster function custom resources in the master cluster and the second target slave cluster, and the adjustment operations include: update operation or deletion operation;
[0028] The step of managing function instances in the master cluster and the target slave cluster by the second resource controller based on the adjusted cluster function custom resources includes:
[0029] Obtain the adjusted cluster function custom resources through the second resource controller;
[0030] Determine the operation type corresponding to the adjusted cluster function custom resources;
[0031] If the operation type is an update operation, obtain second function information and second configuration information through the second resource controller according to the updated cluster function custom resources;
[0032] Update function instances in the master cluster and the second target slave cluster based on the second function information and the second configuration information.
[0033] In one embodiment, the function instance management request includes: a function instance deletion request; the step of adjusting the multi-cloud function custom resources on the master cluster in response to the function instance management request includes:
[0034] In response to the function instance deletion request, delete the multi-cloud function custom resources on the master cluster;
[0035] The step of determining the target slave cluster based on the adjusted multi-cloud function custom resources includes:
[0036] Obtain the third cluster location information in the deleted multi-cloud function custom resources;
[0037] Determine the third target slave cluster based on the third cluster location information, and the third target slave cluster is the slave cluster that needs to delete function instances.
[0038] In one embodiment, the step of adjusting the cluster function custom resources in the master cluster and the target slave cluster by the first resource controller includes:
[0039] Delete the cluster function custom resources in the master cluster and the third target slave cluster through the first resource controller;
[0040] The step of performing function instance management on the master cluster and the target slave clusters by the second resource controller based on the adjusted cluster function custom resources includes:
[0041] The second resource controller is used to monitor in real time whether there are deleted cluster function custom resources;
[0042] If so, delete the function instances in the master cluster and the third target slave cluster.
[0043] In addition, to achieve the above object, the present application also proposes a function management device. A multi-cluster architecture is provided in the device. The multi-cluster architecture includes a master cluster and several slave clusters. A first resource controller and a second resource controller are deployed in the master cluster, and the second resource controller is deployed in each slave cluster. The device includes:
[0044] A resource adjustment module, configured to adjust the multi-cloud function custom resources on the master cluster in response to a function instance management request;
[0045] A slave cluster determination module, configured to determine a target slave cluster based on the adjusted multi-cloud function custom resources;
[0046] The resource adjustment module is further configured to adjust the cluster function custom resources in the master cluster and the target slave clusters through the first resource controller;
[0047] A function management module, configured to perform function instance management on the master cluster and the target slave clusters by the second resource controller based on the adjusted cluster function custom resources.
[0048] In addition, to achieve the above object, the present application also proposes a function management device. The device includes: a memory, a processor, and a computer program stored on the memory and executable on the processor. The computer program is configured to implement the steps of the function management method as described above.
[0049] In addition, to achieve the above object, the present application also proposes a storage medium. The storage medium is a computer-readable storage medium. A computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the function management method as described above.
[0050] The present application provides a function management method. It is disclosed that in response to a function instance management request, the multi-cloud function custom resources on the primary cluster are adjusted; a target secondary cluster is determined based on the adjusted multi-cloud function custom resources; the cluster function custom resources in the primary cluster and the target secondary cluster are adjusted through a first resource controller; and function instance management of the primary cluster and the target secondary cluster is performed through a second resource controller based on the adjusted cluster function custom resources. Compared with the prior art where Serverless usually only supports function instances in a single cluster and does not support cross-cluster function instances, resulting in low application flexibility, since in the present invention, a first resource controller is deployed on the primary cluster, and second resource controllers are deployed in the primary cluster and the secondary clusters, it is possible to adjust the cluster function custom resources in the primary cluster and the target secondary cluster through the first resource controller, and perform function instance management of the primary cluster and the target secondary cluster through the second resource controller based on the adjusted cluster function custom resources, thereby solving the technical problem that Serverless in the prior art usually does not support cross-cluster function instances and has low flexibility. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] The accompanying drawings herein are incorporated into and constitute a part of this specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.
[0052] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the accompanying drawings required for use in the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0053] Figure 1 It is a schematic flowchart provided for Embodiment 1 of the function management method of the present application;
[0054] Figure 2 It is a deployment structure diagram of a multi-cluster architecture in the function management method of the present application;
[0055] Figure 3 It is an information display diagram in the resource controller of the function management method of the present application;
[0056] Figure 4 It is a schematic flowchart provided for Embodiment 2 of the function management method of the present application;
[0057] Figure 5 It is a schematic flowchart of the process of creating multi-cluster function instances in the function management method of the present application;
[0058] Figure 6 It is a schematic flowchart provided for Embodiment 3 of the function management method of the present application;
[0059] Figure 7 This is a schematic flow diagram for updating multi-cluster function instances in the function management method of this application;
[0060] Figure 8 This is a schematic flow diagram for deleting multi-cluster function instances in the function management method of this application;
[0061] Figure 9 This is a schematic module structure diagram of the function management device in the embodiment of this application;
[0062] Figure 10 This is a schematic device structure diagram of the hardware operating environment involved in the function management method in the embodiment of this application.
[0063] The implementation, functional features, and advantages of this application will be further described with reference to the embodiments and the accompanying drawings. Detailed implementation manners
[0064] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of this application and are not used to limit this application.
[0065] To better understand the technical solutions of this application, the following will be described in detail in conjunction with the accompanying drawings of the specification and the specific implementation manners.
[0066] The main solution of the embodiment of this application is: in response to a function instance management request, adjust the multi-cloud function custom resources on the master cluster; determine the target slave cluster based on the adjusted multi-cloud function custom resources; adjust the cluster function custom resources in the master cluster and the target slave cluster through the first resource controller; manage the function instances in the master cluster and the target slave cluster through the second resource controller based on the adjusted cluster function custom resources.
[0067] Since Serverless in the prior art usually only supports applying function instances in a single cluster and does not support applying function instances across clusters, the flexibility of the application is not high.
[0068] This application provides a solution. A first resource controller can be deployed on the master cluster, and second resource controllers can be deployed in the master cluster and the slave clusters, so that the cluster function custom resources in the master cluster and the target slave cluster can be adjusted through the first resource controller, and the function instances in the master cluster and the target slave cluster can be managed through the second resource controller based on the adjusted cluster function custom resources, thereby solving the technical problem that Serverless in the prior art usually does not support applying function instances across clusters and has low flexibility.
[0069] It should be noted that the execution subject of this embodiment can be a multi-cluster architecture with data processing, network communication, and program running functions, or an electronic device, function management device, etc. that can implement the above functions. Hereinafter, taking the function management device as an example (hereinafter referred to as the device), this embodiment and the following embodiments will be described.
[0070] Based on this, an embodiment of the present application provides a function management method. Refer to Figure 1 , Figure 1 which is a schematic flowchart of the first embodiment of the function management method of the present application.
[0071] In this embodiment, the function management method is applied to a multi-cluster architecture. The multi-cluster architecture includes a master cluster and several slave clusters. A first resource controller and a second resource controller are deployed in the master cluster, and the second resource controller is deployed in each slave cluster. The method includes steps S10 to S40:
[0072] Step S10: In response to a function instance management request, adjust the multi-cloud function custom resources on the master cluster.
[0073] In this embodiment, refer to Figure 2 , Figure 2 which is a deployment structure diagram of the multi-cluster architecture in the function management method of the present application. As Figure 2As shown in the figure, the multi-cluster architecture in this embodiment may include a master cluster and several slave clusters. Among them, two CRDs (Custom Resource Definitions) are deployed in the master cluster: the multi-cloud function custom resource MulticloudFunc and the cluster function custom resource ClusterFunc, as well as the first resource controller MulticloudFunc-controller-manager and the second resource controller ClusterFunc-controller-manager; the cluster function custom resource and the second resource controller are deployed in the slave cluster. In practical applications, the first resource controller can be used to manage and coordinate function or service instances deployed on different cloud platforms. At the same time, it can also be responsible for monitoring and managing the resource usage of these function or service instances, and executing automated tasks to ensure the effective utilization of resources and the availability of services; the second resource controller can be used to implement the management of functions or services within a single cloud cluster or the cluster, such as being responsible for creating, updating, deleting, and monitoring specific function or service instances within the cluster. At the same time, it can also automatically adjust the number, configuration, or status of service instances according to the status and requirements of the cluster to ensure the stability and reliability of services within the cluster. In this embodiment, the first resource controller and the second resource controller can respectively control operations such as the creation, update, and deletion of the multi-cloud function custom resource and the cluster function custom resource. Among them, the multi-cloud function custom resource can define the Serverless cross-cluster function instance resources, used to manage the Serverless function instances under multiple clusters, as well as related attribute definitions; the cluster function custom resource can define cross-cluster Serverless function instances, as well as related attribute definitions.
[0074] It should be noted that both the multi-cloud function custom resource and the cluster function custom resource in this embodiment contain a lot of information. Refer to Figure 3 , Figure 3 which is the information display diagram of the resource controller in the function management method of this application. As Figure 3As shown, the custom resources of the multi-cloud function can include: function information, instance information, configuration information, cluster location information, and differential configuration information; the custom resources of the cluster function can include: function information, instance information, and configuration information. Among them, the function information can be the function code package information required for creating a function, which can be a code project in a remote repository, or a local code Zip package, or a local binary package such as a Jar / War, or function image information, etc.; the instance information can be information such as the name and namespace of the function instance to be created; the configuration information can be the value of the relevant configuration of the function required by the user when creating a function instance; the cluster location information can be the location information of the cluster where the function instance is to be created; the differential configuration information can be the differential configuration information when deploying function instances in different clusters. In this embodiment, the function information and instance information in the custom resources of the cluster function can be generated respectively from the function information and instance information in the custom resources of the multi-cloud function, and the configuration information in the custom resources of the cluster function can be generated by combining the configuration information in the custom resources of the multi-cloud function with the differential configuration information.
[0075] It should be noted that the above function instance management request can be a request for indicating the creation, update, or deletion of a function instance. In this embodiment, the user can trigger a function instance management request by creating, updating, or deleting the custom resources of the multi-cloud function on the primary cluster. After detecting the function instance management request, the device can respond to it and adjust the custom resources of the multi-cloud function on the primary cluster, including creation, update, and deletion. For example, if the function instance management request is triggered by the user creating the custom resources of the multi-cloud function, the custom resources of the multi-cloud function can be created at this time; if the function instance management request is triggered by the user updating the custom resources of the multi-cloud function, the custom resources of the multi-cloud function can be updated at this time; if the function instance management request is triggered by the user deleting the custom resources of the multi-cloud function, the custom resources of the multi-cloud function can be deleted at this time.
[0076] Step S20: Determine the target secondary cluster based on the adjusted custom resources of the multi-cloud function.
[0077] It should be noted that the above target secondary cluster can be the secondary cluster where a function instance needs to be created, updated, or deleted. In this embodiment, the device can determine the secondary clusters where function instances need to be created, updated, or deleted through the cluster location information in the adjusted custom resources of the multi-cloud function, and determine these secondary clusters as the target secondary clusters.
[0078] Step S30: Adjust the custom resources of the cluster function in the primary cluster and the target secondary clusters through the first resource controller.
[0079] In this embodiment, after the device determines the target slave cluster for creating, updating, or deleting a function instance, the first resource controller can be used to create, update, or delete the cluster function custom resource in the master cluster and the target slave cluster.
[0080] Step S40: Based on the adjusted cluster function custom resource, the second resource controller is used to manage the function instances in the master cluster and the target slave cluster.
[0081] In practical applications, after the cluster function custom resource is created, updated, or deleted in the master cluster and the target slave cluster, the device can create, update, or delete function instances based on the created, updated, or deleted cluster function custom resource. For example, when the second resource controller monitors that the cluster function custom resource is created in the master cluster and the target slave cluster, the second resource controller can create function instances according to the information (including function information, instance information, and configuration information) in the currently created cluster function custom resource; when the second resource controller monitors that the cluster function custom resource in the master cluster and the target slave cluster is updated or deleted, it can update or delete function instances in the master cluster and the target slave cluster according to the information in the currently updated or deleted cluster function custom resource.
[0082] This embodiment provides a function management method. The method discloses that in response to a function instance management request, the multi-cloud function custom resource on the master cluster is adjusted; the target slave cluster is determined based on the adjusted multi-cloud function custom resource; the first resource controller is used to adjust the cluster function custom resource in the master cluster and the target slave cluster; the second resource controller is used to manage the function instances in the master cluster and the target slave cluster based on the adjusted cluster function custom resource. Compared with the prior art, Serverless usually only supports applying function instances in a single cluster and does not support applying function instances across clusters, resulting in low application flexibility. Since the first resource controller is deployed on the master cluster and the second resource controller is deployed in the master cluster and the slave cluster in this embodiment, the cluster function custom resource in the master cluster and the target slave cluster can be adjusted through the first resource controller, and the function instances in the master cluster and the target slave cluster can be managed based on the adjusted cluster function custom resource through the second resource controller, thereby solving the technical problem that Serverless in the prior art usually does not support applying function instances across clusters and has low flexibility.
[0083] Based on the first embodiment of this application, in the second embodiment of this application, for the same or similar content as in the above-mentioned first embodiment, reference can be made to the above introduction and will not be repeated hereinafter. On this basis, please refer to Figure 4 , Figure 4 which is the schematic flowchart provided for the second embodiment of the function management method of this application.
[0084] In this embodiment, the function instance management request includes: a function instance creation request; step S10 includes:
[0085] Step S101: In response to the function instance creation request, create a multi-cloud function custom resource on the master cluster.
[0086] It can be understood that the above function instance creation request can be a request for indicating the creation of a function instance. In this embodiment, when the user creates a multi-cloud function custom resource on the master cluster, the function instance creation request is triggered. After detecting the function instance creation request, the device can respond to it and create a multi-cloud function custom resource on the master cluster.
[0087] Correspondingly, step S20 includes:
[0088] Step S201: Obtain the first cluster location information in the created multi-cloud function custom resource.
[0089] It should be understood that the above first cluster location information can be the cluster location information in the currently created multi-cloud function custom resource.
[0090] Step S202: Determine a first target slave cluster based on the first cluster location information, where the first target slave cluster is the slave cluster on which a function instance needs to be created.
[0091] It can be understood that the above first target slave cluster is the slave cluster on which a function instance needs to be created. In this embodiment, the first cluster location information may include the location information of the cluster on which a function instance needs to be created. Therefore, the device can directly determine the first target slave cluster on which a function instance needs to be created from all slave clusters according to the first cluster location information.
[0092] Further, step S30 includes:
[0093] Step S301: Create a cluster function custom resource in the master cluster and the first target slave cluster through the first resource controller;
[0094] Correspondingly, step S40 includes:
[0095] Step S401: Obtain the created cluster function custom resource through the second resource controller.
[0096] In this embodiment, the second resource controller can monitor the created cluster function custom resources through the list-watch technology. The list-watch technology is a technology that uses both List and Watch operations to monitor and respond to changes in resource objects in real time. Among them, the List operation is to send an HTTP request to the Kubernetes API Server to obtain a list of all resource objects of a specified resource type; the Watch operation is to send a request to the Kubernetes API Server to establish a long connection for real-time monitoring of changes in the specified resource type.
[0097] Step S402: Obtain first function information and first configuration information according to the created cluster function custom resources through the second resource controller.
[0098] It should be understood that the above first function information can be the function information in the currently created cluster function custom resources; correspondingly, the above first configuration information can be the configuration information in the currently created cluster function custom resources.
[0099] Step S403: Create function instances in the main cluster and the first target slave cluster based on the first function information and the first configuration information.
[0100] It should be noted that if function instances need to be created, the second resource controller can obtain the function code package or image according to the first function information in the currently created cluster function custom resources, and at the same time determine the values of the relevant configurations of the user's required function according to the first configuration information in the currently created cluster function custom resources, so as to create Serverless function instances according to the function code package or image and the configuration values.
[0101] In a specific implementation, refer to Figure 5 , Figure 5 is a schematic flow diagram of creating multi-cluster function instances in the function management method of this application. As Figure 5As shown, if a multi-cluster function instance needs to be created, the user can first create a multi-cloud function custom resource on the primary cluster to trigger a function instance creation request. After detecting the function instance creation request, the multi-cluster architecture can respond to it and create a multi-cloud function custom resource. At this time, the user can obtain information that the multi-cloud function custom resource has started to be created. Then, the first resource controller can monitor the currently created multi-cloud function custom resource through the list-watch technology, and create a cluster function custom resource in the first target secondary cluster included in the first cluster location information according to the information in the currently created multi-cloud function custom resource. At this time, the second resource controller can monitor the currently created cluster function custom resource through the list-watch technology, obtain the function code package or image according to the first function information in the currently created cluster function custom resource, and create a Serverless function instance according to the function code package or image and the configuration value in the first configuration information. After that, the second resource controller can regularly obtain the status of the Serverless function instance and update the status of the cluster function custom resource. At the same time, the first resource controller can regularly obtain the status of the cluster function custom resources on each cluster and update the status of the multi-cloud function custom resource according to the status of the cluster function custom resources on each cluster.
[0102] In this embodiment, it is disclosed that in response to a function instance creation request, a multi-cloud function custom resource on the primary cluster is created; the first cluster location information in the created multi-cloud function custom resource is obtained; the first target secondary cluster is determined based on the first cluster location information, and the first target secondary cluster is the secondary cluster where the function instance needs to be created, so that the secondary cluster where the function instance needs to be created can be accurately determined from all secondary clusters; at the same time, in this embodiment, the first resource controller creates a cluster function custom resource in the primary cluster and the first target secondary cluster; the second resource controller obtains the created cluster function custom resource; the second resource controller obtains the first function information and the first configuration information according to the created cluster function custom resource; a function instance is created in the primary cluster and the first target secondary cluster based on the first function information and the first configuration information, so that the second resource controller can create a function instance in the primary cluster and the first target secondary cluster according to the first function information and the first configuration information, thus realizing the creation of function instances across clusters.
[0103] Based on the first embodiment and / or the second embodiment of the present application, in the third embodiment of the present application, for the same or similar content as the above embodiments, reference can be made to the above introduction and will not be elaborated hereinafter. On this basis, please refer to Figure 6 , Figure 6 which is a schematic flowchart provided for the third embodiment of the function management method of the present application.
[0104] In this embodiment, the function instance management request includes: a function instance update request; step S10 further includes:
[0105] Step S111: In response to the function instance update request, update the multi-cloud function custom resource on the primary cluster.
[0106] It can be understood that the above function instance update request can be a request for indicating to update the function instance. In this embodiment, when the user updates the multi-cloud function custom resource on the primary cluster, a function instance update request is triggered. After the device detects the function instance update request, it can respond to it and update the multi-cloud function custom resource on the primary cluster.
[0107] Correspondingly, step S20 includes:
[0108] Step S211: Obtain the second cluster location information in the updated multi-cloud function custom resource.
[0109] It should be understood that the above second cluster location information can be the cluster location information in the updated multi-cloud function custom resource.
[0110] Step S212: Determine a second target secondary cluster based on the second cluster location information, where the second target secondary cluster is the secondary cluster that needs to update the function instance.
[0111] It can be understood that the above second target secondary cluster is the secondary cluster that needs to update the function instance. In this embodiment, the second cluster location information may include the location information of the cluster that needs to update the function instance. Therefore, the device can directly determine the second target secondary cluster that needs to update the function instance from all secondary clusters according to the second cluster location information.
[0112] Furthermore, step S30 includes:
[0113] Step S311: Determine whether there is a cluster function custom resource in the primary cluster and the second target secondary cluster.
[0114] Step S312: Perform an adjustment operation on the cluster function custom resource in the primary cluster and the second target secondary cluster based on the judgment result, where the adjustment operation includes: an update operation or a deletion operation.
[0115] It can be understood that the above update operation can be an operation to update the custom resource of the cluster function; correspondingly, the above deletion operation can be an operation to delete the custom resource of the cluster function. In this embodiment, the first resource controller can update the custom resource of the cluster function on the second target slave cluster included in the second cluster location information according to various information (including function information, instance information, configuration information, and differential configuration information) in the updated custom resource of the multi-cloud function. Among them, if there was a custom resource of the cluster function on the second target slave cluster before, but there is no custom resource of the cluster function after the update, then at this time, it is necessary to delete the custom resource of the cluster function on this cluster. Therefore, in this embodiment, when updating the custom resource of the cluster function, it can be determined whether there is a custom resource of the cluster function in the master cluster and the second target slave cluster. If there was a custom resource of the cluster function in the master cluster and the second target slave cluster before, and there is still a custom resource of the cluster function after the update, then the update operation can be performed on the custom resource of the cluster function; if there was a custom resource of the cluster function in the master cluster and the second target slave cluster before, but there is no custom resource of the cluster function after the update, then the deletion operation can be performed on the custom resource of the cluster function.
[0116] Correspondingly, step S40 includes:
[0117] Step S411: Obtain the adjusted custom resource of the cluster function through the second resource controller.
[0118] In this embodiment, the second resource controller can listen for the updated or deleted custom resource of the cluster function through the list-watch technology.
[0119] Step S412: Determine the operation type corresponding to the adjusted custom resource of the cluster function.
[0120] Step S413: If the operation type is an update operation, obtain the second function information and the second configuration information according to the updated custom resource of the cluster function through the second resource controller.
[0121] It should be understood that the above second function information can be the function information in the updated custom resource of the cluster function; correspondingly, the above second configuration information can be the configuration information in the updated custom resource of the cluster function.
[0122] Step S414: Update the function instances in the master cluster and the second target slave cluster based on the second function information and the second configuration information.
[0123] It should be noted that if it is necessary to update the function instance, the second resource controller can obtain the function code package or image according to the second function information in the updated cluster function custom resource, and at the same time determine the values of the relevant configurations of the user's required function according to the second configuration information in the updated cluster function custom resource, so that the Serverless function instance can be updated according to the function code package or image and the configuration values.
[0124] In a specific implementation, refer to Figure 7 , Figure 7 which is a schematic flow chart for updating multi-cluster function instances in the function management method of this application. As Figure 7 shown, if it is necessary to update multi-cluster function instances, the user can first update the multi-cloud function custom resource on the primary cluster to trigger a function instance update request. After the multi-cluster architecture detects the function instance update request, it can respond to it and update the multi-cloud function custom resource. At this time, the user can obtain the information that the multi-cloud function custom resource is being updated. Then, the first resource controller can monitor the currently updated multi-cloud function custom resource through the list-watch technology, and update the cluster function custom resource in the second target slave cluster included in the second cluster location information according to the information in the updated multi-cloud function custom resource. Among them, if there was a cluster function custom resource on this cluster before and there is none after the update, it is necessary to delete the cluster function custom resource on this cluster at this time; if there was a cluster function custom resource on this cluster before and the update still exists, the cluster function custom resource on this cluster can be updated at this time. Then, the second resource controller can monitor the currently updated cluster function custom resource through the list-watch technology, and judge whether to delete the cluster function custom resource according to the above logic. If so, delete the function instance; if not, update the cluster function custom resource. When updating the cluster function custom resource, the second resource controller can first obtain the function code package or image according to the second function information in the currently created cluster function custom resource, and then update the Serverless function instance according to the function code package or image and the configuration values in the second configuration information. After that, the second resource controller can regularly obtain the status of the function instance and update the status of the cluster function custom resource. In addition, if the function instance is deleted, it is necessary to delete the cluster function custom resource at this time. At the same time, the first resource controller can regularly obtain the status of the cluster function custom resources on each cluster, or confirm whether the cluster function custom resources have been deleted, and then update the status of the multi-cloud function custom resource.
[0125] Furthermore, the function instance management request includes: a function instance deletion request; step S10 includes:
[0126] Step S121: In response to a function instance deletion request, delete the multi-cloud function custom resource on the primary cluster.
[0127] It can be understood that the above function instance deletion request can be a request for indicating the deletion of a function instance. In this embodiment, when the user deletes the multi-cloud function custom resource on the primary cluster, a function instance deletion request is triggered. After detecting the function instance deletion request, the device can respond to it and delete the multi-cloud function custom resource on the primary cluster.
[0128] Correspondingly, step S20 includes:
[0129] Step S221: Obtain the third cluster location information in the deleted multi-cloud function custom resource.
[0130] It should be understood that the above third cluster location information can be the cluster location information in the currently deleted multi-cloud function custom resource.
[0131] Step S222: Determine the third target slave cluster based on the third cluster location information, where the third target slave cluster is the slave cluster that needs to delete the function instance.
[0132] It can be understood that the above third target slave cluster is the slave cluster that needs to delete the function instance. In this embodiment, the third cluster location information may include the location information of the cluster where the function instance needs to be deleted. Therefore, the device can directly determine the third target slave cluster that needs to delete the function instance from all slave clusters according to the third cluster location information.
[0133] Furthermore, step S30 includes:
[0134] Step S321: Delete the cluster function custom resource in the primary cluster and the third target slave cluster through the first resource controller;
[0135] Correspondingly, step S40 includes:
[0136] Step S421: Through the second resource controller, monitor in real time whether there is a deleted cluster function custom resource.
[0137] Step S422: If there is, delete the function instance in the primary cluster and the third target slave cluster.
[0138] In this embodiment, the second resource controller can monitor whether there is a deleted cluster function custom resource through the list-watch technology. If there is, delete the function instance in the primary cluster and the third target slave cluster.
[0139] In specific implementation, refer to Figure 8 , Figure 8This is a schematic flowchart of the process for deleting multi-cluster function instances in the function management method of this application. As Figure 8 shown, if it is necessary to delete multi-cluster function instances, the user can first delete the multi-cloud function custom resource on the primary cluster to trigger a function instance deletion request. After the multi-cluster architecture detects the function instance deletion request, it can respond to it and delete the multi-cloud function custom resource. At this time, the user can obtain information that the multi-cloud function custom resource is being deleted. Then, the first resource controller can monitor the deleted multi-cloud function custom resource through the list-watch technology, and delete the cluster function custom resource in the third target slave cluster included in the third cluster location information according to the information in the deleted multi-cloud function custom resource. Then, the second resource controller can monitor the deleted cluster function custom resource through the list-watch technology and delete the Serverless function instance. After that, the second resource controller can periodically obtain the status of the Serverless function instance to determine whether the Serverless function instance has been deleted. If it has been deleted, the cluster function custom resource is deleted. At the same time, the first resource controller can periodically obtain the status of the cluster function custom resources on each cluster to confirm whether the cluster function custom resources on each cluster have been deleted, and update the status of the multi-cloud function custom resource according to whether the cluster function custom resources on each cluster have been deleted, and delete the multi-cloud function custom resource.
[0140] In this embodiment, in response to a function instance update request, the multi-cloud function custom resource on the primary cluster is updated; the second cluster location information in the updated multi-cloud function custom resource is obtained; based on the second cluster location information, a second target slave cluster is determined, and the second target slave cluster is the slave cluster that needs to update the function instance, so that the slave cluster that needs to update the function instance can be accurately determined from all slave clusters; at the same time, in this embodiment, the second resource controller can update the function instance in the primary cluster and the second target slave cluster according to the second function information and the second configuration information, thereby realizing cross-cluster update of the function instance. In addition, in this embodiment, the third target slave cluster that needs to delete the function instance can be accurately determined first based on the third cluster location information in the deleted multi-cloud function custom resource, and the second resource controller can delete the function instance in the primary cluster and the third target slave cluster, thereby realizing cross-cluster deletion of the function instance.
[0141] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the function management method of this application. Based on this technical concept, more forms of simple transformations are within the protection scope of this application.
[0142] This application also provides a function management device. Please refer to Figure 9, a multi - cluster architecture is set in the device. The multi - cluster architecture includes a master cluster and several slave clusters. A first resource controller and a second resource controller are deployed in the master cluster, and the second resource controller is deployed in each slave cluster, including:
[0143] A resource adjustment module 10, configured to respond to a function instance management request and adjust the multi - cloud function custom resources on the master cluster;
[0144] A slave cluster determination module 20, configured to determine a target slave cluster based on the adjusted multi - cloud function custom resources;
[0145] The resource adjustment module 10 is further configured to adjust the cluster function custom resources in the master cluster and the target slave cluster through the first resource controller;
[0146] A function management module 30, configured to perform function instance management on the master cluster and the target slave cluster through the second resource controller based on the adjusted cluster function custom resources.
[0147] The function management device provided by this application adopts the function management method in the above - mentioned embodiment, and can solve the technical problem that Serverless in the prior art usually does not support cross - cluster application function instances and has low flexibility. Compared with the prior art, the beneficial effects of the function management device provided by this application are the same as those of the function management method provided by the above - mentioned embodiment, and other technical features in the function management device are the same as those disclosed in the method of the above - mentioned embodiment, which will not be elaborated here.
[0148] This application provides a function management device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the function management method in the first embodiment above.
[0149] Next, refer to Figure 10 , which shows a schematic structural diagram of a function management device suitable for implementing the embodiments of this application. The function management device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions: tablet computers), PMPs (Portable Media Players), in - vehicle terminals (such as in - vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 10The function management device shown is only an example and should not impose any limitations on the functions and scope of use of the embodiments of the present application.
[0150] As Figure 10 shown, the function management device may include a processing device 1001 (such as a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM: Random Access Memory) 1004. In the RAM 1004, various programs and data required for the operation of the function management device are also stored. The processing device 1001, the ROM 1002, and the RAM 1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the function management device to communicate with other devices wirelessly or wiredly to exchange data. Although the figure shows a function management device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be alternatively implemented or had.
[0151] In particular, according to the embodiments disclosed in the present application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program codes for executing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network through the communication device, or installed from the storage device 1003, or installed from the ROM 1002. When the computer program is executed by the processing device 1001, the above functions defined in the methods of the embodiments disclosed in the present application are executed.
[0152] The function management device provided by the present application adopts the function management method in the above embodiments and can solve the technical problems of function management. Compared with the prior art, the beneficial effects of the function management device provided by the present application are the same as those of the function management method provided by the above embodiments, and other technical features in the function management device are the same as those disclosed in the method of the previous embodiment and will not be elaborated here.
[0153] It should be understood that each part disclosed in this application can be implemented by hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in a suitable manner in any one or more embodiments or examples.
[0154] As described above, it is only the specific implementation manner of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in this application, and all should be covered within the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.
[0155] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., computer programs) stored thereon, and the computer-readable program instructions are used to execute the function management method in the above embodiments.
[0156] The computer-readable storage medium provided by this application can be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM) or flash memory, optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this embodiment, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, device, or device. The program code contained on the computer-readable storage medium can be transmitted by any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0157] The above computer-readable storage medium can be included in the function management device; it can also exist separately without being assembled into the function management device.
[0158] The above computer-readable storage medium stores one or more programs which, when executed by a function management device, cause the function management device to: in response to a function instance management request, adjust the multi-cloud function custom resources on the primary cluster; determine a target secondary cluster based on the adjusted multi-cloud function custom resources; adjust the cluster function custom resources in the primary cluster and the target secondary cluster through a first resource controller; and perform function instance management on the primary cluster and the target secondary cluster through a second resource controller based on the adjusted cluster function custom resources.
[0159] Computer program code for performing the operations of this application may be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may execute entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0160] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that, in some alternative implementations, the functions marked in the blocks may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combinations of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system for performing the specified functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.
[0161] The modules described in the embodiments of this application may be implemented in software or in hardware. In some cases, the name of the module does not constitute a limitation on the unit itself.
[0162] The readable storage medium provided by this application is a computer-readable storage medium. The computer-readable storage medium stores computer-readable program instructions (i.e., computer programs) for executing the above function management method, which can solve the technical problem that Serverless in the prior art usually does not support cross-cluster application function instances and has low flexibility. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by this application are the same as those of the function management method provided by the above embodiments, and will not be elaborated here.
[0163] The above are only partial embodiments of this application, and do not limit the patent scope of this application accordingly. Any equivalent structural transformation made by using the content of the specification and drawings of this application under the technical concept of this application, or direct / indirect application in other related technical fields, is included in the patent protection scope of this application.
Claims
1. A function management method, characterized in that: The method is applied to a multi-cluster architecture, the multi-cluster architecture includes a master cluster and a plurality of slave clusters, the master cluster is deployed with a first resource controller and a second resource controller, and each slave cluster is deployed with the second resource controller, the method includes: In response to the function instance management request, adjusting the multi-cloud function custom resources on the main cluster; Determine the target slave cluster based on the adjusted multi-cloud function custom resource; Adjusting the cluster function custom resources in the master cluster and the target slave cluster by the first resource controller; Function instance management is performed on the master cluster and the target slave cluster based on the adjusted cluster function custom resources by the second resource controller.
2. The method according to claim 1, characterized in that The function instance management request includes: a function instance creation request; the step of adjusting the multi-cloud function custom resources on the main cluster in response to the function instance management request includes: In response to the function instance creation request, create a multi-cloud function custom resource on the primary cluster; The step of determining the target slave cluster based on the adjusted multi-cloud function custom resource includes: Get the location information of the first cluster in the created multi-cloud function custom resource; A first target slave cluster is determined based on the first cluster location information, where the first target slave cluster is a slave cluster for which a function instance needs to be created.
3. The method according to claim 2, characterized in that The step of adjusting the cluster function custom resources in the main cluster and the target slave cluster by the first resource controller includes: Creating a cluster function custom resource in the main cluster and the first target slave cluster by using the first resource controller; The step of performing function instance management on the main cluster and the target slave cluster based on the adjusted cluster function custom resource by the second resource controller includes: Obtain the created cluster function custom resource through the second resource controller; Acquiring first function information and first configuration information according to the created cluster function custom resource through the second resource controller; A function instance is created in the primary cluster and the first target slave cluster based on the first function information and the first configuration information.
4. The method according to claim 1, characterized in that The function instance management request includes: a function instance update request; the step of adjusting the multi-cloud function custom resources on the main cluster in response to the function instance management request includes: In response to the function instance update request, updating the multi-cloud function custom resources on the main cluster; The step of determining the target slave cluster based on the adjusted multi-cloud function custom resource includes: Get the location information of the second cluster in the updated multi-cloud function custom resource; A second target slave cluster is determined based on the second cluster location information, where the second target slave cluster is a slave cluster for which function instances need to be updated.
5. The method according to claim 4, characterized in that The step of adjusting the cluster function custom resources in the main cluster and the target slave cluster by the first resource controller includes: Determine whether there are cluster function custom resources in the main cluster and the second target slave cluster; Based on the judgment result, an adjustment operation is performed on the cluster function custom resource in the main cluster and the second target slave cluster, where the adjustment operation includes: an update operation or a delete operation; The step of performing function instance management on the main cluster and the target slave cluster based on the adjusted cluster function custom resource by the second resource controller includes: Acquire the adjusted cluster function custom resource through the second resource controller; Determine the operation type corresponding to the adjusted cluster function custom resource; If the operation type is an update operation, obtaining second function information and second configuration information according to the updated cluster function custom resource through the second resource controller; Function instances are updated in the primary cluster and the second target slave cluster based on the second function information and the second configuration information.
6. The method according to claim 1, characterized in that The function instance management request includes: a function instance deletion request; the step of adjusting the multi-cloud function custom resources on the main cluster in response to the function instance management request includes: In response to the function instance deletion request, deleting the multi-cloud function custom resources on the main cluster; The step of determining the target slave cluster based on the adjusted multi-cloud function custom resource includes: Get the location information of the third cluster in the deleted multi-cloud function custom resource; A third target slave cluster is determined based on the third cluster location information, where the third target slave cluster is a slave cluster from which the function instance needs to be deleted.
7. The method according to claim 6, characterized in that The step of adjusting the cluster function custom resources in the main cluster and the target slave cluster by the first resource controller includes: Deleting the cluster function custom resource from the cluster in the main cluster and the third target by the first resource controller; The step of performing function instance management on the main cluster and the target slave cluster based on the adjusted cluster function custom resource by the second resource controller includes: Monitoring in real time whether there is a deleted cluster function custom resource through the second resource controller; If so, the function instance is deleted from the primary cluster and the third target cluster.
8. A function management device, characterized in that: The device is provided with a multi-cluster architecture, the multi-cluster architecture includes a master cluster and a plurality of slave clusters, the master cluster is deployed with a first resource controller and a second resource controller, each slave cluster is deployed with the second resource controller, and the device includes: A resource adjustment module, configured to adjust the multi-cloud function custom resources on the main cluster in response to a function instance management request; A slave cluster determination module, used to determine a target slave cluster based on the adjusted multi-cloud function custom resources; The resource adjustment module is further used to adjust the cluster function custom resources in the main cluster and the target slave cluster through the first resource controller; The function management module is used to manage the function instances of the master cluster and the target slave cluster based on the adjusted cluster function custom resources through the second resource controller.
9. A function management device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the function management method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the function management method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Custom workload scheduling method and system in multi-cluster environment
CN116244079A