Container cluster node updating method and device, electronic equipment and medium
By using in-situ updates of tag and configuration mapping resources in the Kubernetes cluster, the problem of data loss during cluster node updates is solved, node configuration and local data are preserved, and business continuity is ensured.
Patent Information
- Application Number
- CN202511096462.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-04
- Publication Date
- 2025-12-12
AI Technical Summary
In the Kubernetes ecosystem, when cluster nodes are updated, existing technologies can cause the loss of configuration data on the host machine and local storage data, affecting business continuity.
An in-situ tag update mechanism is adopted. By configuring the mapping resource record node identification information, the node instance is obtained and updated, while retaining the original node configuration and local storage data.
It enables in-situ updates of cluster nodes, preserving the original node configurations, local services, and stored data, ensuring that services can be used normally after the update.
Smart Images

Figure CN121116481A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present specification relates to the technical field of cloud computing, and particularly relates to a container cluster node updating method and device, electronic equipment and medium. BACKGROUND
[0002] In the Kubernetes ecosystem, deploying and managing a cluster is a complex task. In the traditional way, a large number of infrastructure resources need to be manually configured, Kubernetes components need to be installed, and the life cycle of the cluster needs to be maintained.
[0003] The Kubernetes official provides a Cluster API framework to simplify this process. The Cluster API framework uses a declarative API for the creation, configuration and management of clusters. By defining a CRD (Custom Resource Definition), it allows users to manage clusters in the same way as other resources in Kubernetes.
[0004] However, when updating the control plane node pool and worker node pool using the Cluster API, all nodes of the cluster need to be replaced by rolling, and new node instances need to be created to replace old instances, which will cause the configuration data on the host (such as user configuration, local storage data, local services, etc.) to be lost. SUMMARY
[0005] To overcome the problems in the related art, the present specification provides a container cluster node updating method, device, electronic equipment and medium.
[0006] According to a first aspect of an embodiment of the present specification, a container cluster node updating method is provided, the method comprising: updating control plane resources and / or machine deployment resources of a target node in a target cluster if the target cluster is configured with an in-place update label; writing node identification information of the target node into a configuration mapping resource; obtaining a corresponding node instance according to the node identification information in the configuration mapping resource; and updating the node instance.
[0007] According to a second aspect of an embodiment of the present specification, a container cluster node device is provided, comprising: a first updating module configured to update control plane resources and / or machine deployment resources of a target node in a target cluster if the target cluster is configured with an in-place update label; a writing module configured to write node identification information of the target node into a configuration mapping resource; an obtaining module configured to obtain a corresponding node instance according to the node identification information in the configuration mapping resource; and a second updating module configured to update the node instance.
[0008] According to a third aspect of the embodiments of the present specification, an electronic device is provided, comprising:
[0009] a processor;
[0010] a memory for storing processor-executable instructions;
[0011] The processor is configured to perform the container cluster node updating method of the first aspect or any of the corresponding embodiments thereof.
[0012] According to a fourth aspect of the embodiments of the present specification, a computer readable storage medium is provided, and the computer readable storage medium stores computer instructions for causing a computer to perform the container cluster node updating method of the first aspect or any of the corresponding embodiments thereof.
[0013] The technical solutions provided by the embodiments of the present specification can include the following beneficial effects:
[0014] In the embodiments of the present specification, in-place updating of the cluster node is implemented, and while updating the node corresponding configuration and components according to the requirements, the original configuration, local service and local storage data of the node can be preserved, so that all businesses can be normally used after the cluster is updated.
[0015] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present specification. BRIEF DESCRIPTION OF DRAWINGS
[0016] The accompanying drawings incorporated in the specification and constituting a part of the specification illustrate embodiments consistent with the present specification and serve together with the specification to explain the principles of the present specification.
[0017] Figure 1 is a flowchart of a container cluster node updating method according to an exemplary embodiment of the present specification.
[0018] Figure 2 is a schematic diagram of a system architecture according to an exemplary embodiment of the present specification.
[0019] Figure 3 is a flowchart of another container cluster node updating method according to an exemplary embodiment of the present specification.
[0020] Figure 4 is a hardware structure diagram of a computer device in which the container cluster node updating apparatus of the embodiments of the present specification is located.
[0021] Figure 5 is a block diagram of a container cluster node updating apparatus according to an exemplary embodiment of the present specification. DETAILED DESCRIPTION
[0022] The exemplary embodiments will be described in detail herein with reference to the attached drawings. The description of the exemplary embodiments is intended to apply to various alternative embodiments as well. It is to be understood that the description of any exemplary embodiment is intended only to be used to interpret and understand the scope of the application as set forth in the appended claims.
[0023] The terminology used in the description herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the specification. As used in the description and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
[0024] It is to be understood that although the terms first, second, third, etc. can be used herein to describe various information, the information should not be limited to these terms. These terms are only used to distinguish one piece of information from another. For example, a first information can also be termed a second information, and, similarly, a second information can also be termed a first information, without departing from the scope of the present specification. As used herein, the term "if' can be construed to mean "when" or "in response to determining" depending on the context.
[0025] Next, the embodiments of the present specification will be described in detail.
[0026] The container cluster node updating method provided by the embodiments of the present specification will be described in detail below. As shown in Figure 1 Figure 1 is a flowchart of a container cluster node updating method according to an exemplary embodiment of the present specification. The container cluster node updating method provided by the embodiments of the present specification can include the steps as shown below.
[0027] In step 110, in the case where the target cluster is configured with an in-place update label, update the control plane resources and / or machine deployment resources of the target node in the target cluster.
[0028] According to the embodiments of the present specification, the in-place update label can be used to indicate that the nodes of the cluster adopt an in-place update mode during updating. In the in-place update mode, the original user configuration, local storage data, and local services of the node can be retained. The user configuration may, for example, include network policies, hosts, and the like.
[0029] Optionally, the in-place update label can be configured for the target cluster, for example, when creating a cluster resource of the target cluster. Optionally, the target cluster is a container cluster, for example, can include a Kubernetes cluster managed by the Cluster API. The control plane resource can include a KubeControlPlane resource, for example. The machine deployment resource can include a MachineDeployment resource, for example.
[0030] In step 120, the node identification information of the target node is written into the configuration mapping resource.
[0031] According to an embodiment of the present specification, the configuration mapping resource can be used to record nodes that can be reused. The configuration mapping resource can include a one-to-one correspondence between node identification information and node instances. The node identification information can include a node IP address and / or a node instance identifier, for example.
[0032] Optionally, the configuration mapping resource corresponding to the target cluster can be created for the target cluster, for example, when creating a cluster resource of the target cluster.
[0033] Optionally, step 110 can also be performed simultaneously with step 120, or step 120 can be performed prior to step 110.
[0034] In step 130, the corresponding node instance is obtained according to the node identification information in the configuration mapping resource.
[0035] According to an embodiment of the present specification, the cloud infrastructure API (application programming interface) can be called to obtain the node instance according to the node identification information in the configuration mapping resource, for example.
[0036] In step 140, the node instance is updated.
[0037] According to an embodiment of the present specification, the updated data can include configurations and / or components.
[0038] In the case where the updated data includes configurations, step 110 can include determining attribute change data before and after the update of the control plane resource and / or the machine deployment resource, and then cleaning up the configurations corresponding to the attribute change data, for example. Step 140 can include updating the configurations of the node instance according to the attribute change data, for example.
[0039] In the case where the updated data includes components, step 110 can include determining attribute change data before and after the update of the control plane resource and / or the machine deployment resource, and then uninstalling the components corresponding to the attribute change data, for example. Step 140 can include updating the components corresponding to the node instance according to the attribute change data, for example.
[0040] According to the container cluster node updating method and device, in-situ updating of the cluster node is implemented, and the original configuration, local service and local storage data of the node can be retained while updating the corresponding configuration and components of the node according to requirements, so that all services can be normally used after the cluster is updated.
[0041] Optionally, after steps 110 and 120 are completed, the state of the target node can be set as successful deletion, so that the cluster API controller considers that the target node has completed deletion, and the original configuration, local service and local storage data of the node are avoided from being deleted. After step 140 is completed, the state of the target node can be set as successful creation, so that the cluster API controller considers that the target node has completed creation, and the node is reused.
[0042] The following will be described in combination with Figure 2 It should be noted that, Figure 2 The system architecture shown is only an example of a system architecture to which the embodiments of the present specification can be applied, to help those skilled in the art understand the technical content of the present specification, but does not mean that the embodiments of the present specification cannot be applied to other devices, systems, environments or scenarios.
[0043] Figure 2 FIG. 1 is a schematic diagram of a system architecture according to an example embodiment of the present specification.
[0044] As Figure 2 shown, the system architecture may, for example, include a management layer (Cluster API controller), a user CRD resource layer, an infrastructure layer and a container cluster layer.
[0045] According to the embodiments of the present specification, the management layer can include:
[0046] 1) Cluster Controller: Cluster controller, which can be used to monitor Cluster resources, coordinate and control the state of the control plane and infrastructure.
[0047] 2) Infrastructure Provider Controller: Infrastructure Provider Controller, which can be used to interface with a cloud platform, create virtual machines, networks and other resources by interacting with the cloud platform API.
[0048] 3) KubeControlPlane Controller: Control plane node pool controller, which can be used to create control plane nodes (such as EC2 instances) according to KubeControlPlane configuration.
[0049] 4) MachineDeployment Controller: The machine deployment controller can be used to manage MachineDeployment resources (worker node pool resources), such as creating and deleting worker nodes.
[0050] The user CRD resource layer may include, for example:
[0051] 1) Cluster: Cluster resources can be used to define the metadata (such as name, network configuration, Kubernetes version, etc.) and infrastructure references of a Kubernetes cluster.
[0052] 2) KubeControlPlane: Control plane node pool resources, which can be used to define the deployment specifications of the Kubernetes control plane, including core components such as API Server, Scheduler, and Controller Manager.
[0053] 3) MachineDeployment: Worker node pool resource, which can be used to manage the declarative configuration of the worker node pool and supports automatic scaling and rolling updates.
[0054] The infrastructure layer may include cloud resources and nodes. Nodes may be in the form of virtual machines (VMs) or instances. For example, in this embodiment, nodes may include control nodes and worker nodes. For example, in this embodiment, virtual machines or physical machines may be created as nodes of a Kubernetes cluster, and cloud resources such as network and storage may be created.
[0055] At the container cluster layer, Kubernetes cluster infrastructure components such as kube-apiserver, etcd, kubelet, and kube-proxy can be installed on nodes to provide container cluster services to the outside world.
[0056] like Figure 3 The diagram shown is a flowchart illustrating another container cluster node update method according to an exemplary embodiment. Based on the aforementioned embodiments, this implementation describes a process for updating container cluster nodes using a Kubernetes cluster managed by the Cluster API as an example, including the following steps:
[0057] 1) Cluster creation, Infrastructure Provider Controller listens to the creation of Cluster resource and creates a corresponding configuration mapping resource ConfigMap, sets OwnerReference as the current Cluster. Initially, the data in ConfigMap is empty.
[0058] 2) Cluster change, if in-place update, mark Cluster resource with in-place label. When Cluster API Controller listens to Cluster resource change event, call the corresponding cloud infrastructure API to complete the update of cluster network, load balancer and other resources.
[0059] 3) Cluster API Controller updates KubeControlPlane and MachineDeployment resources, and these two resources automatically inherit the in-place label of Cluster resource.
[0060] KubeControlPlane and MachineDeployment controllers listen to resource changes and trigger node in-place update procedures, which include Cluster API node resource deletion and creation actions.
[0061] 4) When Cluster API node resource is deleted, if the current cluster has an in-place label, Infrastructure Provider Controller does not delete the node instance on the cloud, but compares the attribute changes of KubeControlPlane and MachineDeployment new resources and old resources before and after the update. According to the content of the attribute changes, execute scripts to clean up the corresponding changes, uninstall the corresponding components, etc. (such as using kubeadm to uninstall Kubernetes and other components, configurations, etc.), keep other configurations and data of the node unchanged. Finally, set the status of the current node resource to successful deletion, so that the Cluster API controller considers that the current node has been deleted.
[0062] 5) Save the information of the node in ConfigMap, ConfigMap can save the one-to-one correspondence between the unique key of the node instance and the Cluster API node resource, which is used to find the node when it is reused.
[0063] The data structure of the ConfigMap can have a key, and the value of the key can include, but is not limited to, a node instance ID (identity code), a node IP address, and the like. Exemplarily, when the node has a fixed IP address, the IP can be used as the stored key value. When the node obtains an IP address through DHCP (Dynamic Host Configuration Protocol), the node instance ID can be used as the stored key value.
[0064] 6) When a new Cluster API node resource is created, if the current cluster has an in-place label, the Infrastructure Provider Controller does not create an actual node, but calls the corresponding cloud infrastructure API to obtain node instance information according to the node IP address or node instance ID stored in the ConfigMap. Then the node instance is logged in (for example, the node instance can be logged in through SSH (Secure Shell) and the like), and then the node configuration or Kubernetes component update operation is completed by executing a script, and the information corresponding to the node in the ConfigMap is cleaned up. Finally, the state of the current node resource is set to creation success, and the Cluster API controller considers that the current node has been created.
[0065] Thus, for the cluster managed by the Cluster API, the in-place update of the Kubernetes cluster node is realized, and while updating the node corresponding configuration and component according to the requirements, the original node configuration, local service and local storage data can be preserved, so that each business can be normally used after the Kubernetes cluster is updated.
[0066] Corresponding to the embodiments of the foregoing method, the specification also provides embodiments of a container cluster node updating apparatus and a terminal to which the container cluster node updating apparatus is applied.
[0067] The embodiments of the container cluster node updating apparatus of the specification can be applied to a computer device, such as a server or a terminal device. The apparatus embodiments can be implemented through software, or through hardware or a combination of software and hardware. Taking software implementation as an example, as a logically meaningful apparatus, the apparatus is formed by a processor reading corresponding computer program instructions in a non-volatile memory into a memory for execution. From the hardware level, as shown in Figure 4 As shown in FIG. 4, in addition to the processor 410, the memory 430, the network interface 420, and the non-volatile memory 440, the server or the electronic device in which the apparatus 431 in the embodiments is located, according to the actual function of the computer device, can also include other hardware, and details are not described herein. Figure 4 As shown in FIG. 4, in addition to the processor 410, the memory 430, the network interface 420, and the non-volatile memory 440, the server or the electronic device in which the apparatus 431 in the embodiments is located, according to the actual function of the computer device, can also include other hardware, and details are not described herein.
[0068] As Figure 5 shown, Figure 5 is a block diagram of a container cluster node updating apparatus according to an exemplary embodiment of the present specification, the apparatus comprising:
[0069] The first updating module 510 is configured to update the control plane resource and / or the machine deployment resource of the target node in the target cluster if the target cluster is configured with an in-place updating label;
[0070] The writing module 520 is configured to write the node identification information of the target node into the configuration mapping resource;
[0071] The obtaining module 530 is configured to obtain the corresponding node instance according to the node identification information in the configuration mapping resource;
[0072] The second updating module 540 is configured to update the node instance.
[0073] Optionally, the apparatus can further comprise:
[0074] The configuration module is configured to create the configuration mapping resource corresponding to the target cluster and configure the target cluster with the in-place updating label if the cluster resource creation event of the target cluster is listened to.
[0075] Optionally, the first updating module can comprise:
[0076] The first determining submodule is configured to determine the attribute change data before and after the updating of the control plane resource and / or the machine deployment resource;
[0077] The cleaning submodule is configured to clean the configuration corresponding to the attribute change data;
[0078] The second updating module can comprise:
[0079] The configuration updating submodule is configured to update the configuration of the node instance according to the attribute change data.
[0080] Optionally, the first updating module can comprise:
[0081] The second determining submodule is configured to determine the attribute change data before and after the updating of the control plane resource and / or the machine deployment resource;
[0082] The uninstalling submodule is configured to uninstall the component corresponding to the attribute change data;
[0083] The second updating module can comprise:
[0084] The component updating submodule is configured to update the component corresponding to the node instance according to the attribute change data.
[0085] Optionally, the node identification information includes the node IP address and / or node instance identifier; the acquisition module may include:
[0086] The calling submodule is used to call the corresponding cloud infrastructure interface to obtain the node instance based on the node IP address and / or node instance identifier.
[0087] The container cluster node update device according to the embodiments of this specification realizes in-situ update of cluster nodes. While updating the corresponding configuration and components of the nodes according to the requirements, it can retain the original configuration, local services and local storage data of the nodes, so that all services can be used normally after the cluster is updated.
[0088] Accordingly, this specification also provides an electronic device, which includes a processor; a memory for storing processor-executable instructions; wherein the processor is configured to: update the control plane resources and / or machine deployment resources of the target node in the target cluster when the target cluster is configured with in-situ update tags; write the node identification information of the target node into the configuration mapping resource; obtain the corresponding node instance according to the node identification information in the configuration mapping resource; and update the node instance.
[0089] The specific implementation process of the functions and roles of each module in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0090] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of the solution in this specification according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0091] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0092] Other embodiments of this specification will readily occur to those skilled in the art upon consideration of the specification and practice of the invention claimed herein. This specification is intended to cover any variations, uses, or adaptations that follow the general principles of this specification and include common knowledge or customary techniques in the art not claimed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this specification are indicated by the following claims.
[0093] It should be understood that this specification is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this specification is limited only by the appended claims.
[0094] The above description is merely a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of protection of this specification.
Claims
1. A method for updating nodes in a container cluster, characterized in that, The method includes: If the target cluster is configured with in-situ update tags, update the control plane resources and / or machine deployment resources of the target nodes in the target cluster. Write the node identifier information of the target node into the configuration mapping resource; Based on the node identifier information in the configuration mapping resource, obtain the corresponding node instance; Update the node instance.
2. The method according to claim 1, characterized in that, The method further includes: If a cluster resource creation event for the target cluster is detected, a configuration mapping resource corresponding to the target cluster is created, and an in-situ update tag is configured for the target cluster.
3. The method according to claim 1, characterized in that, The updating of the control plane resources and / or machine deployment resources of the target nodes in the target cluster includes: Determine the attribute changes of control plane resources and / or machine deployment resources before and after the update; Clean up the configuration corresponding to the attribute change data; The update of the node instance includes: The configuration of the node instance is updated based on the attribute change data.
4. The method according to claim 1, characterized in that, The updating of the control plane resources and / or machine deployment resources of the target nodes in the target cluster includes: Determine the attribute changes of control plane resources and / or machine deployment resources before and after the update; Unload the component corresponding to the attribute change data; The update of the node instance includes: Based on the attribute change data, the components corresponding to the node instance are updated.
5. The method according to claim 1, characterized in that, The node identification information includes the node IP address and / or node instance identifier; obtaining the corresponding node instance based on the node identification information in the configuration mapping resource includes: Based on the node IP address and / or node instance identifier, the corresponding cloud infrastructure interface is invoked to obtain the node instance.
6. A container cluster node update device, characterized in that, The device includes: The first update module is used to update the control plane resources and / or machine deployment resources of the target nodes in the target cluster when the target cluster is configured with an in-situ update tag. The writing module is used to write the node identification information of the target node into the configuration mapping resource; The acquisition module is used to obtain the corresponding node instance based on the node identifier information in the configuration mapping resource; The second update module is used to update the node instance.
7. The apparatus according to claim 6, characterized in that, The device further includes: The configuration module is used to create a configuration mapping resource corresponding to the target cluster and configure an in-situ update tag for the target cluster if a cluster resource creation event is detected.
8. The apparatus according to claim 6, characterized in that, The first update module includes: The first determination submodule is used to determine the attribute change data before and after the update of control plane resources and / or machine deployment resources; The cleanup submodule is used to clean up the configuration corresponding to the attribute change data; The second update module includes: The configuration update submodule is used to update the configuration of the node instance based on the attribute change data.
9. The apparatus according to claim 6, characterized in that, The first update module includes: The second determination submodule is used to determine the attribute change data before and after the update of control plane resources and / or machine deployment resources; The uninstallation submodule is used to uninstall the components corresponding to the attribute change data; The second update module includes: The component update submodule is used to update the component corresponding to the node instance based on the attribute change data.
10. The apparatus according to claim 6, characterized in that, The node identification information includes the node IP address and / or the node instance identifier; the acquisition module includes: The calling submodule is used to call the corresponding cloud infrastructure interface based on the node IP address and / or node instance identifier to obtain the node instance.
11. An electronic device, characterized in that, The electronic device includes: processor; Memory used to store processor-executable instructions; The processor is configured to perform the method of any one of claims 1 to 5.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a computer to perform the method of any one of claims 1 to 5.