A method, apparatus, device, and storage medium for adding cluster nodes
By utilizing task scheduling within a Kubernetes cluster to directly add nodes from intranet nodes within the target node cluster, the resource consumption and maintenance issues associated with jump servers in existing technologies are resolved, thereby improving node addition efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2021-05-21
- Publication Date
- 2026-08-04
AI Technical Summary
When adding nodes to a Kubernetes cluster, existing technologies require setting up a jump server within the local area network, resulting in additional machine resource consumption and maintenance workload, and reducing the efficiency of node addition.
By using task scheduling, nodes can be added directly from the intranet nodes in the target node cluster, avoiding the need to build additional jump servers and utilizing existing nodes to perform node addition tasks.
It improves the efficiency of adding nodes and avoids additional machine resource consumption and maintenance workload. Especially in scenarios where the control plane cannot directly connect to nodes within the local area network, the internal network nodes act as jump servers.
Smart Images

Figure CN115373809B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and in particular to a method, apparatus, device and storage medium for adding cluster nodes. Background Technology
[0002] Kubernetes is an open-source container cluster management system that provides functions such as application deployment, maintenance, and scaling mechanisms. Kubernetes makes it easy to manage containerized applications running across clusters. It is abbreviated as k8s (there are 8 letters between k and s). A container cluster managed by k8s can be called a k8s cluster.
[0003] As business volume increases, the number of nodes in the Kubernetes cluster also increases, necessitating the addition of nodes to the existing Kubernetes cluster. Currently, adding nodes on a local area network (LAN) is achieved by setting up a jump server, logging into the node within the LAN through the jump server, and performing the node installation operation.
[0004] However, adding Kubernetes cluster nodes by logging into internal network nodes through a jump server requires setting up a jump server within the local area network, which leads to additional machine resource consumption and maintenance workload, and also reduces the efficiency of adding nodes. Summary of the Invention
[0005] To address the aforementioned technical issues, this application provides a method, apparatus, device, and storage medium for adding cluster nodes. It utilizes task scheduling to add other nodes within the local area network of the target node cluster to the target node cluster. However, compared to related technologies, this application leverages existing nodes, particularly those in the target node cluster, eliminating the need for additional jump servers and thus avoiding additional machine resource consumption and maintenance workload, thereby improving node addition efficiency.
[0006] The embodiments of this application disclose the following technical solutions:
[0007] In a first aspect, embodiments of this application provide a method for adding cluster nodes, the method comprising:
[0008] Retrieve the description information of the task added to the node;
[0009] Create a node to add a task based on the description information, and generate the configuration file and sensitive information corresponding to the node to add the task;
[0010] The node addition task is scheduled to an intranet node, so that the intranet node can execute the node addition task according to the configuration file. The intranet node and the target node to be added are located in the same local area network.
[0011] During the execution of the node addition task, the target node is logged in based on the sensitive information to add the target node to the target node cluster.
[0012] Secondly, embodiments of this application provide a cluster node adding device, the device comprising an acquisition unit, a generation unit, a scheduling unit, and an adding unit:
[0013] The acquisition unit is used to acquire description information of the task added by the node;
[0014] The generation unit is used to create a node adding task based on the description information, and generate the configuration file and sensitive information corresponding to the node adding task;
[0015] The scheduling unit is used to schedule the node addition task to an intranet node, so that the intranet node can execute the node addition task according to the configuration file. The intranet node and the target node to be added are located in the same local area network.
[0016] The adding unit is used to log in to the target node based on the sensitive information to add the target node to the target node cluster during the execution of the node adding task.
[0017] Thirdly, embodiments of this application provide an electronic device for adding cluster nodes, the electronic device including a processor and a memory:
[0018] The memory is used to store program code and transmit the program code to the processor;
[0019] The processor is configured to execute the method described in the first aspect according to instructions in the program code.
[0020] Fourthly, embodiments of this application provide a computer-readable storage medium for storing program code for executing the method described in the first aspect.
[0021] As can be seen from the above technical solution, when it is necessary to add a node to the node cluster, this application can obtain the description information of the node addition task, so as to create the node addition task according to the description information and generate the configuration file and sensitive information corresponding to the node addition task. The node addition task is scheduled to the intranet node, so that the node addition task can be executed by the intranet node according to the configuration file. Since the intranet node and the target node to be added are located in the same local area network, during the execution of the node addition task, the target node can be directly logged in according to the sensitive information to add the target node to the target node cluster. This application realizes the addition of other nodes (target nodes) in the local area network where the intranet node is located to the target node cluster through task scheduling. Especially in the scenario where the control plane of the target node cluster cannot be directly connected to the nodes in the local area network (i.e., the control plane and the target node are not in the same local area network), the intranet node in this application plays the role of a jump machine in the related technology. However, compared with the related technology, this application uses existing nodes, especially nodes in the target node cluster, without the need to build an additional jump machine, thereby avoiding additional machine resource consumption and maintenance workload, and improving the node addition efficiency. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 An example diagram illustrating an application scenario for a cluster node addition method provided in this application embodiment;
[0024] Figure 2 An example diagram illustrating another application scenario for adding a cluster node as provided in this application embodiment;
[0025] Figure 3 A flowchart illustrating the implementation of a cluster node addition method for related technologies;
[0026] Figure 4 A system architecture example diagram of a cluster node addition method provided in this application embodiment;
[0027] Figure 5 A flowchart illustrating a method for adding cluster nodes provided in an embodiment of this application;
[0028] Figure 6 An architecture diagram for adding a target node by means of nodes within a target cluster, provided in an embodiment of this application;
[0029] Figure 7 An architecture diagram for adding a target node in a direct node connection application scenario provided in this application embodiment;
[0030] Figure 8 This application provides another architecture diagram for adding a target node by adding a target node within a target cluster;
[0031] Figure 9 An architecture diagram for adding a target node in another application scenario of direct node connection provided in this application embodiment;
[0032] Figure 10 A flowchart illustrating a method for adding cluster nodes provided in an embodiment of this application;
[0033] Figure 11 A structural diagram of a cluster node adding device provided in an embodiment of this application;
[0034] Figure 12 A structural diagram of a terminal provided in an embodiment of this application;
[0035] Figure 13 This is a structural diagram of a server provided in an embodiment of this application. Detailed Implementation
[0036] The embodiments of this application will now be described with reference to the accompanying drawings.
[0037] It should be noted that, in this embodiment, the node cluster to which nodes need to be added can be called the target node cluster. The target node cluster can be a Kubernetes cluster. Kubernetes clusters are mainly divided into node clusters managed uniformly by the control plane and independent node clusters. The control plane manages cloud resources uniformly, meaning that for non-independent node clusters, it can uniformly manage the resources of multiple node clusters. Independent node clusters, on the other hand, do not need to be managed by the control plane along with other node clusters; their required resources are managed independently.
[0038] The control plane is built upon the target node cluster and can access the target node cluster's interfaces. The node cluster managed uniformly by the control plane can be divided into two scenarios: the first scenario is where the target node cluster's control plane directly connects to nodes within the local area network, and the second scenario is where the target node cluster's control plane cannot directly connect to nodes within the local area network.
[0039] The first scenario can be found in [reference]. Figure 1As shown, the control plane and the nodes (i.e., the target nodes to be added, such as node 1, node 2, and node 3) are on the same local area network. The control plane directly connects to the login node via Secure Shell (SSH) to execute the installation script commands. The second scenario can be found in [link to second scenario]. Figure 2 As shown, the control plane cannot directly connect to nodes within the local area network (target nodes to be added, such as node 2, node 3, node B, and node C). This means the control plane and the target nodes are located on different local area networks. Node 1 and node A are already located in the target node cluster, meaning the interface corresponding to the target node cluster (kube-apiserver, KAS) can directly connect to node 1 and node A. Therefore, the control plane cannot directly log in to the nodes to execute the installation script commands. The target node cluster typically includes a master node and worker nodes. Usually, the node running KAS is the master node in the target node cluster.
[0040] For independent node clusters, they can also be divided into nodes directly connected to the local area network (LAN) and nodes that cannot be directly connected to the LAN. The difference from the above scenario is that independent node clusters do not have a control plane. Whether a node is directly connected depends on whether the KAS of the target node cluster and the target node are on the same LAN. If the KAS and the target node are on the same LAN, then it is a node directly connected to the LAN; otherwise, it is a node that cannot be directly connected to the LAN.
[0041] In scenarios where nodes within the local area network cannot be directly connected, the relevant techniques for adding nodes to a Kubernetes cluster can be found in [link to relevant documentation]. Figure 3 As shown, in Figure 3 In this scenario, the Kubernetes cluster's control plane is located on LAN 1, while the target nodes to be added, such as node-1, node-2, and node-3, are located on LAN 2. That is, the Kubernetes control plane and the target nodes are not on the same LAN. In this situation, to allow the control plane to log in to the target nodes on LAN 2 to add them to the Kubernetes cluster, a jump server needs to be set up on LAN 2. This means that only the jump server needs to be assigned an external network address, instead of assigning an external network address to each target node. This allows the control plane to log in to the nodes on the LAN through the jump server and perform the node installation operation. However, this method incurs additional machine resource consumption and maintenance workload, and also reduces the efficiency of node addition.
[0042] To address the aforementioned technical issues, this application provides a method for adding cluster nodes. This method utilizes task scheduling to add other nodes within the local area network (LAN) of the target node cluster to the target node cluster. Especially in scenarios where the control plane cannot directly connect to nodes within the LAN (i.e., the control plane and the target node are not on the same LAN), the intranet nodes in this application function as jump servers in related technologies. However, compared to related technologies, this application utilizes existing nodes, particularly those within the target node cluster, eliminating the need to build additional jump servers. This avoids additional machine resource consumption and maintenance workload, thereby improving node addition efficiency.
[0043] It should be noted that the cluster node addition method provided in this application embodiment is mainly an improvement made for adding cluster nodes in scenarios where nodes cannot be directly connected to the local area network. However, this cluster node method can also be applied to scenarios where nodes are directly connected to the local area network.
[0044] It should be noted that the methods provided in this application embodiment may relate to cloud technology, such as cloud computing. Cloud computing refers to the delivery and usage model of IT infrastructure, meaning obtaining the required resources in an on-demand and easily scalable manner through the network. In a broader sense, cloud computing refers to the delivery and usage model of services, meaning obtaining the required services in an on-demand and easily scalable manner through the network. Such services can be IT and software related, internet-related, or other services. Cloud computing is a product of the development and integration of traditional computer and network technologies such as grid computing, distributed computing, parallel computing, utility computing, network storage technologies, virtualization, and load balancing.
[0045] With the development of the internet, real-time data streams, and the diversification of connected devices, as well as the demands for search services, social networks, mobile commerce, and open collaboration, cloud computing has rapidly developed. Unlike previous parallel distributed computing, cloud computing will fundamentally revolutionize the entire internet model and enterprise management model.
[0046] For example, this application is mainly used to add nodes to a Kubernetes cluster, which is a cluster of virtualized containers.
[0047] In addition, the methods provided in the embodiments of this application may also involve blockchain technology, such as the cluster node addition method disclosed in this application, wherein multiple nodes can be nodes on a blockchain.
[0048] To facilitate understanding of the cluster node addition method provided in this application embodiment, this application embodiment first introduces the system architecture for adding cluster nodes.
[0049] See Figure 4 , Figure 4 This is a schematic diagram of the system architecture for the cluster node addition method provided in this application embodiment. The system architecture includes a target node cluster 401 and target nodes 402. The target node cluster 401 can be a node cluster that needs to have nodes added, including one or more nodes, for example... Figure 4 Node 1 and target node 402 include one or more nodes, for example Figure 4 The target node cluster 401 can be a Kubernetes cluster, and nodes 1, 2, 3, and 4 can be terminals or servers.
[0050] The server can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server providing cloud computing services. The terminal can be a smartphone, tablet, laptop, desktop computer, etc., but is not limited to these. The terminal and server can be connected directly or indirectly via wired or wireless communication, which is not limited herein.
[0051] It should be noted that the method provided in this application embodiment can be executed by a node running the interface corresponding to the target node cluster. This node can be a server or a terminal. This application mainly uses a server as an example for introduction.
[0052] When a node needs to be added to the node cluster, the server can obtain the description information of the node addition task, so as to create the node addition task according to the description information and generate the corresponding configuration file and sensitive information. The server schedules the node addition task to an internal network node, so that the node addition task can be executed by the internal network node according to the configuration file. Here, the internal network node is a node located in the same local area network as the target node 402. Therefore, node 1 in the target node cluster 401 can be used as an internal network node.
[0053] Since the internal network node and the target node 402 to be added are located on the same local area network, during the node addition task, the server can directly log in to the target node 402 based on sensitive information to add the target node 402 to the target node cluster 401. If the addition of the target node 402 to the target node cluster 401 is completed, the target node cluster 401 will include node 1, node 2, node 3, and node 4.
[0054] This application utilizes task scheduling to add other nodes (target nodes) within the local area network (LAN) of the internal network node to the target node cluster. Especially in scenarios where the control plane of the target node cluster cannot directly connect to nodes within the LAN (i.e., the control plane and the target node are not on the same LAN), the internal network node in this application acts as a jump server in related technologies. However, compared to related technologies, this application utilizes existing nodes, especially those in the target node cluster, eliminating the need to build additional jump servers. This avoids additional machine resource consumption and maintenance workload, thus improving node addition efficiency.
[0055] Next, taking the server as the execution subject as an example, the method for adding cluster nodes provided in the embodiments of this application will be described in detail with reference to the accompanying drawings.
[0056] See Figure 5 , Figure 5 A flowchart illustrating a method for adding cluster nodes is shown, the method comprising:
[0057] S501. Obtain the description information of the task added to the node.
[0058] When it is necessary to add a node to the target node cluster, the user can trigger a node add request. This request can include some information pre-set by the user, such as the name of the target node to be added, the method of installing the node, and the location where the node add job that executes the node add command will run. This information is used to create a description of the node add job. The task that creates the description is generally a task.
[0059] This descriptive information can be represented by a node task card (nodes-task-crd), which mainly includes information such as interface version, type of descriptive information, metadata, and configuration data.
[0060] The interface version can be represented by `apiVersion`, for example, `task.tkeedge.io / v1`; the type of description information can be represented by `kind`, for example, `Task`; metadata can be represented by `metadata`; and configuration data can be represented by `spec`. Metadata mainly includes labels, task version (e.g., `v1`), and namespace; spec mainly includes `preName`, `crdVersion`, `mode`, `jobPosition`, `passWd`, `nodeName`, `nameIps`, `sshPort`, and `ips`. `preName` is the node name prefix, generated by adding a random string to the prefix; `crdVersion` is the unique identifier of the task CRD, which will be tagged with `crdVersion` after the node is successfully added; `mode` is the method of installing the node. When adding a node without direct connection, the value of `mode` is `springboard`, and when adding a node with direct connection, the value of `mode` is `direct`; `jobPosition` is the location where the job to be added to the node is executed. When `mode` is `springboard`, the value of `jobPosition` is `in-cluster`, and when `mode` is `direct`, the value of `jobPosition` is `in-cluster`; `passWd` is the passwd of the SSH login node; `sshPort` is the port for SSH connection; `nameIps` is a map of the node name and the Internet Protocol (IP) of the local area network. When installing a node, you can customize the node name or specify an existing node name for reinstalling the node; `ips` is a list of IPs of the local area network where the node is located, used for SSH login to the intranet node.
[0061] It should be noted that, since the method provided in this application embodiment can be applied to different node addition scenarios, the way of creating description information may differ in different scenarios.
[0062] If the target node cluster is managed uniformly by the control plane, the description information is created by the interface (MngCluster apiserver) corresponding to the node cluster running on the control plane in response to the user's node addition request.
[0063] See Figure 6 and Figure 7 As shown, users can send a node addition request to the interface corresponding to the node cluster running on the control plane through the command-line tool (kubectl), thereby requesting the creation of nodes-task-crd.
[0064] If the target node cluster is an independent node cluster, the description information is created by the interface (KAS) corresponding to the target node cluster in response to the user's node addition request.
[0065] See Figure 8 and Figure 9 As shown, the user directly sends a node add request to the KAS of the target node cluster, thereby requesting the creation of a nodes-task-crd. Figure 9 The node where KAS is located and the target node are on the same local area network.
[0066] In this embodiment, the creation of description information can be monitored through a node-task-operator. If the description information is detected as created, the node-task-operator can request the management node of the target node cluster's interface (KAS) to create a node and add tasks. Therefore, the management node can obtain the description information. This management node can be a server; that is, the server obtains the description information to create a node and add tasks based on it. The node-task-operator is implemented using Kubernetes Operator technology.
[0067] S502. Create a node to add a task based on the description information, and generate the configuration file and sensitive information corresponding to the node to add the task.
[0068] After obtaining the description information, the server can create a node addition task (add-node-job) based on the description information and generate the corresponding configuration file and sensitive information for the node addition task. The node addition task is a job task; the configuration file (configmap) is used to run the node addition task and can be represented as add-node-cm; the sensitive information (secret) is used to log in to the target node to perform the target node addition operation, including the SSH password (passwd) or private key (sshkey) for logging into the target node.
[0069] It should be noted that, since the method provided in this application embodiment can be applied to different node addition scenarios, the node addition task, as well as the corresponding configuration file and sensitive information generation method may be different in different scenarios.
[0070] If the target node cluster is managed uniformly by the control plane and the control plane and the target node are located on different local area networks, or if the target node cluster is an independent node cluster and the management node of the interface running the target node cluster is located on a different local area network than the target node (i.e., non-directly connected node addition), then the specific implementation of S502 can be to create a node addition task on the management node of the interface corresponding to the target node cluster and generate the configuration file and sensitive information corresponding to the node addition task.
[0071] See Figure 6 and Figure 8 As shown, after node-task-operator detects the creation of the description information, it will request the management node to create a job on that management node, and at the same time generate the configuration file required for the job to run and the sensitive information of the login target node.
[0072] If the target node cluster is managed uniformly by the control plane and the control plane and the target node are located on the same local area network, or if the target node cluster is an independent node cluster and the management node that runs the interface of the target node cluster is located on the same local area network as the target node (i.e., direct node addition), then the specific implementation of S502 can be to create a node addition task in the namespace where the description information is located, and generate the configuration file and sensitive information corresponding to the node addition task.
[0073] See Figure 7 and Figure 9 As shown, after node-task-operator detects the creation of the description information, it will request the management node to create a job task in the namespace where node-task-crd is located (e.g., cls-A namespace). At the same time, it will generate the configuration file required for the job task to run and the sensitive information of the login target node.
[0074] S503. The node addition task is scheduled to an intranet node, so that the intranet node executes the node addition task according to the configuration file. The intranet node and the target node to be added are located in the same local area network.
[0075] S504. During the execution of the node addition task, log in to the target node according to the sensitive information to add the target node to the target node cluster.
[0076] Since the internal network node and the target node to be added are located on the same local area network, the node addition task can be scheduled to the internal network node. The internal network node then executes the node addition task according to the configuration file, thereby directly logging into the target node based on sensitive information to add the target node to the target node cluster. For example, the target node... Figures 6-9 Nodes 2, 3, and 4 in the diagram.
[0077] Understandably, to avoid multiple nodes adding tasks and executing the add node command on the same target node, there should be only one job task for a single add node task, and at the same time, only one task task should be created for a user's Kubernetes cluster.
[0078] It should be noted that, since the method provided in this application embodiment can be applied to different node addition scenarios, the intranet nodes running the node addition task may be different in different scenarios.
[0079] If the target node cluster is managed uniformly by the control plane and the control plane and the target node are located on different local area networks, or if the target node cluster is an independent node cluster and the management node of the interface running the target node cluster is located on a different local area network than the target node (i.e., non-directly connected node addition), then the intranet node is a working node in the target node cluster.
[0080] See Figure 6 and Figure 8 As shown, at this time, the intranet node can be node 1 in the target node cluster, and node 1 is a worker node in the target node cluster. The node addition task will be scheduled to the specified node 1, and the add-node-job on node 1 will log in to the target node via SSH to execute the command to add the node.
[0081] If the target node cluster is managed uniformly by the control plane, and the control plane and the target nodes are located on the same local area network (i.e., when a directly connected node is added), then the intranet node is a node within the node cluster running on the control plane.
[0082] See Figure 7 As shown, at this time, the intranet node is a node in the node cluster running on the control plane. Then, add-node-job runs in the Kubernetes cluster on the control plane, logs into the target node via SSH, and executes the command to install the node.
[0083] If the target node cluster is an independent node cluster, and the management node of the interface running the target node cluster is located on the same local area network as the target node (i.e., a directly connected node is added), then the intranet node is the management node of the interface corresponding to the target node cluster.
[0084] See Figure 9As shown, in this case, the internal network node is the management node for the interface corresponding to the target node cluster. Therefore, `add-node-job` runs on the node where `kube-apiserver` resides. Log in to the target node via SSH and execute the command to install the node. In a standalone node cluster, `kube-apiserver` may have multiple instances; `add-node-job` runs on the node containing one of these instances.
[0085] As can be seen from the above technical solution, when it is necessary to add a node to the node cluster, this application can obtain the description information of the node addition task, so as to create the node addition task according to the description information and generate the configuration file and sensitive information corresponding to the node addition task. The node addition task is scheduled to the intranet node, so that the node addition task can be executed by the intranet node according to the configuration file. Since the intranet node and the target node to be added are located in the same local area network, during the execution of the node addition task, the target node can be directly logged in according to the sensitive information to add the target node to the target node cluster. This application realizes the addition of other nodes (target nodes) in the local area network where the intranet node is located to the target node cluster through task scheduling. Especially in the scenario where the control plane of the target node cluster cannot be directly connected to the nodes in the local area network (i.e., the control plane and the target node are not in the same local area network), the intranet node in this application plays the role of a jump machine in the related technology. However, compared with the related technology, this application uses existing nodes, especially nodes in the target node cluster, without the need to build an additional jump machine, thereby avoiding additional machine resource consumption and maintenance workload, and improving the node addition efficiency.
[0086] It is understandable that the success of the node addition task directly affects whether the target node is successfully added to the target node cluster. To promptly understand whether the node addition task has succeeded and to remedy any failures, this embodiment of the application can obtain a query request for the node addition task and determine whether the task has failed based on that request. If the query request determines that the task has failed, the node addition task is reissued.
[0087] Normally, a node addition task is deleted after it has been run. However, running a node addition task does not guarantee its success. In other words, a node addition task may not exist because it ran successfully, or because it was run but failed (i.e., some target nodes were not added to the target node cluster). Therefore, in one possible implementation, determining whether a node addition task failed based on a query request could involve checking the task's running status. If the status indicates the task does not exist, it means the task has already been run. In this case, it's necessary to further obtain the installation status of the target nodes to determine if all target nodes are installed. If the installation status indicates that not all target nodes are installed, the node addition task is considered to have failed.
[0088] If the node addition task fails to execute, it can be reissued. At this point, the node addition task can be recreated for the target nodes that were not fully installed, and the corresponding configuration file and sensitive information can be regenerated. The recreated node addition task can then be scheduled to an internal network node to execute the task, thus completing the addition of all target nodes.
[0089] The following describes how to query whether the node addition task has failed in different node addition scenarios, and how to reissue the node addition task when it fails.
[0090] If the target node cluster is managed uniformly by the control plane, and the control plane and the target nodes are located on different local area networks (LANs), or if the target node cluster is an independent node cluster, and the management node running the interface of the target node cluster is located on a different LAN than the target nodes. See also Figure 6 and Figure 8 As shown, node-task-operator periodically queries the target node cluster's interface for the running status of node add tasks. If the running status indicates that the node add task does not exist, it will request the target node cluster's interface to obtain the installation status of the target nodes. If the target nodes are not fully installed, it will recreate the node add task based on the incomplete installation of the target nodes, generate the configuration file and sensitive information required to run the node add task, and issue the recreated node add task.
[0091] If the target node cluster is managed uniformly by the control plane, and the control plane and the target nodes are located on the same local area network (i.e., adding directly connected nodes), see [link to documentation]. Figure 7As shown, the node-task-operator periodically queries the Kubernetes cluster interface in the control plane for the running status of node add tasks. If the running status indicates that the node add task does not exist, it will request the target node cluster interface to obtain the installation status of the target nodes. If the target nodes are not fully installed, it will recreate the node add task based on the incomplete installation of the target nodes, generate the configuration files and sensitive information required to run the node add task, and issue the recreated node add task.
[0092] If the target node cluster is an independent node cluster, and the management node of the interface running the target node cluster is located on the same local area network as the target nodes (i.e., adding a directly connected node), see [link to documentation]. Figure 9 As shown, node-task-operator periodically queries the target node cluster's interface for the running status of node add tasks. If the running status indicates that the node add task does not exist, it will request the target node cluster's interface to obtain the installation status of the target nodes. If not all target nodes are fully installed, it will recreate the node add task based on the incomplete installation of the target nodes, generate the configuration file and sensitive information required to run the node add task, and issue the recreated node add task.
[0093] Next, the cluster node addition method provided in this application embodiment will be introduced in conjunction with a practical application scenario. A user wants to add a target node within a local area network (LAN) to a target node cluster (e.g., a Kubernetes cluster). However, the control plane of the Kubernetes cluster cannot directly connect to the target node within the LAN; that is, the control plane and the target node are located on different LANs. In this case, to avoid adding nodes by setting up a jump server within the LAN, thereby avoiding additional machine resource consumption and maintenance workload, the cluster node addition method provided in this application embodiment can be used to add the target node to the Kubernetes cluster.
[0094] See Figure 10 The method includes:
[0095] S1001. Users send a node addition request to the corresponding interface of the Kubernetes cluster in the control plane via command-line tools.
[0096] The node add request is used to request the creation of nodes-task-crd, which is used to write the description information of the node add task.
[0097] S1002, Create nodes-task-crd.
[0098] S1003. If the node task operator detects that nodes-task-crd has been created, it requests the management node of the interface running the target node cluster to create a node to add the task.
[0099] S1004. The management node of the target node cluster interface creates a node to add a task, and generates the configuration file and sensitive information corresponding to the node to add the task.
[0100] S1005. Add a task to the node and schedule it to the intranet node.
[0101] The internal network node is located on the same local area network as the target node, and the internal network node is a node in the target node cluster.
[0102] S1006. The node addition task is executed through the internal network node according to the configuration file. During the execution of the node addition task, the target node is logged in according to the sensitive information to add the target node to the target node cluster.
[0103] S1007. The node task operator periodically queries the interface of the target node cluster to check the running status of the added tasks on the node.
[0104] S1008. If the running status indicates that the node addition task does not exist, the system will request the target node cluster's interface to obtain the target node's installation status.
[0105] S1009. Determine whether all target nodes have been installed based on the installation status. If yes, end the process; otherwise, re-execute S1004 based on the target nodes that have not been installed.
[0106] In other words, if it is determined from the installation status that not all target nodes have been installed, the node addition task is recreated based on the target nodes that have not been installed, and the configuration file and sensitive information required to run the node addition task are generated. The recreated node addition task is then issued to add all target nodes to the target node cluster.
[0107] based on Figure 5 Corresponding to the cluster node addition method provided in the embodiments, this application also provides a cluster node addition device 1100, see below. Figure 11 The device 1100 includes an acquisition unit 1101, a generation unit 1102, a scheduling unit 1103, and an addition unit 1104.
[0108] The acquisition unit 1101 is used to acquire description information of the task added by the node;
[0109] The generation unit 1102 is used to create a node adding task based on the description information, and generate the configuration file and sensitive information corresponding to the node adding task;
[0110] The scheduling unit 1103 is used to schedule the node addition task to an intranet node, so that the intranet node can execute the node addition task according to the configuration file. The intranet node and the target node to be added are located in the same local area network.
[0111] The adding unit 1104 is used to log in to the target node according to the sensitive information to add the target node to the target node cluster during the execution of the node adding task.
[0112] In one possible implementation, the target node cluster is uniformly managed by the control plane, and the description information is created by the interface corresponding to the node cluster running on the control plane in response to the user's node addition request.
[0113] In one possible implementation, the control plane and the target node are located on different local area networks, and the generation unit 1102 is used for:
[0114] Create the node addition task on the management node that runs the interface corresponding to the target node cluster, and generate the configuration file and sensitive information corresponding to the node addition task.
[0115] In one possible implementation, the intranet node is a worker node in the target node cluster.
[0116] In one possible implementation, if the control plane and the target node are located on the same local area network, the generation unit 1102 is used to:
[0117] Create the node and add the task in the namespace where the description information is located, and generate the configuration file and sensitive information corresponding to the node and add the task;
[0118] Correspondingly, the intranet node is a node within the node cluster running on the control plane.
[0119] In one possible implementation, the target node cluster is an independent node cluster, and the description information is created by the interface corresponding to the target node cluster in response to the user's node addition request.
[0120] In one possible implementation, the generation unit 1102 is used for:
[0121] Create the node addition task on the management node that runs the interface corresponding to the target node cluster, and generate the configuration file and sensitive information corresponding to the node addition task;
[0122] Alternatively, create the node to add a task in the namespace where the description information is located, and generate the configuration file and sensitive information corresponding to the node to add the task.
[0123] In one possible implementation, the intranet node is a worker node in the target node cluster, or a management node that runs the interface corresponding to the target node cluster.
[0124] In one possible implementation, the acquisition unit 1101 is further configured to:
[0125] Obtain the query request for adding a task to the node;
[0126] The device further includes a sending unit, the sending unit being used for:
[0127] If the query request determines that the node addition task failed to execute, the node addition task will be reissued.
[0128] In one possible implementation, the sending unit is specifically used for:
[0129] The query request is used to query the running status of the tasks added to the node;
[0130] If the running status indicates that the node does not have an added task, obtain the installation status of the target node;
[0131] If, based on the installation status, it is determined that not all target nodes have been installed, the task of adding the node has failed.
[0132] In one possible implementation, the sending unit is specifically used for:
[0133] For target nodes that have not been fully installed, recreate the node, add the task, and regenerate the configuration file and sensitive information corresponding to the node task.
[0134] Add tasks to the newly created node and schedule them to the intranet node.
[0135] As can be seen from the above technical solution, when it is necessary to add a node to the node cluster, this application can obtain the description information of the node addition task, so as to create the node addition task according to the description information and generate the configuration file and sensitive information corresponding to the node addition task. The node addition task is scheduled to the intranet node, so that the node addition task can be executed by the intranet node according to the configuration file. Since the intranet node and the target node to be added are located in the same local area network, during the execution of the node addition task, the target node can be directly logged in according to the sensitive information to add the target node to the target node cluster. This application realizes the addition of other nodes (target nodes) in the local area network where the intranet node is located to the target node cluster through task scheduling. Especially in the scenario where the control plane of the target node cluster cannot be directly connected to the nodes in the local area network (i.e., the control plane and the target node are not in the same local area network), the intranet node in this application plays the role of a jump machine in the related technology. However, compared with the related technology, this application uses existing nodes, especially nodes in the target node cluster, without the need to build an additional jump machine, thereby avoiding additional machine resource consumption and maintenance workload, and improving the node addition efficiency.
[0136] This application also provides an electronic device for adding cluster nodes. The electronic device can be a terminal, for example, a smartphone.
[0137] Figure 12 This is a block diagram illustrating a portion of the structure of a smartphone related to the terminal provided in the embodiments of this application. (Reference) Figure 12 The smartphone includes components such as: a radio frequency (RF) circuit 1210, a memory 1220, an input unit 1230, a display unit 1240, a sensor 1250, an audio circuit 1260, a wireless fidelity (WiFi) module 1270, a processor 1280, and a power supply 1290. The input unit 1230 may include a touch panel 1231 and other input devices 1232; the display unit 1240 may include a display panel 1241; and the audio circuit 1260 may include a speaker 1261 and a microphone 1262. Those skilled in the art will understand that... Figure 12 The smartphone structure shown does not constitute a limitation on smartphones and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0138] The memory 1220 can be used to store software programs and modules. The processor 1280 executes various functions and data processing of the smartphone by running the software programs and modules stored in the memory 1220. The memory 1220 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, applications required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the smartphone (such as audio data, phonebook, etc.). In addition, the memory 1220 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0139] The processor 1280 is the control center of the smartphone, connecting various parts of the smartphone via various interfaces and lines. It performs various functions and processes data by running or executing software programs and / or modules stored in the memory 1220 and calling data stored in the memory 1220. Optionally, the processor 1280 may include one or more processing units; preferably, the processor 1280 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 1280.
[0140] In this embodiment, the processor 1280 in the terminal can perform the following steps:
[0141] Retrieve the description information of the task added to the node;
[0142] Create a node to add a task based on the description information, and generate the configuration file and sensitive information corresponding to the node to add the task;
[0143] The node addition task is scheduled to an intranet node, so that the intranet node can execute the node addition task according to the configuration file. The intranet node and the target node to be added are located in the same local area network.
[0144] During the execution of the node addition task, the target node is logged in based on the sensitive information to add the target node to the target node cluster.
[0145] The electronic device may also include a server; embodiments of this application also provide a server, please refer to [link to relevant documentation]. Figure 13 As shown, Figure 13The diagram illustrates the structure of a server 1300 provided in this embodiment. The server 1300 can vary significantly due to different configurations or performance characteristics. It may include one or more central processing units (CPUs) 1322 (e.g., one or more processors) and a memory 1332, and one or more storage media 1330 (e.g., one or more mass storage devices) for storing application programs 1342 or data 1344. The memory 1332 and storage media 1330 may be temporary or persistent storage. The program stored in the storage media 1330 may include one or more modules (not shown in the diagram), each module including a series of instruction operations on the server. Furthermore, the CPU 1322 may be configured to communicate with the storage media 1330 and execute the series of instruction operations stored in the storage media 1330 on the server 1300.
[0146] Server 1300 may also include one or more power supplies 1326, one or more wired or wireless network interfaces 1350, one or more input / output interfaces 1358, and / or one or more operating systems 1341, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0147] In this embodiment, the central processing unit 1322 in the server 1300 can perform the following steps:
[0148] Retrieve the description information of the task added to the node;
[0149] Create a node to add a task based on the description information, and generate the configuration file and sensitive information corresponding to the node to add the task;
[0150] The node addition task is scheduled to an intranet node, so that the intranet node can execute the node addition task according to the configuration file. The intranet node and the target node to be added are located in the same local area network.
[0151] During the execution of the node addition task, the target node is logged in based on the sensitive information to add the target node to the target node cluster.
[0152] According to one aspect of this application, a computer-readable storage medium is provided for storing program code for executing the cluster node addition method described in the foregoing embodiments.
[0153] According to one aspect of this application, a computer program product or computer program is provided, comprising 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 executes the computer instructions, causing the computer device to perform the methods provided in various optional implementations of the above embodiments.
[0154] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0155] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.
[0156] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0157] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0158] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0159] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A method for adding cluster nodes, characterized in that, The method includes: Retrieve the description information of the task added to the node; Create a node to add a task based on the description information, and generate the configuration file and sensitive information corresponding to the node to add the task; The node addition task is scheduled to an intranet node so that the intranet node can execute the node addition task according to the configuration file. The intranet node and the target node to be added are located in the same local area network. During the execution of the node addition task, the target node is logged in based on the sensitive information to add the target node to the target node cluster; Wherein, the target node cluster is uniformly managed by the control plane, and the description information is created by the interface corresponding to the node cluster running on the control plane in response to the user's node addition request; or, the target node cluster is an independent node cluster, and the description information is created by the interface corresponding to the target node cluster in response to the user's node addition request. If the target node cluster is uniformly managed by the control plane and the control plane and the target node are located on different local area networks, or if the target node cluster is an independent node cluster and the management node running the interface of the target node cluster is located on a different local area network than the target node, then the step of creating a node addition task based on the description information and generating the configuration file and sensitive information corresponding to the node addition task includes: after the node task operator detects that the description information has been created, requesting the management node running the interface corresponding to the target node cluster to create the node addition task and generating the configuration file and sensitive information corresponding to the node addition task through the node task operator.
2. The method according to claim 1, characterized in that, If the target node cluster is managed uniformly by a control plane and the control plane and the target node are located in different local area networks, then the intranet node is a working node in the target node cluster.
3. The method according to claim 1, characterized in that, If the target node cluster is uniformly managed by the control plane and the control plane and the target nodes are located on the same local area network, then the step of creating a node adding task based on the description information and generating the configuration file and sensitive information corresponding to the node adding task includes: Create the node and add the task in the namespace where the description information is located, and generate the configuration file and sensitive information corresponding to the node and add the task; Correspondingly, the intranet node is a node within the node cluster running on the control plane.
4. The method according to claim 1, characterized in that, If the target node cluster is an independent node cluster and the management node running the interface of the target node cluster is located on the same local area network as the target node, the step of creating a node addition task based on the description information and generating the configuration file and sensitive information corresponding to the node addition task includes: Create the node and add the task in the namespace where the description information is located, and generate the configuration file and sensitive information corresponding to the node and add the task.
5. The method according to claim 1, characterized in that, If the target node cluster is an independent node cluster and the management node running the interface of the target node cluster is located on a different local area network than the target node, then the intranet node is a working node in the target node cluster. or, If the target node cluster is an independent node cluster and the management node of the interface running the target node cluster is located on the same local area network as the target node, then the intranet node is the management node of the interface running the target node cluster.
6. The method according to any one of claims 1-5, characterized in that, The method further includes: Obtain the query request for adding a task to the node; If the query request determines that the node addition task failed to execute, the node addition task will be reissued.
7. The method according to claim 6, characterized in that, The step of determining that the node's task addition failed to execute based on the query request includes: The query request is used to query the running status of the tasks added to the node; If the running status indicates that the node does not have an added task, obtain the installation status of the target node; If, based on the installation status, it is determined that not all target nodes have been installed, the task of adding the node has failed.
8. The method according to claim 7, characterized in that, The process of re-issuing the node to add tasks includes: For target nodes that have not been fully installed, recreate the node, add the task, and regenerate the configuration file and sensitive information corresponding to the node task. Add tasks to the newly created node and schedule them to the intranet node.
9. A cluster node adding device, characterized in that, The device includes an acquisition unit, a generation unit, a scheduling unit, and an addition unit: The acquisition unit is used to acquire description information of the task added by the node; The generation unit is used to create a node adding task based on the description information, and generate the configuration file and sensitive information corresponding to the node adding task; The scheduling unit is used to schedule the node addition task to an intranet node, so that the intranet node can execute the node addition task according to the configuration file. The intranet node and the target node to be added are located in the same local area network. The adding unit is used to log in to the target node based on the sensitive information to add the target node to the target node cluster during the execution of the node adding task; Wherein, the target node cluster is uniformly managed by the control plane, and the description information is created by the interface corresponding to the node cluster running on the control plane in response to the user's node addition request; or, the target node cluster is an independent node cluster, and the description information is created by the interface corresponding to the target node cluster in response to the user's node addition request. If the target node cluster is uniformly managed by the control plane and the control plane and the target node are located on different local area networks, or if the target node cluster is an independent node cluster and the management node running the interface of the target node cluster is located on a different local area network than the target node, then the generation unit is specifically used to: after the node task operator detects that the description information has been created, request the management node running the interface corresponding to the target node cluster to create the node addition task through the node task operator, and generate the configuration file and sensitive information corresponding to the node addition task.
10. The apparatus according to claim 9, characterized in that, The target node cluster is managed uniformly by the control plane, and the description information is created by the interface corresponding to the node cluster running on the control plane in response to the user's node addition request.
11. An electronic device for adding cluster nodes, characterized in that, The electronic device includes a processor and a memory: The memory is used to store program code and transmit the program code to the processor; The processor is configured to execute the method according to any one of claims 1-8 according to the instructions in the program code.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store program code for performing the method according to any one of claims 1-8.
13. A computer program product, characterized in that, The method 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 executes the computer instructions to cause the computer device to perform the method according to any one of claims 1-8.