Method, device and computer-readable storage medium for deploying master nodes in a cluster
By creating predefined resource objects in Kubernetes clusters and deploying master node components using Operator controls, synchronizing the operating status in real time, the problem of unstable master node deployment status in the existing technology is solved, and the accuracy and reliability of deployment are improved.
Patent Information
- Application Number
- CN202011217893.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-04
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2040-11-04
AI Technical Summary
The deployment method of the master node in the existing Kubernetes cluster cannot effectively ensure the operating status of each component after the master node is deployed, resulting in high deployment complexity and difficulty in troubleshooting errors.
By creating predefined resource objects required by the master node and deploying these resource objects in the Kubernetes cluster using the preset Operator controls, the running status will be synchronized to the API Server in real time to ensure that each resource object reaches the expected state after the master node is deployed.
It reduces the complexity of primary node deployment and the difficulty of error detection, ensures the health status and self-repair capabilities of primary node components, and achieves higher deployment accuracy and reliability.
Smart Images

Figure CN112214330B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method and device for deploying a master node in a cluster, and a computer-readable storage medium. Background Art
[0002] Container Cloud (Kubernetes) is an open source container operating platform that can combine several containers into a service and dynamically allocate hosts for container operation, providing great convenience for users to use containers. Generally speaking, a Kubernetes cluster (or container cloud cluster) includes two types of nodes: master nodes and slave nodes. The master node is responsible for the management and scheduling of all resources in the Kubernetes cluster. Therefore, to create a Kubernetes cluster, you first need to build a master node.
[0003] However, the deployment method of the master node in the Kubernetes cluster in the prior art cannot guarantee the operating status of each component in the master node after the master node is deployed. Summary of the invention
[0004] The purpose of this application is to solve at least one of the above technical defects. The technical solutions provided by the embodiments of this application are as follows:
[0005] In a first aspect, an embodiment of the present application provides a method for deploying a master node in a cluster, including:
[0006] Receive a cluster creation request, which includes configuration information of a target container cloud cluster to be created;
[0007] In response to the cluster creation request, a namespace corresponding to the target container cloud cluster is created in the preset container cloud cluster, and a predefined resource object is created based on the configuration information, where the predefined resource object indicates the resource object required by the master node in the target container cloud cluster;
[0008] Submitting the predefined resource object to the preset container cloud cluster through the application program interface service in the preset container cloud cluster, so that the application controller control in the preset container cloud cluster deploys the resource object in the namespace, and synchronizes the running status of the predefined resource object to the application program interface service;
[0009] The running status of the predefined resource object is obtained through the application program interface service, and when the running status of the predefined resource object is running, it is determined that the deployment of the master node corresponding to the target container cloud cluster is completed.
[0010] In a second aspect, an embodiment of the present application provides a method for deploying a master node in a cluster, including:
[0011] When a new event of a predefined resource object is detected through an application program interface service in a preset container cloud cluster, a corresponding work coroutine is started for the predefined resource object, where the predefined resource object indicates a resource object required by a master node in a target container cloud cluster to be created;
[0012] Deploy resource objects in the namespace corresponding to the target container cloud cluster in the preset container cloud cluster through a work coroutine. The namespace is created by the cluster deployment control after receiving the cluster creation request.
[0013] The running status of the predefined resource object is synchronized to the application interface service, so that the cluster deployment control obtains the running status of the predefined resource object through the application interface service, and when the running status of the predefined resource object is running, it is determined that the deployment of the master node corresponding to the target container cloud cluster is completed.
[0014] In a third aspect, an embodiment of the present application provides a deployment device for a master node in a cluster, including:
[0015] A cluster creation request receiving module is used to receive a cluster creation request, where the cluster creation request includes configuration information of a target container cloud cluster to be created;
[0016] A namespace and predefined resource object creation module, which is used to create a namespace corresponding to the target container cloud cluster in the preset container cloud cluster in response to the cluster creation request, and to create a predefined resource object based on the configuration information, wherein the predefined resource object indicates the resource object required by the master node in the target container cloud cluster;
[0017] A predefined resource object submission module is used to submit the predefined resource object to the preset container cloud cluster through the application program interface service in the preset container cloud cluster, so that the application controller control in the preset container cloud cluster deploys the resource object in the namespace, and synchronizes the running status of the predefined resource object to the application program interface service;
[0018] The predefined resource object running status detection module is used to obtain the running status of the predefined resource object through the application program interface service, and when the running status of the predefined resource object is running, it is determined that the deployment of the master node corresponding to the target container cloud cluster is completed.
[0019] In an optional embodiment of the present application, a definition file of a predefined resource object is preinstalled in the preset container cloud cluster, and an application controller control is pre-deployed in the preset container cloud cluster.
[0020] In an optional embodiment of the present application, the namespace and predefined resource object creation module are specifically used to:
[0021] Based on the definition file, obtain the predefined resource object template;
[0022] Generate a predefined resource object based on the configuration information and the predefined resource object template.
[0023] In a fourth aspect, an embodiment of the present application provides a deployment device for a master node in a cluster, including:
[0024] A work coroutine startup module is used to start a corresponding work coroutine for a predefined resource object when a new event of a predefined resource object is detected through an application program interface service in a preset container cloud cluster. The predefined resource object indicates the resource object required by the master node in the target container cloud cluster to be created;
[0025] A predefined resource object deployment module is used to deploy resource objects in the namespace corresponding to the target container cloud cluster in the preset container cloud cluster through a work coroutine. The namespace is created by the cluster deployment control after receiving a cluster creation request.
[0026] The predefined resource object running status synchronization module is used to synchronize the running status of the predefined resource object to the application interface service, so that the cluster deployment control obtains the running status of the predefined resource object through the application interface service, and when the running status of the predefined resource object is running, it is determined that the deployment of the master node corresponding to the target container cloud cluster is completed.
[0027] In an optional embodiment of the present application, the device further includes an operation status updating module, which is used to:
[0028] After deploying the resource object in the namespace corresponding to the target container cloud cluster in the preset container cloud cluster through the work coroutine, obtain the actual status of the resource object;
[0029] If the actual state of the resource object is the same as the expected state corresponding to the resource object, the running state of the predefined resource object is updated to running.
[0030] In an optional embodiment of the present application, the predefined resource object also indicates an expected state of the resource object.
[0031] In a fifth aspect, an embodiment of the present application provides an electronic device, including a memory and a processor;
[0032] A computer program is stored in the memory;
[0033] A processor is used to execute a computer program to implement the method provided in the first aspect embodiment or the second aspect embodiment.
[0034] In the sixth aspect, an embodiment of the present application provides a computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the method provided in the embodiment of the first aspect or the embodiment of the second aspect is implemented.
[0035] In a seventh aspect, an embodiment of the present application provides a computer program product or a computer program, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that when the computer device executes, the method provided in the first aspect embodiment or the second aspect embodiment is implemented.
[0036] The beneficial effects of the technical solution provided by this application are:
[0037] By creating a predefined resource object corresponding to the resource object required by the master node, and then deploying the resource object indicated by the predefined resource object through the preset application controller (Operator) control, and synchronizing the running status of the predefined resource object to the application interface service (APIServer) during the deployment process for cluster deployment control detection, and when it is known that the running status of the predefined resource object is running, it is determined that the master node deployment is complete. This method ensures that the status of each resource object can reach the expected status after the master node is deployed. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in describing the embodiments of the present application.
[0039] Figure 1 A schematic diagram of the process of pre-deployment in an embodiment of the present application;
[0040] Figure 2 A schematic diagram of a process for deploying a master node in a cluster provided in this application;
[0041] Figure 3 A schematic diagram of the flow of actions performed by the cluster deployment control in an embodiment of the present application;
[0042] Figure 4 A schematic diagram of a process for deploying a master node in a cluster provided in an embodiment of the present application;
[0043] Figure 5 A schematic diagram of the flow of actions performed by the application controller (Operator) control in an embodiment of the present application;
[0044] Figure 6A schematic diagram of the overall solution of the embodiment of the present application;
[0045] Figure 7 A structural block diagram of a deployment device for a master node in a cluster provided in an embodiment of the present application;
[0046] Figure 8 A structural block diagram of a deployment device for a master node in a cluster provided in an embodiment of the present application;
[0047] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be interpreted as limiting the present invention.
[0049] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.
[0050] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0051] First, several terms involved in this application are introduced and explained:
[0052] Application Programming Interface Service (APIServer): It provides HTTP REST (Resource Representational State Transfer) interfaces for adding, deleting, modifying, checking, and detecting various resource objects in Kubernetes. It is the data bus and data center of the entire system. Functions of APIServer: (1) It provides a RestAPI (Application Programming Interface) interface for cluster management (including authentication and authorization, data verification, and cluster status changes); (2) It provides a hub for data interaction and communication between other modules (other modules query or modify data through APIServer); (3) It is the entry point for resource quota control; (4) It has a complete cluster security mechanism.
[0053] Application Controller (Operator): Used to extend the Kubernetes API to create, configure, and manage complex stateful applications such as databases, caches, and detection systems. Operators are built on top of Kubernetes' resource and controller concepts, but also include application-specific domain knowledge.
[0054] Logical host (pod): A pod is a group of closely related containers that run together on the same worker node and in the same Linux namespace. Each pod is like an independent logical machine with its own IP (Internet Protocol), host name, process, etc., running an independent application. All containers of a pod run on the same logical machine, and containers in other pods, even if they run on the same worker node, will appear on different nodes. That is, when a pod contains multiple containers, these containers always run on the same worker node, and a pod can never span multiple worker nodes.
[0055] The master node deployment methods in the Kubernetes cluster in the prior art include the following:
[0056] (1) Install the components required by the master node using yum (yum installation is one of the three ways to install software in Linux) or compile them in binary form manually on the host and run them as system-level daemons. However, manual deployment is very cumbersome and has a high error rate. If an error occurs, it is difficult to trace the error and fix it.
[0057] (2) Use the kubeadm tool (a tool for building Kubernetes clusters) for deployment, containerize the components required for the master node, and deploy each component in a containerized manner. It is necessary to install kubelet (which can be understood as a node agent running on the node) and docker (an open source application container engine that developers can package their applications and dependencies into a portable container and publish it to a popular Linux machine, which can also achieve virtualization) on each node in advance to instantiate the container. The pods on the master node are all static pods and are not managed by Kubernetes itself. They can only run as self-hosted pods. However, the static pods deployed by the kubeadm tool run in a self-hosted manner, and the health status of the master node components cannot be guaranteed. The kubeadm tool also blocks many deployment details. If problems are encountered during the deployment process, it is difficult to troubleshoot the errors.
[0058] (3) Write a deployment script template in advance, generate a configuration script based on the user's configuration parameters, start the deployment script on the node, and start the components of the master node in binary mode. However, this method has two disadvantages. One is that due to the extremely fast update of Kubernetes versions, each update requires rewriting the details in the deployment script, which brings complexity to version management. The second disadvantage is that after the master node components are deployed, the subsequent operating status of these components cannot be guaranteed.
[0059] In response to the above problems, an embodiment of the present application provides a method for deploying a master node in a cluster, and the specific implementation method of the method will be described in detail below.
[0060] Before executing the deployment method of the master node in the cluster provided in the embodiment of the present application, it is necessary to pre-create a preset Kubernetes cluster, submit the definition file of the predefined resource object through the APIServer of the preset Kubernetes cluster, and install the submitted definition file of the predefined resource object in the preset Kubernetes cluster. Specifically, the predefined resource object can be understood as a new resource object type, which can be predefined according to demand. At the same time, it is also necessary to deploy the Operator control in the preset Kubernetes cluster. Specifically, the Operator control is deployed as a container in the preset Operator control. After completing the above-mentioned cluster creation and control deployment work, it is also necessary to start the cluster deployment control corresponding to the preset Kubernetes cluster, and the cluster deployment control can be deployed inside or outside the preset Kubernetes cluster.
[0061] It can be seen from the above description that the above process can be understood as the pre-deployment process of the solution provided by this application. The overall process of the pre-deployment process can be as follows: Figure 1 As shown, including:
[0062] (1) Create a preset Kubernetes cluster.
[0063] (2) Install the definition file of the predefined resource object in the preset Kubernetes cluster and deploy the Operator control in the preset Kubernetes cluster.
[0064] (3) Start the cluster deployment control.
[0065] Figure 2 A schematic diagram of a process flow of a method for deploying a master node in a cluster provided by the present application. The execution subject of the method can be a pre-started cluster deployment control, such as Figure 2 As shown, the method may include:
[0066] Step S201: Receive a cluster creation request, where the cluster creation request includes configuration information of a target Kubernetes cluster to be created.
[0067] The configuration information may include the name of the target Kubernetes cluster, the corresponding subnet identifier (ID) and the corresponding Kubernetes version number.
[0068] Specifically, the cluster deployment control receives a cluster creation request sent by the user, which contains the configuration information of the target Kubernetes cluster. Since the corresponding master node needs to be deployed during the creation of the target Kubernetes cluster, when the cluster creation request is received, it is equivalent to receiving the master node deployment request of the target Kubernetes cluster. Next, the master node needs to be deployed in response to the master node deployment request to achieve the creation of the target Kubernetes cluster.
[0069] Step S202, in response to the cluster creation request, creates a namespace corresponding to the target Kubernetes cluster in the preset Kubernetes cluster, and creates a predefined resource object based on the configuration information, where the predefined resource object indicates the resource object required by the master node in the target Kubernetes cluster.
[0070] The namespace is the deployment space of the master node in the target Kubernetes cluster and can be named with the name of the target Kubernetes cluster.
[0071] Among them, the predefined resource objects indicate the resource objects required by the master node in the target Kubernetes cluster, where the resource objects required by the master node can be understood as the components required by the master node, such as APIServer (application interface service), Scheduler (scheduler), Controller Manager (management control center), etc.
[0072] Specifically, when the cluster deployment control receives a cluster creation request sent by a user, in response to the cluster creation request, the cluster deployment control first creates a namespace corresponding to the target Kubernetes cluster in the preset Kubernetes cluster, and the namespace can be named with the cluster name of the target Kubernetes cluster. Then, the cluster deployment control creates a predefined resource object based on the configuration information combined with the definition file of the pre-installed predefined resource object, and the predefined resource object indicates the resource object required by the master node in the target Kubernetes cluster, that is, the components required by the master node.
[0073] Step S203, submitting the predefined resource object to the preset Kubernetes cluster through the APIServer in the preset Kubernetes cluster, so that the Operator control in the preset Kubernetes cluster deploys the resource object in the namespace, and synchronizes the running status of the predefined resource object to the APIServer.
[0074] Specifically, the cluster deployment control submits the created predefined resource objects to the preset Kubernetes cluster through the APIServer. Since the Operator control in the preset Kubernetes cluster has been detecting events related to predefined resource objects in the APIServer (including new additions, modifications, and deletions, etc.), when the APIServer receives the submitted predefined resource objects, the Operator control detects the new addition events of the predefined resource objects. Next, the Operator control deploys the resource objects required by the master node in the target Kubernetes cluster indicated by the predefined resource objects to the corresponding namespace, and synchronizes the running status of the predefined resource objects to the APIServer at regular intervals during the deployment process.
[0075] It should be noted that in the solution of this embodiment, predefined resource objects corresponding to the resource objects required by the master node are created, and each resource object is deployed using a pre-deployed Operator control corresponding to the predefined resource object. The deployment method of the master node is closer to the operation method of native Kubernetes, making the deployment of the master node less complex and more accurate.
[0076] Step S204, obtaining the running status of the predefined resource object through the API Server, and when the running status of the predefined resource object is running, it is determined that the deployment of the master node corresponding to the target Kubernetes cluster is completed.
[0077] Specifically, since the Operator control will synchronize the running status of the predefined resource object to the APIServer at regular intervals, the cluster deployment control can obtain the running status of the predefined resource object from the APIServer to determine the deployment status of the master node. Specifically, the cluster deployment control obtains the running status of the predefined resource object from the APIServer at regular intervals, and when it is learned that the running status of the predefined resource object is running, it is determined that the deployment of the master node is complete. Among them, the running status of the predefined resource object is determined by the running status of the corresponding resource object, and when the actual status of the running status of all corresponding resource objects reaches the expected status, the running status of the predefined resource object is running. Among them, the predefined resource object also indicates the expected status of each corresponding resource object.
[0078] The solution provided by the present application creates a predefined resource object corresponding to the resource object required by the master node, and then deploys the resource object indicated by the predefined resource object through a preset Operator control. During the deployment process, the running status of the predefined resource object is synchronized to the API server for cluster deployment control detection, and when it is known that the running status of the predefined resource object is running, it is determined that the deployment of the master node is complete. This method ensures that the status of each resource object can reach the expected status after the master node is deployed.
[0079] In an optional embodiment of the present application, a definition file of a predefined resource object is pre-installed in a preset Kubernetes cluster, and an Operator control is pre-deployed in the preset Kubernetes cluster.
[0080] Specifically, since the declarative API and Controller mechanism are the basis of the Kubernetes design concept, the embodiment of the present application pre-creates a preset Kubernetes cluster, installs predefined resource objects for the preset Kubernetes cluster, and deploys the corresponding Operator control. Specifically, the definition file of the predefined resource object contains all the selectable properties for creating the predefined resource object type. The Operator control defines the Controller corresponding to each resource object indicated by the predefined resource object to ensure the running status of each resource object in the predefined resource object. The Controller continuously synchronizes the expected state of each resource object from the API Server and tunes between the expected state and the actual state of each resource object, thereby achieving the ultimate consistency between the two. Make each component of the Kubernetes master node have fault migration capabilities and self-healing properties.
[0081] In an optional embodiment of the present application, creating a predefined resource object based on configuration information includes:
[0082] Based on the definition file, obtain the predefined resource object template;
[0083] Generate a predefined resource object based on the configuration information and the predefined resource object template.
[0084] Among them, the predefined resource object template can be further defined based on the definition file. Specifically, since the definition file of the predefined resource object contains all the selectable attributes for creating the predefined resource object type, the corresponding attributes can be selected according to the needs to determine the corresponding predefined resource template.
[0085] Specifically, after receiving the cluster creation request, the group deployment control first obtains the configuration information contained in the cluster creation request, obtains the corresponding template from the preset Kubernetes, and then generates a predefined resource object based on the configuration information and the predefined resource object template.
[0086] From the above description, it can be seen that the process of the actions performed by the cluster deployment control in the solution provided by this application can be as follows: Figure 3 As shown, including:
[0087] (1) Receive a cluster creation request from a user.
[0088] (2) Create a namespace in the preset Kubernetes cluster and create predefined resource objects based on the configuration information in the cluster creation request.
[0089] (3) Obtain the running status of predefined resource objects through API Server.
[0090] (4) Determine whether the predefined resource object is running.
[0091] (5) When the running status of the resource object is defined as running, it is determined that the deployment of the master node corresponding to the target Kubernetes cluster is completed.
[0092] Figure 4 A schematic diagram of a process for deploying a master node in a cluster provided in an embodiment of the present application, wherein the execution subject of the method may be an Operator control, such as Figure 4 As shown, the method may include:
[0093] Step S401, when a new event of a predefined resource object is detected by the APIServer in the preset Kubernetes cluster, a corresponding work coroutine is started for the predefined resource object, and the predefined resource object indicates the resource object required by the master node in the target Kubernetes cluster to be created.
[0094] The predefined resource objects indicate the resource objects required by the master node in the target Kubernetes cluster, where the resource objects required by the master node can be understood as the components required by the master node, such as APIServer, Scheduler, Controller Manager, etc.
[0095] Specifically, the cluster deployment control submits the created predefined resource object to the preset Kubernetes cluster through the APIServer. Since the Operator control in the preset Kubernetes cluster has been detecting events related to the predefined resource objects in the APIServer (including new addition, modification, and deletion events, etc.), when the APIServer receives the submitted predefined resource object, the Operator control detects the new addition event of the predefined resource object.
[0096] Step S402, deploy resource objects in the namespace corresponding to the target Kubernetes cluster in the preset Kubernetes cluster through the work coroutine, where the namespace is created by the cluster deployment control after receiving the cluster creation request.
[0097] Among them, the namespace is the deployment space of the master node in the target Kubernetes cluster, and it can be named with the name of the target Kubernetes cluster. When the cluster deployment control receives a cluster creation request sent by the user, in response to the cluster creation request, the cluster deployment control first creates a namespace corresponding to the target Kubernetes cluster in the preset Kubernetes cluster, and the namespace can be named with the cluster name of the target Kubernetes cluster. Then, the cluster deployment control creates a predefined resource object based on the configuration information combined with the definition file of the pre-installed predefined resource object. The predefined resource object indicates the resource object required by the master node in the target Kubernetes cluster, that is, the components required by the master node.
[0098] Specifically, the Operator control deploys the resource objects required by the master node in the target Kubernetes cluster indicated by the predefined resource objects to the corresponding namespace, and synchronizes the running status of the predefined resource objects to the APIServer at regular intervals during the deployment process. Specifically, the Operator control starts a work coroutine corresponding to the predefined resource object, and deploys the resource object in the namespace corresponding to the target Kubernetes cluster in the preset Kubernetes cluster through the work coroutine.
[0099] Step S403, synchronize the running status of the predefined resource object to the API Server, so that the cluster deployment control obtains the running status of the predefined resource object through the API Server, and when the running status of the predefined resource object is running, it is determined that the deployment of the master node corresponding to the target Kubernetes cluster is completed.
[0100] Specifically, since the Operator control will synchronize the running status of the predefined resource object to the APIServer at regular intervals, the cluster deployment control can obtain the running status of the predefined resource object from the APIServer to determine the deployment status of the master node. Specifically, the cluster deployment control obtains the running status of the predefined resource object from the APIServer at regular intervals, and when it is learned that the running status of the predefined resource object is running, it is determined that the deployment of the master node is complete. Among them, the running status of the predefined resource object is determined by the running status of the corresponding resource object, and when the actual status of the running status of all corresponding resource objects reaches the expected status, the running status of the predefined resource object is running. Among them, the predefined resource object also indicates the expected status of each corresponding resource object.
[0101] The solution provided by the present application creates a predefined resource object corresponding to the resource object required by the master node, and then deploys the resource object indicated by the predefined resource object through a preset Operator control. During the deployment process, the running status of the predefined resource object is synchronized to the API server for cluster deployment control detection, and when it is known that the running status of the predefined resource object is running, it is determined that the deployment of the master node is complete. This method ensures that the status of each resource object can reach the expected status after the master node is deployed.
[0102] In an optional embodiment of the present application, after deploying the resource object in the namespace corresponding to the target Kubernetes cluster in the preset Kubernetes cluster through the work coroutine, it also includes:
[0103] Get the actual status of the resource object;
[0104] If the actual state of the resource object is the same as the expected state corresponding to the resource object, the running state of the predefined resource object is updated to running.
[0105] The predefined resource object also indicates the expected state of the resource object.
[0106] Specifically, for each resource object corresponding to the predefined resource object, when the Operator control deploys it through the work coroutine, it is necessary to determine whether the actual state of each resource object is the same as the corresponding expected state. If they are the same, the running state of the predefined resource object is updated to running and synchronized to the API server.
[0107] From the above description, it can be seen that the process of the actions performed by the Operator control in the solution provided by this application can be as follows: Figure 5 As shown, including:
[0108] (1) When a new event of a predefined resource object is detected, a corresponding work coroutine is started for the predefined resource object.
[0109] (2) Deploy each resource object corresponding to the predefined resource object in the namespace through the work coroutine, and check the actual status of each resource object.
[0110] (3) Determine whether the actual state of each resource object is the same as the corresponding expected state.
[0111] (4) If the actual state of each resource object is the same as the corresponding expected state, the running state of the predefined resource object is updated to running.
[0112] Combine the following Figure 6 The overall solution process of the embodiment of the present application is further described as follows: Figure 6As shown, the program may include:
[0113] (1.0) The cluster deployment control receives cluster creation requests sent by users.
[0114] (1.1) The cluster deployment control creates a namespace corresponding to the target Kubernetes cluster in the preset Kubernetes cluster.
[0115] (1.2) The cluster deployment control creates a predefined resource object and submits the predefined resource object to the Kubernetes cluster through the API server.
[0116] (1.3) The cluster deployment control obtains the running status of predefined resource objects through the API server.
[0117] (2.1) Operator controls are detected through API server.
[0118] (2.2) When a new event of a predefined resource object is detected, the Operator control starts the working coroutine (or woker) corresponding to the predefined resource object.
[0119] (2.3) Predefined resource objects deploy the resource objects APIServer, Scheduler, and Controller Manager corresponding to the predefined resource objects in the namespace through work coroutines.
[0120] (2.4) The Operator control synchronizes the running status of the predefined resource objects to the API server.
[0121] It should be noted that this application involves cloud technology. Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and network within a wide area network or local area network to achieve data calculation, storage, processing, and sharing.
[0122] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool, which can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The backend services of the technical network system require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the rapid development and application of the Internet industry, in the future, each item may have its own identification mark, which needs to be transmitted to the backend system for logical processing. Data of different levels will be processed separately. All kinds of industry data need strong system backing support, which can only be achieved through cloud computing.
[0123] Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this.
[0124] Figure 7 A structural block diagram of a deployment device for a master node in a cluster provided in an embodiment of the present application, such as Figure 7 As shown, the device 700 may include: a cluster creation request receiving module 701, a namespace and predefined resource object creation module 702, a predefined resource object submission module 703, and a predefined resource object running status detection module 704, wherein:
[0125] The cluster creation request receiving module 701 is used to receive a cluster creation request, where the cluster creation request includes configuration information of a target Kubernetes cluster to be created;
[0126] The namespace and predefined resource object creation module 702 is used to create a namespace corresponding to the target Kubernetes cluster in the preset Kubernetes cluster in response to the cluster creation request, and create a predefined resource object based on the configuration information, where the predefined resource object indicates the resource object required by the master node in the target Kubernetes cluster;
[0127] The predefined resource object submission module 703 is used to submit the predefined resource object to the preset Kubernetes cluster through the APIServer in the preset Kubernetes cluster, so that the Operator control in the preset Kubernetes cluster deploys the resource object in the namespace, and synchronizes the running status of the predefined resource object to the APIServer;
[0128] The predefined resource object running status detection module 704 is used to obtain the running status of the predefined resource object through the API Server, and when the running status of the predefined resource object is running, it is determined that the deployment of the master node corresponding to the target Kubernetes cluster is completed.
[0129] The solution provided by the present application creates a predefined resource object corresponding to the resource object required by the master node, and then deploys the resource object indicated by the predefined resource object through a preset Operator control. During the deployment process, the running status of the predefined resource object is synchronized to the API server for cluster deployment control detection, and when it is known that the running status of the predefined resource object is running, it is determined that the deployment of the master node is complete. This method ensures that the status of each resource object can reach the expected status after the master node is deployed.
[0130] In an optional embodiment of the present application, a definition file of a predefined resource object is pre-installed in a preset Kubernetes cluster, and an Operator control is pre-deployed in the preset Kubernetes cluster.
[0131] In an optional embodiment of the present application, the namespace and predefined resource object creation module are specifically used to:
[0132] Based on the definition file, obtain the predefined resource object template;
[0133] Generate a predefined resource object based on the configuration information and the predefined resource object template.
[0134] Figure 8 A structural block diagram of a deployment device for a master node in a cluster provided in an embodiment of the present application, such as Figure 8 As shown, the device 800 may include: a work coroutine starting module 801, a predefined resource object deployment module 802 and a predefined resource object running state synchronization module 803, wherein:
[0135] The work coroutine startup module 801 is used to start the corresponding work coroutine for the predefined resource object when a new event of the predefined resource object is detected by the APIServer in the preset Kubernetes cluster. The predefined resource object indicates the resource object required by the master node in the target Kubernetes cluster to be created;
[0136] The predefined resource object deployment module 802 is used to deploy resource objects in the namespace corresponding to the target Kubernetes cluster in the preset Kubernetes cluster through a work coroutine, and the namespace is created by the cluster deployment control after receiving the cluster creation request;
[0137] The predefined resource object running status synchronization module 803 is used to synchronize the running status of the predefined resource object to the API Server, so that the cluster deployment control obtains the running status of the predefined resource object through the API Server, and when the running status of the predefined resource object is running, it is determined that the deployment of the master node corresponding to the target Kubernetes cluster is completed.
[0138] The solution provided by the present application creates a predefined resource object corresponding to the resource object required by the master node, and then deploys the resource object indicated by the predefined resource object through a preset Operator control. During the deployment process, the running status of the predefined resource object is synchronized to the API server for cluster deployment control detection, and when it is known that the running status of the predefined resource object is running, it is determined that the deployment of the master node is complete. This method ensures that the status of each resource object can reach the expected status after the master node is deployed.
[0139] In an optional embodiment of the present application, the device further includes an operation status updating module, which is used to:
[0140] After deploying the resource object in the namespace corresponding to the target Kubernetes cluster in the preset Kubernetes cluster through the work coroutine, obtain the actual status of the resource object;
[0141] If the actual state of the resource object is the same as the expected state corresponding to the resource object, the running state of the predefined resource object is updated to running.
[0142] In an optional embodiment of the present application, the predefined resource object also indicates an expected state of the resource object.
[0143] Based on the same principle, an embodiment of the present application further provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method provided in any optional embodiment of the present application is implemented, and specifically the following situations can be implemented:
[0144] Receive a cluster creation request, which includes the configuration information of the target Kubernetes cluster to be created; create a namespace corresponding to the target Kubernetes cluster in the preset Kubernetes cluster in response to the cluster creation request, and create a predefined resource object based on the configuration information, the predefined resource object indicates the resource object required for the master node in the target Kubernetes cluster; submit the predefined resource object to the preset Kubernetes cluster through the APIServer in the preset Kubernetes cluster, so that the Operator control in the preset Kubernetes cluster deploys the resource object in the namespace, and synchronizes the running status of the predefined resource object to the APIServer; obtain the running status of the predefined resource object through the APIServer, and when the running status of the predefined resource object is running, determine that the deployment of the master node corresponding to the target Kubernetes cluster is completed.
[0145] Alternatively, when a new event of a predefined resource object is detected through the APIServer in the preset Kubernetes cluster, a corresponding work coroutine is started for the predefined resource object, and the predefined resource object indicates the resource object required for the master node in the target Kubernetes cluster to be created; the resource object is deployed in the namespace corresponding to the target Kubernetes cluster in the preset Kubernetes cluster through the work coroutine, and the namespace is created by the cluster deployment control after receiving the cluster creation request; the running status of the predefined resource object is synchronized to the APIServer, so that the cluster deployment control obtains the running status of the predefined resource object through the APIServer, and when the running status of the predefined resource object is running, it is determined that the deployment of the master node corresponding to the target Kubernetes cluster is completed.
[0146] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the method shown in any embodiment of the present application is implemented.
[0147] It is understandable that what is stored in the medium may be a computer program corresponding to the interactive method in video playback.
[0148] Fig. 9 A schematic diagram of the structure of an electronic device applicable to an embodiment of the present application is shown in FIG. Fig. 9 As shown, Fig. 9 The electronic device 900 shown includes: a processor 901 and a memory 903. The processor 901 and the memory 903 are connected, such as through a bus 902. Further, the electronic device 900 may also include a transceiver 904, and the electronic device 900 may interact with other electronic devices through the transceiver 904. It should be noted that in actual applications, the transceiver 904 is not limited to one, and the structure of the electronic device 900 does not constitute a limitation on the embodiments of the present application.
[0149] The processor 901 is used in the embodiment of the present application to implement Figure 7 or Figure 8 The functions of the deployment device of the master node in the cluster are shown.
[0150] The processor 901 may be a CPU, a general-purpose processor, a DSP, an ASIC, an FPGA or other programmable logic device, a transistor logic device, a hardware component or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. The processor 901 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0151] The bus 902 may include a path to transmit information between the above components. The bus 902 may be a PCI bus or an EISA bus, etc. The bus 902 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig. 9 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0152] The memory 903 may be a ROM or other type of static storage device that can store static information and instructions, a RAM or other type of dynamic storage device that can store information and instructions, or an EEPROM, a CD-ROM or other optical disk storage, an optical disk storage (including a compressed optical disk, a laser disk, an optical disk, a digital versatile disk, a Blu-ray disk, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto.
[0153] The memory 903 is used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 901. The processor 901 is used to execute the application code stored in the memory 903 to implement Figure 7 or Figure 8 The illustrated embodiment provides actions of a deployment device for a master node in a cluster.
[0154] The embodiment of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that when the computer device executes the computer instructions, the following conditions are achieved:
[0155] Receive a cluster creation request, which includes the configuration information of the target Kubernetes cluster to be created; create a namespace corresponding to the target Kubernetes cluster in the preset Kubernetes cluster in response to the cluster creation request, and create a predefined resource object based on the configuration information, the predefined resource object indicates the resource object required for the master node in the target Kubernetes cluster; submit the predefined resource object to the preset Kubernetes cluster through the APIServer in the preset Kubernetes cluster, so that the Operator control in the preset Kubernetes cluster deploys the resource object in the namespace, and synchronizes the running status of the predefined resource object to the APIServer; obtain the running status of the predefined resource object through the APIServer, and when the running status of the predefined resource object is running, determine that the deployment of the master node corresponding to the target Kubernetes cluster is completed.
[0156] Alternatively, when a new event of a predefined resource object is detected through the APIServer in the preset Kubernetes cluster, a corresponding work coroutine is started for the predefined resource object, and the predefined resource object indicates the resource object required for the master node in the target Kubernetes cluster to be created; the resource object is deployed in the namespace corresponding to the target Kubernetes cluster in the preset Kubernetes cluster through the work coroutine, and the namespace is created by the cluster deployment control after receiving the cluster creation request; the running status of the predefined resource object is synchronized to the APIServer, so that the cluster deployment control obtains the running status of the predefined resource object through the APIServer, and when the running status of the predefined resource object is running, it is determined that the deployment of the master node corresponding to the target Kubernetes cluster is completed.
[0157] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0158] The above are only some implementation methods of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for deploying a master node in a cluster. It is characterized in that The method is applied to cluster deployment controls, including: Receive a cluster creation request, where the cluster creation request includes configuration information of a target container cloud cluster to be created; In response to the cluster creation request, a namespace corresponding to the target cluster is created in a preset container cloud cluster, and a predefined resource object is created based on the configuration information, where the predefined resource object indicates a resource object required by a master node in the target container cloud cluster; Submitting the predefined resource object to the preset container cloud cluster through the application program interface service in the preset container cloud cluster, so that the application program controller control in the preset container cloud cluster deploys the resource object in the namespace, and synchronizes the running status of the predefined resource object to the application program interface service; Acquiring the running status of the predefined resource object through the application program interface service, and when the running status of the predefined resource object is running, determining that the deployment of the master node corresponding to the target container cloud cluster is completed; The predefined resource object further indicates the expected state of each resource object corresponding to the master node; when the actual state of the running state of each resource object corresponding to the master node reaches the corresponding expected state, the running state of the predefined resource object is running; The application controller control defines a control center Controller corresponding to each resource object of the master node indicated by the predefined resource object; The expected state and actual state of each resource object are consistent in the following manner: the control center Controller corresponding to each resource object continuously synchronizes the expected state of each resource object from the application interface service and performs tuning between the expected state and actual state of each resource object.
2. The method according to claim 1, It is characterized in that The definition file of the predefined resource object is pre-installed in the preset container cloud cluster, and the application controller control is pre-deployed in the preset container cloud cluster.
3. The method according to claim 2, It is characterized in that The creating a predefined resource object based on the configuration information comprises: Based on the definition file, obtaining the predefined resource object template; The predefined resource object is generated based on the configuration information and the predefined resource object template.
4. A method for deploying a master node in a cluster, It is characterized in that The method is applied to an application controller control, comprising: When a new event of a predefined resource object is detected through an application program interface service in a preset container cloud cluster, a corresponding work coroutine is started for the predefined resource object, wherein the predefined resource object indicates a resource object required by a master node in a target container cloud cluster to be created; Deploy the resource object in the namespace corresponding to the target container cloud cluster in the preset container cloud cluster by the work coroutine, where the namespace is created by the cluster deployment control after receiving the cluster creation request; Synchronize the running status of the predefined resource object to the application program interface service, so that the cluster deployment control obtains the running status of the predefined resource object through the application program interface service, and when the running status of the predefined resource object is running, it is determined that the deployment of the master node corresponding to the target container cloud cluster is completed; The predefined resource object further indicates the expected state of each resource object corresponding to the master node; when the actual state of the running state of each resource object corresponding to the master node reaches the corresponding expected state, the running state of the predefined resource object is running; The application controller control defines a control center Controller corresponding to each resource object of the master node indicated by the predefined resource object; The expected state and actual state of each resource object are consistent in the following manner: the control center Controller corresponding to each resource object continuously synchronizes the expected state of each resource object from the application interface service and performs tuning between the expected state and actual state of each resource object.
5. The method according to claim 4, It is characterized in that After deploying the resource object in the namespace corresponding to the target container cloud cluster in the preset container cloud cluster through the work coroutine, the method further includes: Get the actual status of the resource object; If the actual state of the resource object is the same as the expected state corresponding to the resource object, the running state of the predefined resource object is updated to running.
6. The method according to claim 5, It is characterized in that The predefined resource object also indicates the expected state of the resource object.
7. A deployment device for a master node in a cluster, It is characterized in that The device is applied to cluster deployment controls, including: A cluster creation request receiving module, used to receive a cluster creation request, wherein the cluster creation request includes configuration information of a target container cloud cluster to be created; A namespace and predefined resource object creation module, configured to create a namespace corresponding to the target container cloud cluster in a preset container cloud cluster in response to the cluster creation request, and to create a predefined resource object based on the configuration information, wherein the predefined resource object indicates a resource object required by the master node in the target container cloud cluster; A predefined resource object submission module, used to submit the predefined resource object to the preset container cloud cluster through the application program interface service in the preset container cloud cluster, so that the application program controller control in the preset container cloud cluster deploys the resource object in the namespace, and synchronizes the running status of the predefined resource object to the application program interface service; A predefined resource object running status detection module is used to obtain the running status of the predefined resource object through the application program interface service, and when the running status of the predefined resource object is running, determine that the deployment of the master node corresponding to the target container cloud cluster is completed; The predefined resource object further indicates the expected state of each resource object corresponding to the master node; when the actual state of the running state of each resource object corresponding to the master node reaches the corresponding expected state, the running state of the predefined resource object is running; The application controller control defines a control center Controller corresponding to each resource object of the master node indicated by the predefined resource object; The expected state and actual state of each resource object are consistent in the following manner: the control center Controller corresponding to each resource object continuously synchronizes the expected state of each resource object from the application interface service and performs tuning between the expected state and actual state of each resource object.
8. A deployment device for a master node in a cluster, It is characterized in that The device is applied to an application controller control, comprising: A work coroutine startup module is used to start a corresponding work coroutine for a predefined resource object when a new event of the predefined resource object is detected through an application program interface service in a preset container cloud cluster, wherein the predefined resource object indicates a resource object required by a master node in a target container cloud cluster to be created; A predefined resource object deployment module, used to deploy the resource object in the namespace corresponding to the target container cloud cluster in the preset container cloud cluster through the work coroutine, where the namespace is created by the cluster deployment control after receiving the cluster creation request; A predefined resource object running state synchronization module is used to synchronize the running state of the predefined resource object to the application interface service, so that the cluster deployment control obtains the running state of the predefined resource object through the application interface service, and when the running state of the predefined resource object is running, it is determined that the deployment of the master node corresponding to the target container cloud cluster is completed; The predefined resource object further indicates the expected state of each resource object corresponding to the master node; when the actual state of the running state of each resource object corresponding to the master node reaches the corresponding expected state, the running state of the predefined resource object is running; The application controller control defines a control center Controller corresponding to each resource object of the master node indicated by the predefined resource object; The expected state and actual state of each resource object are consistent in the following manner: the control center Controller corresponding to each resource object continuously synchronizes the expected state of each resource object from the application interface service and performs tuning between the expected state and actual state of each resource object.
9. An electronic device, It is characterized in that including memory and processor; The memory stores a computer program; The processor is configured to execute the computer program to implement the method according to any one of claims 1 to 6.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
