Multi-cluster container management method and device, electronic equipment and storage medium
By introducing pre-defined management objects and CRDs into the global control cluster, the complexity and consistency issues of managing Kubernetes container scheduling platforms in multi-cluster deployments are resolved, achieving unified management and efficient upgrades of containers and reducing operational costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CCB FINTECH CO LTD
- Filing Date
- 2021-03-29
- Publication Date
- 2026-04-10
AI Technical Summary
In existing technologies, Kubernetes container scheduling platforms cannot achieve unified management of containers in multi-cluster deployment scenarios, resulting in complex operations, inability to guarantee container consistency, and lack of batch upgrade functionality, leading to a waste of human and material resources.
By introducing preset management objects and container management requests into the global control cluster, unified management of business containers in subordinate clusters is achieved, including container creation and automated injection and upgrade of auxiliary functions. Unified management across clusters is realized by utilizing the Custom Resource Definition (CRD) and Operator framework.
It reduces the difficulty of container management in multi-cluster deployments, improves the efficiency of container upgrades, reduces human and material costs, and achieves unified and consistent container management.
Smart Images

Figure CN112905306B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of automatic programming, and in particular to a multi-cluster container management method and device, electronic equipment and storage medium. BACKGROUND
[0002] Application programs and services often need other related functions, such as monitoring, logging, centralized configuration and network services, and these peripheral functions are often integrated in the application program, and the peripheral functions run in the same process as the application program and are not well isolated. Once the peripheral function is interrupted, it will cause the crash of other functions or the whole application program. In the prior art, the Sidecar mode in the kubernetes container scheduling platform is often used to deploy these peripheral functions as individual components in their own processes or containers.
[0003] However, the support for the Sidecar mode in the native kubernetes is weak, and the following problems exist when deploying the system through the native resource type in Kubernetes: 1. In a multi-cluster deployment scenario, a business application program needs to rely on multiple containers, and when managing the containers, an operation and maintenance personnel needs to manually add multiple containers for deployment, operate services, and cannot guarantee the consistency of the containers in different clusters. 2. The native Kubernetes does not have a batch upgrade function, and cannot uniformly upgrade the containers, and must log in to each cluster to upgrade the container version and notify the business project to rebuild the business image, resulting in waste of manpower and resources. SUMMARY
[0004] The present application provides a multi-cluster container management method, device, electronic equipment and storage medium, applied to the technical field of automatic programming, to uniformly manage the containers under multiple clusters, reduce the operation difficulty of adding new containers, improve the container upgrade efficiency, and reduce the container management cost in the multi-cluster deployment scenario.
[0005] In a first aspect, the embodiments of the present application provide a multi-cluster container management method, which comprises:
[0006] Obtaining a container management request input by a user;
[0007] According to the container management request and a preset management object, managing a business container in a slave cluster.
[0008] In a second aspect, the embodiments of the present application further provide a multi-cluster container management method, which comprises:
[0009] Obtaining a container management instruction sent by a global control cluster, wherein the container management instruction is determined according to the container management request and the preset management object;
[0010] managing the business container according to the container management instruction.
[0011] In a third aspect, an embodiment of the present application further provides a multi-cluster container management device, which comprises:
[0012] a request acquisition module, configured to acquire a container management request input by a user;
[0013] a container management module, configured to manage a business container in a subordinate cluster according to the container management request and a preset management object.
[0014] In a fourth aspect, an embodiment of the present application further provides a multi-cluster container management device, which comprises:
[0015] an instruction acquisition module, configured to acquire a container management instruction sent by a global control cluster, wherein the container management instruction is determined according to the container management request and the preset management object;
[0016] a management execution module, configured to manage a business container according to the container management instruction.
[0017] In a fifth aspect, an embodiment of the present application further provides an electronic device, which comprises:
[0018] one or more processors;
[0019] a memory, configured to store one or more programs;
[0020] When the one or more programs are executed by the one or more processors, the one or more processors implement the multi-cluster container management method according to any of the embodiments of the present application.
[0021] In a sixth aspect, an embodiment of the present application further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the multi-cluster container management method according to any of the embodiments of the present application.
[0022] According to the embodiments of the present application, the container management request input by the user is collected, the preset management object and the container management request are used to manage the business container in the subordinate cluster, the unified management of the business container in the subordinate cluster is implemented, the maintenance difficulty of the business container is reduced, and the container management cost under the multi-cluster deployment condition is reduced. BRIEF DESCRIPTION OF DRAWINGS
[0023] Figure 1 is a flowchart of a multi-cluster container management method provided by an embodiment of the present application;
[0024] Figure 2 is an example diagram of a cluster architecture provided by an embodiment of the present application;
[0025] Figure 3 is a flowchart of another multi-cluster container management method provided by Embodiment Two of the present application;
[0026] Figure 4 is a flowchart of another multi-cluster container management method provided by Embodiment Three of the present application;
[0027] Figure 5 is a flowchart of a multi-cluster container management method provided by Embodiment Four of the present application;
[0028] Figure 6 is a flowchart of another multi-cluster container management method provided by Embodiment Five of the present application;
[0029] Figure 7 is a structural schematic diagram of a multi-cluster container management device provided by Embodiment Six of the present application;
[0030] Figure 8 is a structural schematic diagram of another multi-cluster container management device provided by Embodiment Seven of the present application;
[0031] Figure 9 is a structural schematic diagram of an electronic device provided by Embodiment Eight of the present application. DETAILED DESCRIPTION
[0032] The present application will be further described below in conjunction with the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the present application, but not to limit the present application. In addition, it should be noted that, for the convenience of description, only the parts related to the present application are shown in the drawings, and the entire structure is not shown. Furthermore, the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.
[0033] Embodiment One
[0034] Figure 1 is a flowchart of a multi-cluster container management method provided by Embodiment One of the present application. The present embodiment can be applied to the case of uniformly managing the business containers of multiple clusters. The method can be executed by a multi-cluster container management device, which can be realized in the form of hardware and / or software, and is generally integrated in a global control cluster, which can be a server cluster, for managing slave clusters, as shown in Figure 1 The multi-cluster container management method provided by the present embodiment specifically includes the following steps:
[0035] Step 110: Obtain the container management request input by a user.
[0036] The container management request can be a request of a user to manage a service container in the dependent cluster, the service container can be a service logic running instance, the service container can be a series of processes isolated from other parts, the container management request can include a creation request and an update request of the service container, and the container management request can include the service container to be managed and the dependent cluster corresponding to the service container.
[0037] In the embodiment of the application, the container management request of the user can be directly input to the global control cluster, the input container management request can be acquired by the monitoring thread of the global control cluster, the global control cluster can be used as an entrance of the container management request, the service containers in the dependent clusters are uniformly managed, and the management efficiency of the service containers can be improved.
[0038] Exemplarily, Figure 2 is an example of a cluster architecture provided by the embodiment of the application, referring to Figure 2 In a Kubernetes cluster, the global control cluster can be a management cluster, the dependent clusters can be business clusters and be managed by the management cluster, and the capacity management request input by the user can be listened to by using the Operator operation in the global control cluster.
[0039] In step 120, the service container in the dependent cluster is managed according to the container management request and the preset management object.
[0040] The preset management object can be an instance object for the management of the service container, can include an instance for the creation process of the service container and an instance for the update of the service container, and can be customized according to the user demand in advance.
[0041] Specifically, the global control cluster can determine the service container to be managed and the corresponding dependent cluster according to the container management request, and then call the corresponding preset management object to manage the service container in the dependent cluster.
[0042] Further, on the basis of the above-mentioned embodiment of the application, the preset management object at least includes one of a service container management object and an auxiliary function management object.
[0043] In the embodiment of the application, the service container management object and the auxiliary function management object can be instantiated in the global control cluster in advance, the service container management object can be used for the creation of the service container, the related parameters and control logic for creating the service container are set in the service container management object in advance, the auxiliary function management object can be an instance object for managing the auxiliary function in the service container, and the related parameters and control logic for updating the auxiliary function can be set in the auxiliary function management object in advance.
[0044] The embodiment of the application realizes the management of the business container in the dependent cluster by collecting the container management request input by the user, using the preset management object and the container management request, realizes the unified management of the business container in the dependent cluster, reduces the maintenance difficulty of the business container, and reduces the container management cost under the multi-cluster deployment condition.
[0045] Embodiment two
[0046] Figure 3 is a flowchart of another multi-cluster container management method provided by the second embodiment of the application, and the embodiment of the application is a specific embodiment based on the above-mentioned application embodiment, and the method provided by the embodiment of the application specifically includes the following steps: Figure 3
[0047] Step 210, obtaining the container management request input by the user, wherein the container management request at least includes one of a container creation request and a container update request.
[0048] Step 220, obtaining the business container management object corresponding to the container creation request.
[0049] The container creation request can be a request of the user for creating a business container, and the container creation request can include the business container to be created and the dependent cluster for creating the business container, and the container creation request can be specifically a creation request of the business container management object.
[0050] Specifically, the global control cluster can find the corresponding business container management object according to the container creation request, for example, when the container creation request is accepted, the business container management object can be automatically created to realize the creation of the business container.
[0051] Step 221, extracting the expected deployment cluster and the expected instance number in the business container management object.
[0052] The business container management object can be a preset instance for container management, and the business container management object can include the expected deployment cluster and the preset instance number. The expected deployment cluster can be the dependent cluster for creating the business container, and the preset instance number can represent the number of the dependent clusters to be created. Further, the expected deployment cluster and the expected instance number in the business container management object can also be associated, and each of the expected deployment clusters can have a corresponding expected instance number, and the expected instance numbers of different dependent clusters can be the same or different. The business container management object can be preset according to the user demand or the cluster architecture.
[0053] In the embodiment of the present application, the expected deployment cluster is extracted in the service container object, the expected deployment cluster can be preset as a slave cluster in which the service container needs to be created, and the expected instance number can be extracted in the service container object, the expected instance number can be the number of service containers created in each slave cluster in which the service container needs to be created.
[0054] Step 222, creating the service container according to the expected deployment cluster and the expected instance number.
[0055] Specifically, the global control cluster can create the service container for each slave cluster corresponding to the expected deployment cluster, and control the number of service containers created by each slave cluster to reach the expected instance number.
[0056] Step 230, modifying the auxiliary function container template of the auxiliary function management object according to the container update request.
[0057] The container update request can be a request for updating the function implemented by the service container, the service container can be composed of one or more auxiliary functions, and the update of the service container can be implemented by updating the auxiliary function. The auxiliary function management object can be an instantiated function management object, the auxiliary function management object can be used to update the auxiliary function in the service container, the auxiliary function container template can be preconfigured in the auxiliary function management object, the auxiliary function container template can store the auxiliary function information in the service container, and the service container can be configured with one or more auxiliary functions in the auxiliary function container template. The auxiliary functions configured for different service containers can be the same or different.
[0058] Specifically, when the global control cluster obtains the container update request, the auxiliary function container template in the auxiliary function management object can be modified, for example, the new auxiliary function sent in the container update request can be added to the auxiliary function container template, or the corresponding auxiliary function in the auxiliary function container template can be deleted according to the deleted auxiliary function sent in the container update request, and the update and upgrade of the service container in each slave cluster can be triggered by modifying the auxiliary function container template.
[0059] Step 231, when the auxiliary function management object is updated, controlling each slave cluster to update the service container according to the auxiliary function management object.
[0060] Specifically, the global control cluster can also listen to the auxiliary function management object, and when the auxiliary function management object is updated, the global control cluster can trigger the control of the slave cluster to update the service container. The global control cluster can call the updated auxiliary function management object to update the service container in each slave cluster, and change the auxiliary function in the service container.
[0061] In the embodiment of the application, the global control cluster obtains a container management request input by a user, the container management request including a container creation request and a container update request, a corresponding business container management object is obtained when the container creation request is obtained, and an expected deployment cluster and an expected instance number in the business container management object are extracted, and a business container is created in a slave cluster according to the preset deployment cluster and the expected instance number, when the container update request is obtained, an auxiliary function container template in the auxiliary function management object is modified according to the container update request, and when the auxiliary function management object is updated, the business container is updated in each slave cluster according to the auxiliary function management object, the instantiated business container management object and the auxiliary function management object are called through the container management request, the difficulty of business container management in multiple clusters is reduced, the degree of unified management of the global control cluster on the business container of the slave cluster is improved, the business container creation and upgrade overhead is reduced, manual control of the business container upgrade of each slave cluster by an operation and maintenance personnel is avoided, and the waste of human and material resources is avoided.
[0062] Further, on the basis of the above-mentioned embodiment of the application, the method further comprises managing the slave cluster according to the cluster management object, wherein the management includes adding, deleting and updating the slave cluster information.
[0063] In the embodiment of the application, the global control cluster can also generate an instantiated object for the cluster management of the slave cluster, and the control logic for adding, deleting and updating the slave cluster information can be preset in the cluster management object, further reducing the difficulty of the slave cluster management.
[0064] Embodiment three
[0065] Figure 4 is a flowchart of another multi-cluster container management method provided by the third embodiment of the application, and the embodiment of the application is a specific embodiment on the basis of the above-mentioned embodiment of the application, and the embodiment of the application is described in detail with reference to Figure 4 The method provided by the embodiment of the application specifically includes the following steps:
[0066] Step 310, obtaining a container management request input by a user, wherein the preset management object includes at least one of a business container management object and an auxiliary function management object.
[0067] Step 320, obtaining a business container management object corresponding to a container creation request.
[0068] Step 321, extracting an expected deployment cluster and an expected instance number in the business container management object.
[0069] Step 322, connecting to at least one slave cluster according to the expected deployment cluster.
[0070] In the embodiment of the present application, the global control cluster can establish a communication connection with the slave clusters contained in the preset deployment cluster, the communication connection can include wired connection or wireless connection, and the control command of the global control cluster can be sent to the slave clusters establishing the connection.
[0071] In step 323, the global control cluster controls the slave clusters to create service containers.
[0072] Specifically, the global control cluster can send control instructions to the slave clusters through the established connection, and the slave clusters can create service containers after obtaining the control instructions.
[0073] In step 324, it is judged whether the number of service containers created in the slave clusters meets the requirement of the expected instance number, if yes, the creation of the service containers is completed, and if not, the slave clusters are controlled to continue creating service containers until the number of service containers meets the requirement of the expected instance number.
[0074] In the embodiment of the present application, the global control cluster can also monitor the slave clusters to determine whether the number of service containers created in the slave clusters meets the requirement of the preset instance number, for example, the number of service containers created in the slave clusters is equal to the preset instance number, which can be determined to meet the requirement of the preset instance number. If the service containers of the slave clusters meet the requirement of the preset instance number, the slave clusters complete the creation of the service containers, and if the service containers of the slave clusters do not meet the requirement of the preset instance number, the slave clusters are controlled to continue creating service containers until the number of created service containers meets the requirement of the preset instance number.
[0075] In step 330, the auxiliary function container template of the auxiliary function management object is modified according to the container update request.
[0076] In step 331, when the auxiliary function management object is monitored to be updated, the service containers of the slave clusters are traversed, and it is judged whether the service auxiliary function of the service container is consistent with the service auxiliary function in the auxiliary function container template of the auxiliary function management object.
[0077] In the embodiment of the present application, the global control cluster can monitor the auxiliary function management object, and after detecting that the auxiliary function management object is updated, the global control cluster can contact the slave clusters and obtain the service containers in the slave clusters, and judge whether the service auxiliary function in each service container is completely the same as the service auxiliary function in the auxiliary function container template of the updated auxiliary function management object.
[0078] In step 332, if yes, the service container is not updated, and if not, the service auxiliary function in the auxiliary function container template is injected into the service container.
[0079] Specifically, for each service container, if all service auxiliary functions in a service container are completely consistent with the service auxiliary functions in the auxiliary function container template, it is determined that the service container does not need to be updated, and if one or more auxiliary service functions in the service container are not the same as the service auxiliary functions in the auxiliary function container template, all service auxiliary functions in the auxiliary function container template are injected into the service container to realize the update of the service container.
[0080] In the embodiment of the application, the global control cluster obtains a container management request input by a user, the container management request including a container creation request and a container update request, the corresponding service container management object is obtained when the container creation request is obtained, the intended deployment cluster and the intended instance number in the service container management object are extracted, the corresponding slave cluster of the intended deployment cluster is connected, and the service container is created according to the remainder instance number, the auxiliary function container template in the auxiliary function management object is modified according to the container update request when the container update request is obtained, the service container of each slave cluster is updated according to the auxiliary function management object when the auxiliary function management object is updated, the instantiated service container management object and auxiliary function management object are called through the container management request, the difficulty of service container management in multiple clusters is reduced, the degree of unified management of the service container of the slave cluster by the global control cluster is improved, the service container creation and upgrade overhead is reduced, manual control of the service container upgrade of each slave cluster by the operation and maintenance personnel is avoided, and the waste of human and material resources is avoided.
[0081] Further, on the basis of the above-mentioned embodiment of the application, the control of the slave cluster to create a service container includes: obtaining an auxiliary function container template in the auxiliary function management object, wherein the auxiliary function container template includes at least one service auxiliary function; controlling each slave cluster to create a service container; and injecting each service auxiliary function into each service container according to the auxiliary function container template.
[0082] In the embodiment of the application, when the slave cluster is controlled to create a service container, the corresponding auxiliary function needs to be injected into each service container, which specifically can include that the global control cluster calls the auxiliary function management object, obtains the auxiliary function container template in the auxiliary function management object, and injects the service auxiliary function into the service container created in the slave cluster according to the auxiliary function container template.
[0083] Embodiment four
[0084] Figure 5is a flowchart of a multi-cluster container management method provided by Embodiment Four of the present application. The embodiment can be applicable to the case of uniformly managing business containers of multiple clusters. The method can be executed by a multi-cluster container management device, which can be realized in the form of hardware and / or software and is generally integrated in a subordinate cluster, which can be a server cluster and is used to execute business functions. See Figure 5 The multi-cluster container management method provided by the embodiment of the present application specifically includes the following steps.
[0085] In step 410, a container management instruction sent by the global control cluster is acquired, wherein the container management instruction is determined according to a container management request and a preset management object.
[0086] The container management instruction can be an instruction for managing the business container and can control the creation of the business container or the update of the auxiliary function of the business container.
[0087] In the embodiment of the present application, the subordinate cluster can listen to the container management instruction sent by the global control cluster, which can be determined by the global control cluster according to the container management request and the preset management object. For example, the container management instruction can be preset in the preset management object. When the global control cluster acquires the container management request, the preset management object is called to trigger the sending of the capacity management instruction to the subordinate cluster.
[0088] In step 420, the business container is managed according to the container management instruction.
[0089] Specifically, the subordinate cluster can manage the business container according to the acquired container management instruction, for example, can newly create the business container or update the auxiliary function in the business container.
[0090] In the embodiment of the present application, the subordinate cluster listens to the container management instruction sent by the global control cluster and manages the business container according to the container management instruction, thereby realizing the uniform management of the business container in the subordinate cluster, reducing the difficulty of maintaining the business container in the multiple subordinate cluster scenario, and saving the manpower and material cost of managing the business container.
[0091] Embodiment Five
[0092] Figure 6 is a flowchart of another multi-cluster container management method provided by Embodiment Five of the present application. The embodiment is a specific embodiment based on the above-mentioned embodiments of the present application. See Figure 6 The method provided by the embodiment of the present application specifically includes the following steps.
[0093] In step 510, a container management instruction sent by the global control cluster is acquired, wherein the container management instruction is determined according to the container management request and the preset management object, and the container management instruction includes at least one of a container creation instruction and a container update instruction.
[0094] In the embodiment of the application, the container creation instruction and / or the container update instruction sent by the global control cluster can be received, wherein the container creation instruction can be an instruction indicating that the slave cluster creates a service container, and the container update instruction can be an instruction updating the auxiliary function of the service container.
[0095] Further, on the basis of the above-mentioned embodiment of the application, the preset management object includes at least one of a service container management object and an auxiliary function management object.
[0096] In step 520, the expected instance number in the container creation instruction is extracted, and the service container of the expected instance number is created.
[0097] Specifically, the container creation instruction can include an expected instance number, which can represent the number of service containers that the slave cluster needs to create. The slave cluster can extract the expected instance number from the container creation instruction, and create the service container corresponding to the expected instance number.
[0098] Further, on the basis of the above-mentioned embodiment of the application, the creation of the service container includes:
[0099] The auxiliary function container template in the auxiliary function management object in the global control cluster is received, wherein the auxiliary function container template includes at least one service auxiliary function; and the service container is created, and each service auxiliary function is injected into the service container according to the auxiliary function container template.
[0100] In the embodiment of the application, the slave cluster can receive the auxiliary function container template sent by the global control cluster, the auxiliary function container template can be pre-set in the auxiliary function management object of the global control cluster, the service container can be created, and the auxiliary service function in the auxiliary function container template is injected into the newly created service container.
[0101] In step 530, the auxiliary function container template in the auxiliary function management object in the global control cluster is received.
[0102] Specifically, when the container update instruction is received, the global control cluster can be listened to, and the auxiliary function container template in the auxiliary function management object is received.
[0103] In step 531, it is judged whether the service auxiliary function of the service container is consistent with the service auxiliary function in the auxiliary function container template of the auxiliary function management object, if yes, the service container is not updated, and if not, the service auxiliary function in the auxiliary function container template is injected into the service container.
[0104] In the embodiment of the present application, the dependent cluster determines whether the service auxiliary functions in each service container are completely identical with the service auxiliary functions in the auxiliary function container template of the updated auxiliary function management object. For each service container, if all the service auxiliary functions in a service container are completely identical with the service auxiliary functions in the auxiliary function container template, it is determined that the service container does not need to be updated, and if one or more auxiliary service functions in the service container are not identical with the service auxiliary functions in the auxiliary function container template, all the service auxiliary functions in the auxiliary function container template are injected into the service container to realize the update of the service container.
[0105] In the embodiment of the present application, the container management instruction sent by the global control cluster is acquired, when the container management instruction is a container creation instruction, the expected instance number in the container creation instruction is extracted, and the service container is created according to the expected instance number, when the container management instruction is a container update instruction, the auxiliary function container template of the auxiliary function management object in the global control cluster is received, if the service container is consistent with the auxiliary service function in the auxiliary function container template, the service container is not updated, if the service container is not consistent with the auxiliary function service function in the auxiliary function container template, the service auxiliary function is injected into the service container according to the auxiliary function container template, the difficulty of service container management in the multi-cluster is reduced, the degree of unified management of the service container of the dependent cluster by the global control cluster is improved, the service container creation and upgrade overhead is reduced, the manual control of the service container upgrade of each dependent cluster by the operation and maintenance personnel is avoided, and the waste of human and material resources is avoided.
[0106] Further, on the basis of the above-mentioned embodiment of the application, the method further comprises: sending the dependent cluster information to the global control cluster to update the cluster management object.
[0107] The dependent cluster information can include unique identification information and working state information of the dependent cluster, and the dependent cluster information can be used for the global control cluster to uniformly manage the dependent cluster.
[0108] In the embodiment of the present application, the dependent cluster can send the dependent cluster information to the global control cluster, the global control cluster can update the cluster management object according to the dependent cluster information, the global control cluster can manage the dependent cluster through the cluster management object, and the control logic for managing the dependent cluster can be preset in the cluster management object.
[0109] In a typical implementation, Kubernetes clusters provide various resource types, such as resource objects (Pod, ReplicaSet, Deployment, StatefulSet, Job, CronJob, etc.), configuration objects (Node, Namespace, ConfigMap, Ingress, Secret, etc.), storage objects (PersistentVolume, etc.), and policy objects (ResourceQuota, LimitRange, etc.). These resource types can meet the requirements of most distributed system deployments. However, different application business environments have some unique requirements for the platform, and the native resource types cannot meet these requirements.
[0110] Taking our use case as an example, deployment using traditional resource types cannot solve the following pain points:
[0111] 1. Each of our business applications requires six agents, which are maintained by the data center. All business applications need to use the latest version of the agents. Kubernetes does not natively have an automatic batch injection function. On native Kubernetes, operations personnel need to manually add, deploy, and maintain these six agent containers when deploying business applications, which is complex and cannot guarantee consistency.
[0112] 2. If the traditional "fat container" deployment mode is adopted, and the 6 agents and business applications are built in the same image, when the data center needs to upgrade the agent version, all business project teams need to be notified to rebuild the image. Moreover, when the image is re-released, it will cause the business applications to be restarted, wasting a lot of manpower and resources and generating some unnecessary change operations.
[0113] 3. The native Kubernetes does not have a batch upgrade function. When deployed in the Sidecar mode, when it is necessary to upgrade the version of 6 agents, it is necessary to log in to each Kubernetes cluster to perform the upgrade operation on the native resource objects, which is complex to operate and maintain.
[0114] 4. Our business applications cannot be deployed in a single Kubernetes cluster in a production environment. They need to be deployed across Kubernetes clusters. Kubernetes native resource objects do not support cross-cluster deployment. Using native resource objects requires manually creating resource objects with the same name on the deployed Kubernetes clusters, which makes unified management impossible.
[0115] A layer can be extracted on top of the business cluster in the kubernetes cluster as a global control cluster, which is essentially also a set of kubernetes clusters. The global control cluster can manage the kubernetes clusters in a cluster management manner to achieve unified management of the kubernetes clusters. Custom Resource Definition (CRD) is an important feature in the kubernetes cluster. The cluster can support custom resource types through CRD. Operator utilizes this feature of CRD to manage the life cycle of CRD. The development of Operator needs to use operator-framework. Operator-framework is an open source project that provides a component framework for cloud native developers to develop Operator. It mainly includes three components: 1. Operator SDK. Integrates controller-runtime to provide: high-level APIs for writing operational logic, a scaffolding tool for quickly building Operator projects and code generation, and extensions covering common Operator use cases. Operator SDK is the most core project in Operator Framework. 2. Operator Lifecycle Manager: Life cycle management of all Operators (and associated services) within the K8S cluster. 3. Operator Metering: Provides monitoring of Operators themselves to provide some customized services.
[0116] Based on the above, three CRD objects of Cluster, AlcorGroup, and SidecarGroup can be created on the global control cluster. Cluster manages the information of the business cluster, AlcorGroup manages the Pod containers of the business cluster, and SidecarGroup manages the auxiliary functions in the Pod containers of the business cluster.
[0117] First, a CRD named Cluster is created in the kubernetes cluster, which records the cluster information. By maintaining this CR, the existing cluster list can be managed. Another CRD named AlcorGroup is created, which can be regarded as an upgraded version of the kubernetes native resource object Deployment and StatefulSet. The CRD is created on the global control cluster. When the operator on the global control cluster listens to the creation of the CRD object, it will create the expected Pod object on the target cluster according to the detailed definition in the CRD object. The CRD object will define the list of clusters where the Pod object is expected to be deployed, and the instance number of the Pod object on each expected deployment cluster. The process of creating a Pod container for a business cluster is as follows: 1. The operator listens to the creation of the AlcorGroup object; 2. The operator establishes a connection with the target cluster according to the list of expected deployment clusters and the list of instance numbers on each expected deployment cluster defined in the AlcorGroup, and listens to and judges whether the number of Pod objects on the cluster meets the expectation. If not, the Pod is created according to the Pod object template defined in the AlcorGroup until the expected number is met. Through the way of kubernetes managing kubernetes, and an AlcorGroup-Operator running on the global control cluster and a CRD object named AlcorGroup, the cross-cluster unified management of deploying applications is realized.
[0118] The process of batch injection and upgrade of auxiliary functions of Pod containers for business clusters is as follows: When the AlcorGroup-Operator creates a Pod, it will first read the global SidecarGroup to obtain the list of Sidecar container templates that the Pod needs to inject. When creating the Pod, these Sidecar containers will be automatically injected into the Pod. When the Sidecar containers need to be upgraded, only the SidecarGroup object needs to be modified and updated. The SidecarGroup-Operator will listen to the changes of the SidecarGroup, traverse and compare all Pods on all clusters, detect whether the Sidecar containers in the Pods are consistent with the templates defined in the SidecarGroup, and update the containers if they are not consistent. The whole process does not require human intervention and will not affect the business main container. The pre-created CRD object named SidecarGroup stores the list of Sidecar container templates that need to be automatically injected within the entire cluster range.
[0119] Embodiment six
[0120] Figure 7 is a structural schematic diagram of a multi-cluster container management device provided by embodiment six of the application. The device can execute the multi-cluster container management device provided by any embodiment of the application, has a function module and beneficial effects corresponding to the execution method. The device can be realized by software and / or hardware, and specifically includes: a request acquisition module 601 and a container management module 602.
[0121] The request acquisition module 601 is configured to acquire a container management request input by a user.
[0122] The container management module 602 is configured to manage a service container in a subordinate cluster according to the container management request and a preset management object.
[0123] In the embodiment of the application, the request acquisition module collects the container management request input by the user, and the container management module uses the preset management object and the container management request to manage the service container in the subordinate cluster, thereby realizing unified management of the service container in the subordinate cluster, reducing the maintenance difficulty of the service container, and reducing the container management cost in the multi-cluster deployment case.
[0124] Further, on the basis of the above-mentioned application embodiment, the preset management object at least includes one of a service container management object and an auxiliary function management object.
[0125] Further, on the basis of the above-mentioned application embodiment, the container management module 602 includes:
[0126] The creation request unit is configured to acquire a service container management object corresponding to the container creation request.
[0127] The extraction unit is configured to extract an expected deployment cluster and an expected instance number in the service container management object.
[0128] The container creation unit is configured to create a service container according to the expected deployment cluster and the expected instance number.
[0129] Further, on the basis of the above-mentioned application embodiment, the container creation unit has functions of:
[0130] connecting to at least one subordinate cluster according to the expected deployment cluster; controlling each subordinate cluster to create a service container; judging whether the number of the created service containers in each subordinate cluster meets the requirement of the expected instance number, if yes, completing the creation of the service container, and if not, controlling the subordinate cluster to continue creating the service container until the number of the service containers meets the requirement of the expected instance number.
[0131] Further, on the basis of the above-mentioned application embodiment, the container management module 602 includes:
[0132] an update request unit configured to modify the auxiliary function container template of the auxiliary function management object according to the container update request.
[0133] an update management unit configured to, when the auxiliary function management object is updated, control each of the slave clusters to update the service container according to the auxiliary function management object.
[0134] Further, on the basis of the above-mentioned embodiments, the update management unit is specifically configured to: traverse the service container of each of the slave clusters, and determine whether the service auxiliary function of the service container is consistent with the service auxiliary function in the auxiliary function container template of the auxiliary function management object; if yes, the service container is not updated; and if no, the service auxiliary function in the auxiliary function container template is injected into the service container.
[0135] Further, on the basis of the above-mentioned embodiments, the device further comprises:
[0136] a cluster management module configured to manage the slave clusters according to a cluster management object, wherein the management includes adding, deleting and updating slave cluster information.
[0137] Embodiment Seven
[0138] Figure 8 is a structural schematic diagram of another multi-cluster container management device provided by Embodiment Seven of the present application, which can execute the multi-cluster container management device provided by any of the embodiments of the present application, has the corresponding function modules and beneficial effects of the execution method. The device can be realized by software and / or hardware, and specifically includes: an instruction acquisition module 701 and a management execution module 702.
[0139] The instruction acquisition module 701 is configured to acquire the container management instruction sent by the global control cluster, wherein the container management instruction is determined according to the container management request and the preset management object.
[0140] The management execution module 702 is configured to manage the service container according to the container management instruction.
[0141] In the embodiments of the present application, the instruction acquisition module acquires the container management instruction sent by the global control cluster in the slave cluster, and the management execution module manages the service container according to the container management instruction, thereby realizing the unified management of the service container in the slave cluster, reducing the difficulty of service container maintenance in the multi-slave cluster scenario, and saving the human and material costs of service container management.
[0142] Further, on the basis of the above-mentioned embodiments, the preset management object at least includes one of a service container management object and an auxiliary function management object.
[0143] Further, on the basis of the above-mentioned embodiment of the application, the management execution module 702 comprises:
[0144] The creation execution unit is configured to extract the expected instance number in the container creation instruction, and create a service container of the expected instance number.
[0145] Further, on the basis of the above-mentioned embodiment of the application, the creation execution unit comprises:
[0146] The template receiving sub-unit is configured to receive an auxiliary function container template in the auxiliary function management object in the global control cluster, wherein the auxiliary function container template comprises at least one service auxiliary function.
[0147] The creation execution sub-unit is configured to create a service container, and inject each service auxiliary function in the auxiliary function container template into the service container.
[0148] Further, on the basis of the above-mentioned embodiment of the application, the management execution module 702 comprises:
[0149] The update receiving unit is configured to receive an auxiliary function container template in the auxiliary function management object in the global control cluster.
[0150] The update execution unit is configured to judge whether the service auxiliary function of the service container is consistent with the service auxiliary function in the auxiliary function container template of the auxiliary function management object, if consistent, the service container is not updated, if not consistent, the service auxiliary function in the auxiliary function container template is injected into the service container.
[0151] Further, on the basis of the above-mentioned embodiment of the application, the device further comprises:
[0152] The cluster information module is configured to send the subordinate cluster information to the global control cluster to update the cluster management object.
[0153] Embodiment eight
[0154] Figure 9 is a structural schematic diagram of an electronic device provided by embodiment eight of the application, as Figure 9 shown, the electronic device comprises a processor 70, a memory 71, an input device 72 and an output device 73; the number of processors 70 in the electronic device can be one or more, Figure 9 for example, one processor 70; the processor 70, the memory 71, the input device 72 and the output device 73 in the electronic device can be connected through a bus or other means, Figure 9 for example, connected through a bus.
[0155] The memory 71 can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the multi-cluster container management method in the embodiments of the present application (for example, the request obtaining module 601 and the container management module 602 in the multi-cluster container management apparatus, or the instruction obtaining module 701 and the management execution module 702). The processor 70 executes various functions and data processing of the electronic device by running the software programs, instructions and modules stored in the memory 71, that is, implements the multi-cluster container management method described above.
[0156] The memory 71 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and application programs required by at least one function; the data storage area can store data created according to the use of the terminal, etc. In addition, the memory 71 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state memory device. In some examples, the memory 71 can further include a memory remotely arranged with respect to the processor 70, which can be connected to the electronic device through a network. Examples of the above network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0157] The input device 72 can be used to receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device. The output device 73 can include a display device such as a display screen.
[0158] Embodiment Nine
[0159] The embodiment nine of the present application also provides a storage medium containing computer executable instructions, which, when executed by a computer processor, are used to perform a multi-cluster container management method, the method comprising:
[0160] Obtaining a container management request input by a user;
[0161] According to the container management request and the preset management object, managing the service container in the dependent cluster.
[0162] Or,
[0163] Obtaining a container management instruction sent by a global control cluster, wherein the container management instruction is determined according to the container management request and the preset management object;
[0164] According to the container management instruction, managing the service container.
[0165] Of course, the storage medium provided by the embodiment of the present application contains computer executable instructions, which are not limited to the method operations described above, but can also perform the related operations in the multi-cluster container management method provided by any embodiment of the present application.
[0166] Through the above description of the embodiments, those skilled in the art can clearly understand that the present application can be realized by means of software and necessary general hardware, and of course can also be realized by hardware, but in many cases the former is a better embodiment. Based on such understanding, the technical solutions of the present application 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 a floppy disk, a read-only memory (ROM), a random access memory (RAM), a FLASH, a hard disk or an optical disk, etc., including a plurality of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in various embodiments of the present application.
[0167] It is worth noting that the embodiments of the above multi-cluster container management device include various units and modules only according to functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific name of each functional unit is only for easy mutual distinction, and does not limit the protection scope of the present application.
[0168] Note that the above is only the preferred embodiment of the present application and the technical principle applied. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and those skilled in the art can make various obvious changes, readjustments and substitutions without departing from the scope of the present application. Therefore, although the present application has been described in more detail through the above embodiments, the present application is not limited to the above embodiments, and can include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the appended claims.
Claims
1. A multi-cluster container management method, characterized by, The method is applied to global control clusters, and the method comprises: Obtaining a container management request input by a user; wherein the container management request comprises at least one of a container creation request and a container update request; the container management request comprises a business container to be managed and a slave cluster corresponding to the business container; the container creation request comprises a business container to be created and a slave cluster for creating the business container; the container update request is a request for updating a function implemented by the business container; the business container is composed of one or more auxiliary functions; According to the container management request and a preset management object, managing the business container in the slave cluster; According to the container management request and a preset management object, managing the business container in the slave cluster, comprising: According to the container update request, modifying an auxiliary function container template of the auxiliary function management object; When the auxiliary function management object is updated, traversing the business containers of each slave cluster, and judging whether the business auxiliary function of the business container is consistent with the business auxiliary function in the auxiliary function container template of the auxiliary function management object; If consistent, the business container is not updated, and if inconsistent, the business auxiliary function in the auxiliary function container template is injected into the business container; wherein the auxiliary function container template stores auxiliary function information in the business container; wherein the auxiliary function management object is used to update the auxiliary function in the business container; According to the container management request and a preset management object, managing the business container in the slave cluster, comprising: According to the container management request and a preset management object, managing the business container in the slave cluster, comprising:
2. The method of claim 1, wherein, Obtaining a container creation request corresponding to the business container management object; 3. The method of claim 1, wherein, Extracting an expected deployment cluster and an expected instance number in the business container management object; According to the expected deployment cluster and the expected instance number, creating a business container. According to the expected deployment cluster and the expected instance number, creating a business container, comprising: According to the expected deployment cluster, connecting to at least one slave cluster; 4. The method of claim 3, wherein, Controlling each slave cluster to create a business container; Judging whether the number of business containers created in each slave cluster meets the requirement of the expected instance number, if yes, completing the creation of the business container, and if no, controlling the slave cluster to continue creating the business container until the number of business containers meets the requirement of the expected instance number. Controlling each slave cluster to create a business container, comprising: Obtaining an auxiliary function container template in the auxiliary function management object, wherein the auxiliary function container template comprises at least one business auxiliary function; 5. The method of claim 4, wherein, Controlling each slave cluster to create a business container; Inject each of the business auxiliary functions into each of the business containers according to the auxiliary function container template.
6. A multi-cluster container management method, characterized by, The method is applied to a subordinate cluster, and the method comprises: obtaining a container management instruction sent by a global control cluster, wherein the container management instruction is determined according to a container management request and a preset management object; the container management request comprises at least one of a container creation request and a container update request; the container management request comprises a business container to be managed and a subordinate cluster corresponding to the business container; the container creation request comprises a business container to be created and a subordinate cluster in which the business container is created; the container update request is a request for updating a function implemented by the business container; the business container is composed of one or more auxiliary functions; managing the business container according to the container management instruction; wherein the container management instruction comprises a container update instruction, and the management of the business container according to the container management instruction comprises: receiving an auxiliary function container template in an auxiliary function management object in the global control cluster; determining whether the business auxiliary functions of the business container are consistent with the business auxiliary functions in the auxiliary function container template of the auxiliary function management object; if consistent, the business container is not updated; if not consistent, the business auxiliary functions in the auxiliary function container template are injected into the business container; wherein the auxiliary function management object is used to update the auxiliary functions in the business container; wherein the receiving of the auxiliary function container template in the auxiliary function management object in the global control cluster comprises: when the container update instruction is received, the global control cluster is listened to, and an auxiliary function container template in an auxiliary function management object is received; wherein the auxiliary function management object is used to update the auxiliary functions in the business container; wherein the method further comprises: sending subordinate cluster information to the global control cluster to update a cluster management object; the subordinate cluster information comprises unique identification information and working state information of the subordinate cluster; the subordinate cluster information is used for the global control cluster to uniformly manage the subordinate cluster; the cluster management object is preset with a control logic for managing the subordinate cluster.
7. The method of claim 6, wherein, The preset management object comprises at least one of a business container management object and an auxiliary function management object.
8. The method of claim 6, wherein, The container management instruction comprises a container creation instruction, and the management of the business container according to the container management instruction comprises: extracting a number of expected instances in the container creation instruction, and creating the number of expected instances of the business container.
9. The method of claim 8, wherein, The creation of the business container comprises: receiving an auxiliary function container template in an auxiliary function management object in the global control cluster, wherein the auxiliary function container template comprises at least one business auxiliary function; creating a business container, and injecting each of the business auxiliary functions into the business container according to the auxiliary function container template. 10.A multi-cluster container management apparatus, characterized by comprising: The device is applied to a global control cluster, and the device comprises: The request obtaining module is configured to obtain a container management request input by a user, wherein the container management request comprises at least one of a container creation request and a container update request; the container management request comprises a business container to be managed and a slave cluster corresponding to the business container; the container creation request comprises a business container to be created and a slave cluster for creating the business container; the container update request is a request for updating a function implemented by the business container; and the business container is composed of one or more auxiliary functions. The container management module is configured to manage the business container in the slave cluster according to the container management request and a preset management object. The container management module comprises: The update request unit is configured to modify an auxiliary function container template of the auxiliary function management object according to the container update request. The update management unit is configured to control the slave cluster to update the business container according to the auxiliary function management object when the auxiliary function management object is updated, wherein the auxiliary function management object is used to update the auxiliary function in the business container. The update management unit is specifically configured to: traverse the business container of each slave cluster, and determine whether the business auxiliary function of the business container is consistent with the business auxiliary function in the auxiliary function container template of the auxiliary function management object; if the business auxiliary function is consistent, the business container is not updated; and if the business auxiliary function is not consistent, the business auxiliary function in the auxiliary function container template is injected into the business container; wherein the auxiliary function container template stores auxiliary function information in the business container. The device further comprises: The cluster management module is configured to manage the slave cluster according to a cluster management object, wherein the management comprises adding, deleting and updating slave cluster information; the slave cluster information comprises unique identification information and working state information of the slave cluster; the slave cluster information is used for globally controlling the cluster to uniformly manage the slave cluster; and the cluster management object is preset with a control logic for managing the slave cluster.
11. A multi-cluster container management apparatus characterized by comprising: The device is applied to a slave cluster and comprises: The instruction obtaining module is configured to obtain a container management instruction sent by a global control cluster, wherein the container management instruction is determined according to a container management request and a preset management object; the container management request comprises at least one of a container creation request and a container update request; the container management request comprises a business container to be managed and a slave cluster corresponding to the business container; the container creation request comprises a business container to be created and a slave cluster for creating the business container; the container update request is a request for updating a function implemented by the business container; and the business container is composed of one or more auxiliary functions. The management execution module is configured to manage the business container according to the container management instruction. The container management instruction comprises a container update instruction, and the management execution module comprises: The update receiving unit is configured to receive an auxiliary function container template in an auxiliary function management object in the global control cluster. The update execution unit is configured to determine whether the service auxiliary function of the service container is consistent with the service auxiliary function in the auxiliary function container template of the auxiliary function management object, and if yes, the service container is not updated, and if not, the service auxiliary function in the auxiliary function container template is injected into the service container; wherein the auxiliary function management object is used to update the auxiliary function in the service container. The update receiving unit is specifically configured to listen to the global control cluster to receive the auxiliary function container template in the auxiliary function management object when the container update instruction is received; wherein the auxiliary function management object is used to update the auxiliary function in the service container. The device further comprises: A cluster information module is configured to send the subordinate cluster information to the global control cluster to update the cluster management object; the subordinate cluster information comprises unique identification information and working state information of the subordinate cluster; the subordinate cluster information is used for the global control cluster to uniformly manage the subordinate cluster; and the cluster management object is preconfigured with the control logic for managing the subordinate cluster.
12. An electronic device, comprising: The electronic device comprises: One or more processors; Memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the multi-cluster container management method according to any one of claims 1-5 or 6-9.
13. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the multi-cluster container management method according to any one of claims 1-5 or 6-9.
Citation Information
Patent Citations
Multi-cluster management method and device, server and storage medium
CN110389836A
Container resource use limitation dynamic updating method
CN112181597A