Kubernetes cluster upgrading method and device, computer equipment, readable storage medium and program product
By pre-checking and mirroring file upgrade methods for kubernets clusters, the problem of high cost of upgrading the kubernets cluster version is solved, and an efficient and accurate cluster upgrade process is achieved.
Patent Information
- Application Number
- CN202411780250.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-03-21
AI Technical Summary
The kubernets cluster version has a short life cycle, rapid version iteration, and complex technology stack, which leads to huge costs for users to perform version upgrades.
Provide a kubernets cluster upgrade method, including determining the target cluster to be upgraded, performing pre-checking, obtaining required image files from the mirror repository and upgrading. Pre-flights include cluster node problem checks, system component health checks, and interface version compatibility checks.
Through the cluster upgrade pre-check function, we can reduce error occurrence, accelerate upgrade efficiency, reduce operation difficulty and cost, and improve the efficiency and accuracy of the upgrade process.
Smart Images

Figure CN119668651A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a Kubernetes cluster upgrade method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art
[0002] Since the birth of Kubernetes, it has been highly praised by the industry for its excellent design, powerful functions and strong scalability.
[0003] However, there are still some problems in the use of Kubernetes. On the one hand, the version life cycle of Kubernetes is short and the version iteration is rapid. On the other hand, the Kubernetes technology stack is profound and very complex in daily application and maintenance. Therefore, users with a large number of Kubernetes assets need to pay huge costs when performing version upgrades. Summary of the invention
[0004] Based on this, it is necessary to provide a Kubernetes cluster upgrade method, apparatus, computer equipment, computer-readable storage medium and computer program product that can reduce the cost of Kubernetes cluster upgrade in order to solve the above technical problems.
[0005] In a first aspect, the present application provides a kubernetes cluster upgrade method, comprising:
[0006] Determine a target cluster to be upgraded; the upgrade control component and the node problem detection component have been installed in the target cluster;
[0007] Determine the version of the target cluster to be upgraded;
[0008] Based on the version of the target cluster to be upgraded, pre-check the target cluster; the pre-check includes problem checking of cluster nodes, health checking of system components of the target cluster, and compatibility checking of interface versions of the target cluster;
[0009] After the target cluster passes the pre-check, based on the version of the target cluster to be upgraded, an image file required by the version of the target cluster to be upgraded is obtained from an image repository, and the target cluster is upgraded using the image file.
[0010] In one of the embodiments, the pre-checking the target cluster based on the version to be upgraded of the target cluster includes:
[0011] When the node problem detection component detects that there is no abnormal state in the cluster nodes in the target cluster, it is determined that the system components in the target cluster are running normally; wherein the abnormal state includes kernel read and write abnormality, disk read and write abnormality, Kubelet process abnormality and resource consumption abnormality;
[0012] An interface version verification plan for the target cluster is created, and a compatibility check is performed on the interface based on the interface version verification plan.
[0013] In one of the embodiments, based on the version of the target cluster to be upgraded, obtaining an image file required by the version of the target cluster to be upgraded from an image repository, and upgrading the target cluster using the image file includes:
[0014] Obtain the image file required for the version to be upgraded of the target cluster from the image repository;
[0015] Based on the image file, create a control node upgrade plan and a working node upgrade plan;
[0016] Based on the control node upgrade plan, upgrade the control nodes in the target cluster;
[0017] After all the control nodes are upgraded, the working nodes in the target cluster are upgraded based on the working node upgrade plan.
[0018] In one of the embodiments, upgrading the control nodes in the target cluster based on the control node upgrade plan includes:
[0019] When the upgrade control component monitors that the control node upgrade plan has been created, the control node is set to be unschedulable, the control node is dispersed, a corresponding job task is created, and a task pod is pulled up in the control node through the job controller to start the upgrade process of the control node;
[0020] After the upgrade of the control node is completed, the job tasks corresponding to the control nodes that have completed the upgrade process are deleted through the upgrade control component, and the corresponding job tasks are continued to be created through the upgrade control component to instruct the remaining control nodes to complete the upgrade.
[0021] In one embodiment, upgrading the working nodes in the target cluster based on the working node upgrade plan includes:
[0022] After the upgrade control component monitors that the work node upgrade plan has been created, determine the concurrent number of the work nodes, set the concurrent number of work nodes as unschedulable, and disperse the concurrent number of work nodes, create corresponding job tasks based on the concurrent number of work nodes, and pull up task pods in the work nodes through the job tasks to start the upgrade process of the concurrent number of work nodes;
[0023] After the upgrade of the working node is completed, the job tasks corresponding to the working nodes that have completed the upgrade process are deleted through the upgrade control component, and the corresponding job tasks are continued to be created through the upgrade control component to instruct the remaining working nodes to complete the upgrade.
[0024] In one embodiment, the method further comprises:
[0025] After completing the upgrade process of the control node and the working node, annotations are added to the control node upgrade plan and the working node upgrade plan respectively to indicate the upgrade progress of the control node and the working node respectively.
[0026] In a second aspect, the present application also provides a kubernets cluster upgrade device, including:
[0027] A determination module is used to determine a target cluster to be upgraded; the upgrade control component and the node problem detection component are already installed in the target cluster;
[0028] The determination module is further used to determine the version of the target cluster to be upgraded;
[0029] A pre-check module, used to pre-check the target cluster based on the version of the target cluster to be upgraded; the pre-check includes a problem check of cluster nodes, a health check of system components of the target cluster, and a compatibility check of interface versions of the target cluster;
[0030] The upgrade module is used to obtain the image file required by the version of the target cluster to be upgraded from the image repository after the target cluster passes the pre-check, based on the version of the target cluster to be upgraded, and use the image file to upgrade the target cluster.
[0031] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0032] Determine a target cluster to be upgraded; the upgrade control component and the node problem detection component have been installed in the target cluster;
[0033] Determine the version of the target cluster to be upgraded;
[0034] Based on the version of the target cluster to be upgraded, pre-check the target cluster; the pre-check includes problem checking of cluster nodes, health checking of system components of the target cluster, and compatibility checking of interface versions of the target cluster;
[0035] After the target cluster passes the pre-check, based on the version of the target cluster to be upgraded, an image file required by the version of the target cluster to be upgraded is obtained from an image repository, and the target cluster is upgraded using the image file.
[0036] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0037] Determine a target cluster to be upgraded; the upgrade control component and the node problem detection component have been installed in the target cluster;
[0038] Determine the version of the target cluster to be upgraded;
[0039] Based on the version of the target cluster to be upgraded, pre-check the target cluster; the pre-check includes problem checking of cluster nodes, health checking of system components of the target cluster, and compatibility checking of interface versions of the target cluster;
[0040] After the target cluster passes the pre-check, based on the version of the target cluster to be upgraded, an image file required by the version of the target cluster to be upgraded is obtained from an image repository, and the target cluster is upgraded using the image file.
[0041] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0042] Determine a target cluster to be upgraded; the upgrade control component and the node problem detection component have been installed in the target cluster;
[0043] Determine the version of the target cluster to be upgraded;
[0044] Based on the version of the target cluster to be upgraded, pre-check the target cluster; the pre-check includes problem checking of cluster nodes, health checking of system components of the target cluster, and compatibility checking of interface versions of the target cluster;
[0045] After the target cluster passes the pre-check, based on the version of the target cluster to be upgraded, an image file required by the version of the target cluster to be upgraded is obtained from an image repository, and the target cluster is upgraded using the image file.
[0046] The above-mentioned Kubernetes cluster upgrade method, device, computer equipment, computer-readable storage medium and computer program product first determine the target cluster to be upgraded; the upgrade control component and the node problem detection component have been installed in the target cluster; determine the version of the target cluster to be upgraded; based on the version of the target cluster to be upgraded, pre-check the target cluster; after the target cluster passes the pre-check, based on the version of the target cluster to be upgraded, obtain the image file required for the version of the target cluster to be upgraded from the image warehouse, and use the image file to upgrade the target cluster. In this way, through the target cluster upgrade pre-check function, the target cluster is directly upgraded after the pre-check is completed, and the cluster upgrade process is productized. Compared with manual operation upgrades, there is a qualitative leap in efficiency and accuracy, the difficulty of operation is greatly reduced, and the technical requirements for operators are also reduced, which reduces the cost of the entire cluster upgrade process. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0048] Figure 1 An application environment diagram of a kubernetes cluster upgrade method in an embodiment;
[0049] Figure 2 A schematic diagram of a process of upgrading a kubernetes cluster in one embodiment;
[0050] Figure 3 It is a structural block diagram of a kubernetes cluster upgrade device in one embodiment;
[0051] Figure 4 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0053] The kubernetes cluster upgrade method provided in the embodiment of the present application can be applied to Figure 1In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the relevant data of the cluster upgrade that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car devices, projection devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The head-mounted device can be a virtual reality (VR) device, an augmented reality (AR) device, smart glasses, etc. The server 104 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.
[0054] In an exemplary embodiment, Figure 2 As shown, a kubernets cluster upgrade method is provided. The terminal mainly includes a web console component (user operation interface), a kube-upgrade-controller component (upgrade control component), a kube-upgrade-tools component (tool implementation component), a Harbor component, and an NPD component (node problem detection component).
[0055] This method is applied to Figure 1 The terminal 102 in the example is used as an example to illustrate, including the following steps 202 to 208. Among them:
[0056] Step 202, determining a target cluster to be upgraded; an upgrade control component and a node problem detection component have been installed in the target cluster.
[0057] In some embodiments, it is necessary to determine a target cluster to be upgraded, in which an upgrade control component (kube-upgrade-controller component) and a node problem detection component (NPD component) have been installed.
[0058] Among them, the kube-upgrade-controller component is a custom controller, and the NPD component is an official open source component of Kubernetes, which is used for cluster node fault detection.
[0059] Step 204: determine the version of the target cluster to be upgraded.
[0060] In some embodiments, a version of the target cluster to be upgraded is determined.
[0061] Specifically, the version selection of kubernetes needs to follow the version restrictions. The Kubernetes version is expressed as xyz, where x is the major version, y is the minor version, and z is the patch version. The present invention calls xy a major version and xyz a patch version. A major version upgrade can only span one minor version, while a patch version upgrade can span multiple patch versions. For example, upgrading from the current 1.23.3 to 1.25.6 spans 2 minor versions. When upgrading, you must first upgrade from 1.23.3 to 1.24.x, and then from 1.24.x to 1.25.6. Patch versions can be upgraded across patch version numbers, and 1.23.3 supports upgrades to 1.23.10.
[0062] Step 206 , based on the version of the target cluster to be upgraded, pre-check the target cluster; the pre-check includes checking problems of cluster nodes, health of system components of the target cluster, and compatibility of interface versions of the target cluster.
[0063] In some embodiments, according to the version of the target cluster to be upgraded, the cluster nodes of the target cluster are checked to ensure that there are no problems with the cluster nodes; the interface version corresponding to the version to be upgraded is determined to ensure that the interface version of the target cluster is compatible.
[0064] Step 208: after the target cluster passes the pre-check, based on the version of the target cluster to be upgraded, the image file required by the version of the target cluster to be upgraded is obtained from the image repository, and the target cluster is upgraded using the image file.
[0065] In some embodiments, after the target cluster passes the pre-check, the corresponding image file is obtained from the image repository (Harbor) according to the version to be upgraded, and the control nodes and working nodes in the target cluster are upgraded using the image file. After all cluster nodes are upgraded, the upgraded target cluster is obtained.
[0066] In the above Kubernetes cluster upgrade method, the target cluster to be upgraded is determined; the upgrade control component and the node problem detection component have been installed in the target cluster; the version of the target cluster to be upgraded is determined; based on the version of the target cluster to be upgraded, the target cluster is pre-checked; after the target cluster passes the pre-check, based on the version of the target cluster to be upgraded, the image file required for the version of the target cluster to be upgraded is obtained from the image repository, and the target cluster is upgraded according to the image file. In this way, through the target cluster upgrade pre-check function, the target cluster is directly upgraded after the pre-check is completed, and the cluster upgrade process is productized. Compared with manual operation upgrades, there is a qualitative leap in efficiency and accuracy, the difficulty of operation is greatly reduced, the technical requirements for operators are also reduced, and the cost of the entire cluster upgrade process is reduced.
[0067] In an exemplary embodiment, based on the version of the target cluster to be upgraded, the target cluster is pre-checked, including: when a node problem detection component is used to detect that there is no abnormal state in the cluster nodes in the target cluster, determining that the system components in the target cluster are operating normally; wherein the abnormal state includes kernel read and write abnormalities, disk read and write abnormalities, Kubelet process abnormalities and resource consumption abnormalities; creating an interface version verification plan for the target cluster, and performing a compatibility check on the interface based on the interface version verification plan.
[0068] In actual implementation, when the NPD component is installed on the cluster nodes in the target cluster, the web console component queries the status data of each cluster node through the kubernetes api. The web console component confirms that there are no kernel read and write anomalies, disk read and write anomalies, Kubelet process anomalies, and resource consumption anomalies in the cluster nodes in the target cluster.
[0069] The web console component determines that the kube-apiserver (one of the core components, responsible for handling all requests from the API), kube-scheduler (one of the core components, mainly responsible for allocating newly created pods to appropriate nodes), kube-controller-manager (responsible for managing and controlling multiple controllers in the cluster to ensure that they run as expected), coredns (a new DNS server), and cni (CNI provides a set of standards to configure container network connections) network plug-ins are running normally in the namespace of the target cluster.
[0070] Create an api-version-check Plan (interface version check plan). When the kube-upgrade-controller component listens to the creation of the api-version-check Plan, it creates a job named api-version-check-xxxx. This job will pull up a pod (the smallest basic unit of deployment and management in a cluster) on any master node (a special node in a distributed system) to indicate the args parameter (command line parameter) to start the compatibility check.
[0071] Furthermore, after the compatibility check is completed, the check results will be added to the api-version-check plan in the form of annotations. The web console component will query the annotations of the api-version-check plan and display all resource names with interface version compatibility in the form of warnings, guiding users to solve the interface version compatibility issues by uninstalling or upgrading component versions. Among them, typical api compatibility issues include api version name changes and api version abandonment.
[0072] In the above embodiment, by performing a pre-check before upgrading the target cluster, the occurrence of errors in the subsequent cluster upgrade process is reduced, and the efficiency of the target cluster upgrade is accelerated.
[0073] In some exemplary embodiments, image files required for the version to be upgraded of the target cluster are obtained from the image repository; based on the image files, a control node upgrade plan and a working node upgrade plan are created; based on the control node upgrade plan, the control nodes in the target cluster are upgraded; after all control nodes are upgraded, the working nodes in the target cluster are upgraded based on the working node upgrade plan.
[0074] In some embodiments, after the pre-check is passed, the image file required for the version to be upgraded of the target cluster is obtained from the image repository, and based on the obtained image file, an upgradeMaster Plan (control node upgrade plan) and an upgradeWorker Plan (worker node upgrade plan) are created. First, the control nodes are upgraded one by one. After all control nodes are upgraded, the number of work nodes that can be upgraded concurrently is determined, and the work nodes are upgraded.
[0075] In the above embodiment, by upgrading the control nodes and the working nodes in order, the probability of errors occurring during the target cluster upgrade process is reduced, and the time spent on the target cluster upgrade is reduced.
[0076] In an exemplary embodiment, based on the control node upgrade plan, the control nodes in the target cluster are upgraded, including: when the upgrade control component monitors that the control node upgrade plan has been created, the control node is set to be unschedulable, and the control node is dispersed, and a corresponding job task is created. Through the job task, the task pod is pulled up in the control node to start the upgrade process of the control node; after the control node upgrade is completed, the corresponding job task of the control node that has completed the upgrade process is deleted through the upgrade control component, and the corresponding job task continues to be created through the upgrade control component to instruct the remaining control nodes to complete the upgrade.
[0077] In actual implementation, after the kube-upgrade-controller component monitors the creation of the upgradeMaster Plan, it creates a job task named upgradeMaster-xxxx. According to the job task definition, upgradeMaster-xxxx selects any control node to pull up a pod named kube-upgrade-tools-xxx, and passes the "upgrade_master" args parameter to the task pod payload container to start the upgrade of the first control node.
[0078] The kube-upgrade-controller component will instruct the kube-upgrade-tools component to disperse nodes first, set nodes to be unschedulable, and then resume node scheduling after the upgrade action is executed. The kube-upgrade-controller component monitors the status changes of job tasks. When the node upgrade is completed, the kube-upgrade-controller component cleans up the completed job tasks and adds annotations to the upgradeMaster Plan.
[0079] In the above embodiment, by upgrading the control nodes in the target cluster one by one, it is ensured that all control nodes are upgraded without problems, and node draining is performed before the upgrade to safely disperse the control nodes, thereby avoiding negative impact on the business layer.
[0080] In an exemplary embodiment, based on the work node upgrade plan, the work nodes in the target cluster are upgraded, including: after the upgrade control component monitors that the work node upgrade plan has been created, the concurrent number of work nodes is determined, the concurrent number of work nodes is set to be unschedulable, and the concurrent number of work nodes is dispersed, and corresponding job tasks are created based on the concurrent number of work nodes, and through the job tasks, task pods are pulled up in the work nodes to start the upgrade process for the concurrent number of work nodes; after the work node upgrade is completed, the job tasks corresponding to the work nodes that have completed the upgrade process are deleted through the upgrade control component, and the corresponding job tasks continue to be created through the upgrade control component to instruct the remaining work nodes to complete the upgrade.
[0081] In actual implementation, after the kube-upgrade-controller component monitors the creation of the upgradeNode Plan, it creates a job task named upgradeNode-xxxx. The upgradeNode-xxxx can set the concurrency of the job task through the concurrency parameter of the plan. The job task definition selects the corresponding number of working nodes to pull up the kube-upgrade-tools-xxx pod, and passes the "upgrade_node" args parameter to the task pod payload container to start the upgrade of the working node.
[0082] The kube-upgrade-controller component will instruct the kube-upgrade-tools component to disperse the nodes first, set the nodes to be unschedulable, and then resume node scheduling after the upgrade action is executed. The kube-upgrade-controller component monitors the status changes of the job tasks. When the node upgrade is completed, the kube-upgrade-controller component cleans up the completed job tasks and adds annotations to the upgradeNode Plan.
[0083] In the above embodiment, by upgrading a number of concurrent working nodes together, the time required for the target cluster is reduced and the efficiency of the target cluster upgrade is accelerated.
[0084] In some exemplary embodiments, after completing the upgrade process of the control node and the working node, annotations are added to the control node upgrade plan and the working node upgrade plan respectively to indicate the upgrade progress of the control node and the working node respectively.
[0085] In some embodiments, after completing the upgrade process of the control node and the working node, annotations are added to the control node upgrade plan and the working node upgrade plan respectively, and the web control terminal component is returned to feedback the upgrade progress of the control node and the working node respectively.
[0086] In the above embodiment, by returning the work progress of the control node and the working node in the form of annotations, the user can understand the upgrade progress of the target cluster in real time and solve problems in time when they occur.
[0087] In some embodiments, if the upgrade fails, a retry operation will be automatically performed; the kube-upgrade-controller generates a new job task, the job task will re-pull the task pod, execute the upgrade of the cluster node, and the upgrade result will be fed back as an annotation of the upgrade plan.
[0088] To explain the Kubernetes cluster upgrade method in the present application in detail, an embodiment is used for explanation below. By way of example, the present application is described with a Kubernetes cluster upgrade method in a specific Kubernetes cluster upgrade scenario.
[0089] First, determine the target cluster to be upgraded. The upgrade control component (kube-upgrade-controller component) and node problem detection component (NPD component) have been installed in the target cluster.
[0090] Determine the version of the target cluster to be upgraded. Specifically, the version selection of kubernetes needs to follow the version restrictions. The Kubernetes version is expressed as xyz, where x is the major version, y is the minor version, and z is the patch version. The present invention calls xy the major version and xyz the patch version. Major version upgrades can only span one minor version, and patch version upgrades can span multiple patch versions. For example, upgrading from the current 1.23.3 to 1.25.6 version spans 2 minor versions. When upgrading, you must first upgrade from 1.23.3 to 1.24.x, and then upgrade from 1.24.x to 1.25.6. Patch versions can be upgraded across patch version numbers, and 1.23.3 supports upgrades to version 1.23.10.
[0091] When the NPD component is installed on the cluster nodes in the target cluster, the web console component queries the status data of each cluster node through the Kubernetes API. The web console component confirms that there are no kernel read and write exceptions, disk read and write exceptions, Kubelet process exceptions, and resource consumption exceptions in the cluster nodes in the target cluster.
[0092] The web console component determines that the kube-apiserver (one of the core components, responsible for handling all requests from the API), kube-scheduler (one of the core components, mainly responsible for allocating newly created pods to appropriate nodes), kube-controller-manager (responsible for managing and controlling multiple controllers in the cluster to ensure that they run as expected), coredns (a new DNS server), and cni (CNI provides a set of standards to configure container network connections) network plug-ins are running normally in the namespace of the target cluster.
[0093] Create an api-version-check Plan (interface version check plan). When the kube-upgrade-controller component listens to the creation of the api-version-check Plan, it creates a job named api-version-check-xxxx. This job will pull up a pod (the smallest basic unit of deployment and management in a cluster) on any master node (a special node in a distributed system) to indicate the args parameter (command line parameter) to start the compatibility check.
[0094] Furthermore, after the compatibility check is completed, the check results will be added to the api-version-check plan in an annotated form. The web console component will query the annotations of the api-version-check plan and display all resource names with interface version compatibility in a warning format, guiding users to solve the interface version compatibility issues by uninstalling or upgrading component versions. Among them, typical api compatibility issues include api version name changes and api version abandonment.
[0095] After the kube-upgrade-controller component monitors the creation of the upgradeMaster Plan, it creates a job task named upgradeMaster-xxxx. According to the job task definition, upgradeMaster-xxxx selects any control node to pull up a pod named kube-upgrade-tools-xxx, and passes the "upgrade_master" args parameter to the task pod payload container to start the upgrade of the first control node.
[0096] The kube-upgrade-controller component will instruct the kube-upgrade-tools component to disperse nodes first, set nodes to be unschedulable, and then resume node scheduling after the upgrade action is executed. The kube-upgrade-controller component monitors the status changes of job tasks. When the node upgrade is completed, the kube-upgrade-controller component cleans up the completed job tasks and adds annotations to the upgradeMaster Plan.
[0097] After the kube-upgrade-controller component monitors the creation of the upgradeNode Plan, it creates a job task named upgradeNode-xxxx. The upgradeNode-xxxx can set the concurrency of the job task through the concurrency parameter of the plan. The job task definition selects the corresponding number of working nodes to pull up the kube-upgrade-tools-xxx pod, and passes the "upgrade_node" args parameter to the task pod payload container to start the upgrade of the working node.
[0098] The kube-upgrade-controller component will instruct the kube-upgrade-tools component to disperse the nodes first, set the nodes to be unschedulable, and then resume node scheduling after the upgrade action is executed. The kube-upgrade-controller component monitors the status changes of the job tasks. When the node upgrade is completed, the kube-upgrade-controller component cleans up the completed job tasks and adds annotations to the upgradeNode Plan.
[0099] If the upgrade fails, it will be automatically retried; kube-upgrade-controller generates a new job task, which will re-start the task pod and perform the upgrade of the cluster nodes. The upgrade result will be fed back as an annotation of the upgrade plan.
[0100] After completing the upgrade process of the control node and the working node, annotations are added to the control node upgrade plan and the working node upgrade plan respectively, and the web control terminal component is returned to feedback the upgrade progress of the control node and the working node respectively.
[0101] This application commercializes the cluster upgrade process through software engineering, which has a qualitative leap in efficiency and accuracy compared to manual operation upgrades, greatly reduces the difficulty of operation, and also reduces the technical requirements for operators.
[0102] This application has the ability to pre-check cluster upgrades, accurately assess cluster health status, remind users to fix deviations, and reduce the probability of cluster failure; it can automatically check the API compatibility of the cluster's current workload and the Kubernetes version to be upgraded, reducing cluster upgrade risks.
[0103] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0104] Based on the same inventive concept, the embodiment of the present application also provides a Kubernetes cluster upgrade device for implementing the Kubernetes cluster upgrade method involved above. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in one or more Kubernetes cluster upgrade device embodiments provided below can refer to the limitations of the Kubernetes cluster upgrade method above, and will not be repeated here.
[0105] In an exemplary embodiment, Figure 3 As shown, a kubernets cluster upgrade device is provided, including: a determination module 301, a pre-check module 302 and an upgrade module 303, wherein:
[0106] The determination module is used to determine a target cluster to be upgraded; the upgrade control component and the node problem detection component have been installed in the target cluster.
[0107] The determination module is further used to determine the version of the target cluster to be upgraded.
[0108] The pre-check module is used to pre-check the target cluster based on the version of the target cluster to be upgraded; the pre-check includes problem checking of cluster nodes, health checking of system components of the target cluster and compatibility checking of interface versions of the target cluster.
[0109] The upgrade module is used to obtain the image file required by the version of the target cluster to be upgraded from the image repository after the target cluster passes the pre-check, based on the version of the target cluster to be upgraded, and use the image file to upgrade the target cluster.
[0110] In some embodiments, the above-mentioned pre-check module is also used to determine that the system components in the target cluster are operating normally when it is detected through the node problem detection component that there is no abnormal state in the cluster nodes in the target cluster; wherein the abnormal state includes kernel read and write abnormalities, disk read and write abnormalities, Kubelet process abnormalities and resource consumption abnormalities; create an interface version verification plan for the target cluster, and perform a compatibility check on the interface based on the interface version verification plan.
[0111] In some embodiments, the above-mentioned upgrade module is also used to obtain the image files required for the version to be upgraded of the target cluster from the image repository; based on the image files, create a control node upgrade plan and a working node upgrade plan; based on the control node upgrade plan, upgrade the control nodes in the target cluster; after all control nodes are upgraded, upgrade the working nodes in the target cluster based on the working node upgrade plan.
[0112] In some embodiments, the above-mentioned upgrade module is also used to set the control node as unschedulable and disperse the control node when the upgrade control component monitors that the control node upgrade plan has been created, and create a corresponding job task. Through the job task, the task pod is pulled up in the control node to start the upgrade process of the control node; after the upgrade of the control node is completed, the corresponding job task of the control node that has completed the upgrade process is deleted through the upgrade control component, and the corresponding job task continues to be created through the upgrade control component to instruct the remaining control nodes to complete the upgrade.
[0113] In some embodiments, the above-mentioned upgrade module is also used to determine the concurrent number of working nodes after the upgrade control component monitors that the work node upgrade plan has been created, set the concurrent number of working nodes as unschedulable, and disperse the concurrent number of working nodes, create corresponding job tasks based on the concurrent number of working nodes, and pull up the task pod in the working node through the job task to start the upgrade process of the concurrent number of working nodes; after the work node upgrade is completed, delete the corresponding job tasks of the work nodes that have completed the upgrade process through the upgrade control component, and continue to create corresponding job tasks through the upgrade control component to instruct the remaining work nodes to complete the upgrade.
[0114] In some embodiments, the device also includes an annotation module for adding annotations to the control node upgrade plan and the working node upgrade plan respectively after completing the upgrade process of the control node and the working node to indicate the upgrade progress of the control node and the working node respectively.
[0115] Each module in the above-mentioned kubernetes cluster upgrade device can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0116] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Figure 4As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (Near Field Communication, NFC) or other technologies. When the computer program is executed by the processor, a kubernets cluster upgrade method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0117] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0118] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0119] Determine a target cluster to be upgraded; the upgrade control component and the node problem detection component have been installed in the target cluster;
[0120] Determine the version of the target cluster to be upgraded;
[0121] Based on the version of the target cluster to be upgraded, pre-check the target cluster; the pre-check includes problem checking of cluster nodes, health checking of system components of the target cluster, and compatibility checking of interface versions of the target cluster;
[0122] After the target cluster passes the pre-check, based on the version of the target cluster to be upgraded, an image file required by the version of the target cluster to be upgraded is obtained from an image repository, and the target cluster is upgraded using the image file.
[0123] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0124] Determine a target cluster to be upgraded; the upgrade control component and the node problem detection component have been installed in the target cluster;
[0125] Determine the version of the target cluster to be upgraded;
[0126] Based on the version of the target cluster to be upgraded, pre-check the target cluster; the pre-check includes problem checking of cluster nodes, health checking of system components of the target cluster, and compatibility checking of interface versions of the target cluster;
[0127] After the target cluster passes the pre-check, based on the version of the target cluster to be upgraded, an image file required by the version of the target cluster to be upgraded is obtained from an image repository, and the target cluster is upgraded using the image file.
[0128] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0129] Determine a target cluster to be upgraded; the upgrade control component and the node problem detection component have been installed in the target cluster;
[0130] Determine the version of the target cluster to be upgraded;
[0131] Based on the version of the target cluster to be upgraded, pre-check the target cluster; the pre-check includes problem checking of cluster nodes, health checking of system components of the target cluster, and compatibility checking of interface versions of the target cluster;
[0132] After the target cluster passes the pre-check, based on the version of the target cluster to be upgraded, an image file required by the version of the target cluster to be upgraded is obtained from an image repository, and the target cluster is upgraded using the image file.
[0133] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0134] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0135] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0136] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the present application. It should be noted that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A kubernets cluster upgrade method, characterized in that: The method comprises: Determine a target cluster to be upgraded; the upgrade control component and the node problem detection component have been installed in the target cluster; Determine the version of the target cluster to be upgraded; Based on the version of the target cluster to be upgraded, pre-check the target cluster; the pre-check includes problem checking of cluster nodes, health checking of system components of the target cluster, and compatibility checking of interface versions of the target cluster; After the target cluster passes the pre-check, based on the version of the target cluster to be upgraded, an image file required by the version of the target cluster to be upgraded is obtained from an image repository, and the target cluster is upgraded using the image file.
2. The method according to claim 1, characterized in that The pre-checking the target cluster based on the version to be upgraded of the target cluster includes: When the node problem detection component detects that there is no abnormal state in the cluster nodes in the target cluster, it is determined that the system components in the target cluster are running normally; wherein the abnormal state includes kernel read and write abnormality, disk read and write abnormality, Kubelet process abnormality and resource consumption abnormality; An interface version verification plan for the target cluster is created, and a compatibility check is performed on the interface based on the interface version verification plan.
3. The method according to claim 1, characterized in that The step of acquiring, based on the version of the target cluster to be upgraded, an image file required by the version of the target cluster to be upgraded from an image repository, and upgrading the target cluster using the image file includes: Obtain the image file required for the version to be upgraded of the target cluster from the image repository; Based on the image file, create a control node upgrade plan and a working node upgrade plan; Based on the control node upgrade plan, upgrade the control nodes in the target cluster; After all the control nodes are upgraded, the working nodes in the target cluster are upgraded based on the working node upgrade plan.
4. The method according to claim 3, characterized in that The step of upgrading the control nodes in the target cluster based on the control node upgrade plan includes: When the upgrade control component monitors that the control node upgrade plan has been created, the control node is set to be unschedulable, the control node is dispersed, a corresponding job task is created, and a task pod is pulled up in the control node through the job task to start the upgrade process of the control node; After the upgrade of the control node is completed, the job tasks corresponding to the control nodes that have completed the upgrade process are deleted through the upgrade control component, and the corresponding job tasks are continued to be created through the upgrade control component to instruct the remaining control nodes to complete the upgrade.
5. The method according to claim 3, characterized in that: The step of upgrading the working nodes in the target cluster based on the working node upgrade plan includes: After the upgrade control component monitors that the work node upgrade plan has been created, determine the concurrent number of the work nodes, set the concurrent number of work nodes as unschedulable, and disperse the concurrent number of work nodes, create corresponding job tasks based on the concurrent number of work nodes, and pull up task pods in the work nodes through the job tasks to start the upgrade process of the concurrent number of work nodes; After the work node upgrade is completed, the upgrade control component deletes the corresponding job tasks of the work nodes that have completed the upgrade process, and the upgrade control component continues to create the corresponding job controller to instruct the remaining work nodes to complete the upgrade.
6. The method according to any one of claims 3 to 5, characterized in that The method further comprises: After completing the upgrade process of the control node and the working node, annotations are added to the control node upgrade plan and the working node upgrade plan respectively to indicate the upgrade progress of the control node and the working node respectively.
7. A kubernets cluster upgrade device, characterized in that: The device comprises: A determination module is used to determine a target cluster to be upgraded; the upgrade control component and the node problem detection component are already installed in the target cluster; The determination module is further used to determine the version of the target cluster to be upgraded; A pre-check module, used to pre-check the target cluster based on the version of the target cluster to be upgraded; the pre-check includes a problem check of cluster nodes, a health check of system components of the target cluster, and a compatibility check of interface versions of the target cluster; The upgrade module is used to obtain the image file required by the version of the target cluster to be upgraded from the image repository after the target cluster passes the pre-check, based on the version of the target cluster to be upgraded, and use the image file to upgrade the target cluster.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Chip firmware upgrading method used in server cluster
CN121704878A