A method, system, device and storage medium for improving k8s cluster stability
By monitoring the host environment in the k8s cluster, backing up etcd data regularly, and decoding the etcd cluster when the cluster size is large, the problem of k8s cluster instability caused by etcd failure is solved, and higher etcd and k8s cluster stability is achieved. , ensuring the normal operation of the business.
Patent Information
- Application Number
- CN202110868349.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-30
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2041-07-30
AI Technical Summary
In the k8s cluster, etcd failure causes the service pod to fail to start, causing the entire k8s environment to crash and affect the stability of the cluster.
By monitoring the host's operating environment, if the number of restarts or IO read and write speed is not up to standard, use the etcd API to back up the etcd cluster data regularly; if the etcd fails, use the backup data to restore; when the cluster size is large, the etcd cluster will be clustered Deployment from the k8s cloud platform service.
It improves the stability of etcd, prevents data loss caused by etcd failure, avoids resource seizure between etcd and cloud platform services, enhances the overall stability of the k8s cluster, and ensures the normal operation of the business.
Smart Images

Figure CN113672341B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud platform technology, and more specifically to a method, system, device and storage medium for improving the stability of a k8s cluster. Background Art
[0002] Kubernetes, or K8s for short, is an abbreviation formed by replacing the eight characters "ubernete" with "8". It is an open source containerized application management framework for multiple hosts in a cloud platform. The goal of Kubernetes is to make the deployment of containerized applications simple and powerful. Kubernetes provides a mechanism for application deployment, planning, updating, and maintenance.
[0003] In the Kubernetes cluster, etcd plays a key role in the service discovery and configuration center functions of the Kubernetes cluster. etcd is an open source project initiated by the CoreOS team in June 2016. Its goal is to build a highly available distributed key-value database. etcd uses the raft protocol as a consistency algorithm. etcd is implemented based on the Go language. etcd is widely used in service discovery. Service discovery solves one of the most common problems in distributed systems: how can processes or services in the same distributed cluster find each other and establish connections.
[0004] Currently, in a cluster environment, if etcd fails and cannot provide services normally, the service pod in the entire k8s environment cannot be started, causing the business to crash and making the entire k8s cluster basically unusable. In daily life, the cloud platform may also be unusable due to etcd failures during operation. It can be seen that the stability of etcd has a direct impact on the stability of the k8s cluster.
[0005] Therefore, how to improve the stability of etcd and support the stable operation of the k8s platform is an urgent problem to be solved. Summary of the invention
[0006] In view of the above problems, the purpose of the present invention is to provide a method, system, device and storage medium for improving the stability of the k8s cluster. By improving the stability of etcd, the stability of the k8s cluster service can be improved to a certain extent, thereby better supporting the business platform.
[0007] To achieve the above object, the present invention is implemented through the following technical solutions: A method for improving the stability of a k8s cluster, comprising:
[0008] Monitor the operating environment of the host machine. If the number of restarts of the host machine within the preset time interval exceeds the preset threshold or the IO read and write speed is lower than the preset threshold, back up the etcd cluster data in a timed synchronization manner through the application interface of the distributed key-value storage system (etcd API);
[0009] If the current etcd fails, use the backed-up cluster data to restore the data status;
[0010] If the number of nodes in the current cluster is greater than the preset threshold, the k8s platform service will be separated from the etcd operating environment.
[0011] Further, backing up the cluster data of the distributed key-value storage system in a timed synchronization manner through the application interface of the distributed key-value storage system includes:
[0012] Create storage space in the etcd running environment;
[0013] Create a scheduled synchronization task in the etcd running environment and set the synchronization time for the scheduled synchronization task;
[0014] Through the etcd cluster API interface, start the scheduled task and continuously synchronize the etcd cluster data to the storage space according to the set synchronization time.
[0015] Furthermore, if the current distributed key-value storage system fails, restoring the data state using the backed-up cluster data includes:
[0016] Monitor the operating status of the distributed key-value storage system;
[0017] If the current distributed key-value storage system fails, specify the data recovery time, collect the cluster data of the corresponding time in the storage space, and use the collected cluster data to overwrite the cluster data of the current distributed key-value storage system.
[0018] Furthermore, a scheduled synchronization task is configured on each node of the etcd cluster, and a corresponding storage space is specified for each scheduled synchronization task.
[0019] Further, the creation of storage space in the operating environment of the distributed key-value storage system is specifically as follows:
[0020] Create a fixed data backup space in the etcd running environment or connect to an external storage space as the storage space for performing scheduled synchronization tasks.
[0021] Further, the separation of the k8s platform service from the etcd operating environment includes:
[0022] Deploy the etcd cluster on a separate host node;
[0023] The host node and the k8s cloud platform are deployed in the same cluster.
[0024] Correspondingly, the present invention also discloses a system for improving the stability of a k8s cluster, comprising:
[0025] The environment monitoring unit is used to monitor the number of host machine restarts and IO read and write speeds within a preset time interval; the data backup unit is used to back up the cluster data of the distributed key-value storage system in a timed synchronization manner through the etcd API;
[0026] A recovery unit, used to recover data status using backed-up cluster data;
[0027] Cluster monitoring unit, used to monitor the number of nodes in the cluster;
[0028] The environment separation unit is used to separate the k8s platform service from the etcd operating environment.
[0029] Further, the data backup unit includes:
[0030] The backup space creation module is used to create storage space in the etcd running environment;
[0031] The task creation module is used to create scheduled synchronization tasks in the etcd running environment and set the synchronization time for the scheduled synchronization tasks;
[0032] The task execution module is used to start the scheduled synchronization task through the etcd API and synchronize the etcd cluster data to the storage space according to the set synchronization time;
[0033] Specify a module to configure scheduled tasks on each node of the etcd cluster and specify the corresponding storage space for each scheduled task.
[0034] Furthermore, the environment separation unit is specifically used to: deploy the etcd cluster on a separate host node; and deploy the host node and the k8s cloud platform in the same cluster.
[0035] Accordingly, the present invention discloses a device for improving the stability of a k8s cluster, comprising:
[0036] Storage, used to store programs that improve the stability of the k8s cluster;
[0037] A processor is used to implement the method steps for improving the stability of the k8s cluster as described in any of the above items when executing the program for improving the stability of the k8s cluster.
[0038] Accordingly, the present invention discloses a readable storage medium, on which is stored a program for improving the stability of a k8s cluster. When the program for improving the stability of a k8s cluster is executed by a processor, the method steps for improving the stability of a k8s cluster as described in any one of the above items are implemented.
[0039] Compared with the prior art, the present invention has the following beneficial effects:
[0040] 1. When the stability of the host environment is poor, the present invention uses the etcd API to perform data backup and separate the etcd data from its own data storage mechanism. If etcd fails and needs to be restored, it can be restored to the data state of the specified date normally. This prevents the situation where etcd's own data cannot be restored due to problems, and effectively ensures the integrity of the data.
[0041] 2. The present invention aims at increasing instability when etcd and k8s cloud platform services are deployed in the same host environment when the cluster scale is large. The method of separating the etcd cluster from the k8s cloud platform operating environment is adopted. On the one hand, it avoids resource preemption between etcd and cloud platform services, improves the stability of etcd itself and the stability of k8s services; on the other hand, it realizes the decoupling of the operating environment. When the operating node of the cloud platform service is abnormal, it will not have any impact on the etcd cluster service.
[0042] 3. The present invention improves the stability of the etcd cluster from the perspective of the important role of etcd stability in the k8s cloud platform, so that the high stability foundation of the etcd cluster can better support the normal operation of the k8s platform, thereby ensuring the normal operation of the business.
[0043] It can be seen that compared with the prior art, the present invention has outstanding substantive features and significant progress, and the beneficial effects of its implementation are also obvious. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0045] Attached Figure 1 is a flow chart of the method of the present invention;
[0046] Attached Figure 2 It is a system structure diagram of the present invention.
[0047] In the figure, 1 is the environment monitoring unit; 2 is the data backup unit; 3 is the recovery unit; 4 is the cluster monitoring unit; 5 is the environment separation unit; 6 is the backup space creation module; 7 is the task creation module; 8 is the task execution module; and 9 is the designated module. DETAILED DESCRIPTION
[0048] The core of the present invention is to provide a method for improving the stability of the k8s cluster. Currently, in a cluster environment, if etcd fails to provide services normally, the service pod cannot be started in the entire k8s environment, causing the business to crash, making the entire k8s cluster basically unusable. In daily life, the cloud platform may also be unusable due to etctd failure during operation. It can be seen that the stability of etcd has a direct impact on the stability of the k8s cluster.
[0049] The method for improving the stability of the k8s cluster provided by the present invention, first, for the poor stability of the host environment, data backup is performed through the etcd API, and etcd data is separated from its own data storage mechanism. If the etcd failure needs to be restored, it can be restored to the data state of the specified date normally. Preventing the situation where etcd's own data cannot be restored due to problems, effectively ensures the integrity of the data. Secondly, for the large cluster scale, etcd and k8s cloud platform services are deployed in the same host environment to increase instability. The present invention adopts a method of separating the etcd cluster from the k8s cloud platform operating environment, on the one hand, avoiding the resource preemption of etcd and cloud platform services, and improving the stability of etcd itself and the stability of k8s services; on the other hand, the decoupling of the operating environment is realized, and when the operating node of the cloud platform service is abnormal, it will not have any impact on the etcd cluster service. It can be seen that the present invention improves the stability of the etcd cluster from the perspective of the important role of etcd stability in the k8s cloud platform, so that the high stability of the etcd cluster can better support the normal operation of the k8s platform, thereby ensuring the normal operation of the business.
[0050] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0051] Embodiment 1:
[0052] like Figure 1 As shown, this embodiment provides a method for improving the stability of a k8s cluster, comprising the following steps:
[0053] S1: Monitor the operating environment of the host machine. If the number of restarts of the host machine within the preset time interval exceeds the preset threshold or the IO read and write speed is lower than the preset threshold, back up the etcd cluster data in a scheduled synchronization manner through the etcd API.
[0054] In this step, if the number of restarts of the host machine within the preset time interval exceeds the preset number threshold or the IO read and write speed is lower than the preset number threshold, it can be regarded that the operating environment stability of the host machine is poor. When the operating environment stability of the host machine is poor, system restarts or large IO delays often occur. The mechanism of the etcd cluster itself is to conduct leader elections through the raft election mechanism. If a communication failure will cause the leader member's heartbeat to not be obtained by other members, a new round of elections will be conducted. After the election is completed, the follower members will synchronize data from the leader member. If before the election, the follower member causes data synchronization abnormalities due to network or disk IO reasons. When the election is completed, the new leader member happens to be the member with abnormal data before the election. At this time, problems will occur when synchronizing data from this member to other members. When data recovery is performed, this abnormal data cannot be started normally for etcd.
[0055] Specifically: Two subdirectories snap and wal are generated in the default working directory of etcd. Since all data modifications in etcd must be written to the WAL file before submission, using WAL to store data enables etcd to have fast fault recovery and data rollback. etcd creates snapshots to prevent too many WAL files. The snap subdirectory is used to store the snapshot data status of etcd. The wal subdirectory is used to record the entire process of data changes. However, network or disk I / O abnormalities that cause backup data abnormalities will cause etcd data to be unable to be read normally. If the etcd cluster member data is synchronized again, the synchronization status of the entire cluster will have abnormal data. Once the etcd cluster crashes, the abnormal data cannot be read and restored when the cluster is restored. Therefore, in order to ensure data integrity, this step directly backs up the etcd cluster data in a timed synchronization manner through the etcd API.
[0056] Among them, backing up etcd cluster data in a timed synchronization manner through etcd API specifically includes:
[0057] First, create a storage space in the etcd running environment, that is, create a fixed backup data space in the etcd running environment or connect to an external storage space as the storage space for executing scheduled synchronization tasks. Then, back up the etcd cluster data in a scheduled synchronization manner. Finally, start the scheduled task through the etcd cluster API interface to continuously synchronize the etcd cluster data to the storage space according to the set synchronization time.
[0058] S2: If the current etcd fails, use the backed-up cluster data to restore the data status.
[0059] Specifically: First, monitor the running status of the distributed key-value storage system. If the current distributed key-value storage system fails, specify the data recovery time, collect the cluster data of the corresponding time in the storage space, and use the collected cluster data to overwrite the current etcd cluster data.
[0060] Usually, the data status can be checked through the backup data of a cluster node. In order to prevent the backup data abnormality caused by the single node API abnormality, this step configures the scheduled synchronization task in each node of the etcd cluster and specifies the corresponding storage space for each scheduled synchronization task, so that the data of multiple nodes can be backed up simultaneously.
[0061] S3: If the number of nodes in the current cluster is greater than the preset threshold, separate the k8s platform service from the etcd operating environment.
[0062] Currently, etcd, as a distributed key-value database, plays a key role in supporting the business of the k8s cloud platform. When the cluster size is small and the number of businesses is small, the etcd cluster and the cloud platform service are usually deployed in the same host environment. However, this deployment method has the following two defects:
[0063] 1. If the cloud platform services increase or the machine performance is poor, the host machine will crash, and the etcd cluster will be affected. Cluster node failure will cause etcd to fail to start, which will in turn make the entire k8s platform unusable.
[0064] 2. As the scale of the cluster continues to expand, the larger the scale of the k8s cluster, the more data resources need to be synchronized, resulting in a substantial increase in the amount of data that etcd needs to process and synchronize. The increase in data processing volume will cause etcd to be unstable and the failure rate will increase significantly.
[0065] Therefore, in order to improve the stability of the etcd cluster and better support the business stability of the k8s cloud platform, this step first detects the scale of the current cluster. If the number of nodes in the current cluster is greater than the preset number threshold, it means that the current cluster scale is large. At this time, separate the etcd cluster running nodes from the service running nodes, and use a separate cluster to deploy the etcd service. Specifically: deploy the etcd cluster on a separate host node, and deploy the host node and the k8s cloud platform in the same cluster. Among them, in order to meet the implementation of the raft election mechanism, the number of nodes selected for deploying the etcd cluster is an odd number.
[0066] This embodiment provides a method for improving the stability of the k8s cluster, which improves the stability of the etcd cluster from the perspective of the important role of etcd stability in the k8s cloud platform, so that the etcd cluster can better support the normal operation of the k8s platform on the basis of high stability, thereby ensuring the normal operation of the business.
[0067] Embodiment 2:
[0068] Based on Example 1, Figure 2 As shown, the present invention also discloses a system for improving the stability of a k8s cluster, comprising: an environment monitoring unit 1, a data backup unit 2, a recovery unit 3, a cluster monitoring unit 4 and an environment separation unit 5.
[0069] The environment monitoring unit 1 is used to monitor the number of restarts and IO read / write speed of the host machine within a preset time interval. If the number of restarts of the host machine within a preset time interval exceeds a preset number threshold or the IO read / write speed is lower than a preset number threshold, it can be regarded that the operating environment stability of the host machine is poor. Then the data backup unit 2 is triggered to start.
[0070] Data backup unit 2 is used to back up the cluster data of the distributed key-value storage system in a timed synchronization manner through the etcd API. Data backup unit 2 specifically includes:
[0071] The backup space creation module 6 is used to create storage space in the etcd operating environment.
[0072] The task creation module 7 is used to create a scheduled synchronization task in the etcd operating environment and set the synchronization time for the scheduled synchronization task.
[0073] The task execution module 8 is used to start the scheduled synchronization task through the etcd API and synchronize the etcd cluster data to the storage space according to the set synchronization time.
[0074] Specify module 9 to configure scheduled tasks on each node of the etcd cluster and specify the corresponding storage space for each scheduled task.
[0075] The recovery unit 3 is used to recover the data status by using the backed-up cluster data. The recovery unit 3 is specifically used to: monitor the running status of the distributed key-value storage system; if the current distributed key-value storage system fails, specify the data recovery time, collect the cluster data of the corresponding time in the storage space, and use the collected cluster data to overwrite the cluster data of the current distributed key-value storage system.
[0076] The cluster monitoring unit 4 is used to monitor the number of nodes in the cluster. If the number of nodes in the current cluster is greater than a preset number threshold, it means that the current cluster size is large, and the environment separation unit 5 is triggered to start.
[0077] The environment separation unit 5 is used to separate the k8s platform service from the etcd operating environment. The environment separation unit 5 is specifically used to: deploy the etcd cluster on a separate host node, and set the host node under the cluster to which the k8s cloud platform belongs.
[0078] This embodiment provides a system for improving the stability of the k8s cluster. First, data is backed up through the etcd API to separate etcd data from its own data storage mechanism. If the etcd failure needs to be restored, it can be restored to the data state of the specified date normally. Preventing the situation where etcd's own data cannot be restored due to problems, effectively ensures the integrity of the data. Secondly, a method of separating the etcd cluster from the k8s cloud platform operating environment is adopted. On the one hand, it avoids the resource preemption of etcd and cloud platform services, improves the stability of etcd itself and the stability of k8s services; on the other hand, it realizes the decoupling of the operating environment. When the operating node of the cloud platform service is abnormal, it will not have any impact on the etcd cluster service. Therefore, by improving the stability of etcd, the stability of the k8s cluster service is improved to a certain extent, thereby better supporting the business platform.
[0079] Embodiment three:
[0080] This embodiment discloses a device for improving the stability of a k8s cluster, including a processor and a memory; wherein the processor implements the following steps when executing a program for improving the stability of a k8s cluster stored in the memory:
[0081] 1. Monitor the operating environment of the host machine. If the number of host machine restarts within the preset time interval exceeds the preset threshold or the IO read and write speed is lower than the preset threshold, back up the etcd cluster data in a scheduled synchronization manner through the etcd API.
[0082] 2. If the current etcd fails, use the backed-up cluster data to restore the data status.
[0083] 3. If the number of nodes in the current cluster is greater than the preset threshold, separate the k8s platform service from the etcd operating environment.
[0084] Furthermore, the device for improving the stability of the k8s cluster in this embodiment may also include:
[0085] The input interface is used to obtain the program for improving the stability of the k8s cluster imported from the outside, and save the obtained program for improving the stability of the k8s cluster to the memory. It can also be used to obtain various instructions and parameters transmitted by external terminal devices, and transmit them to the processor so that the processor can use the above various instructions and parameters to carry out corresponding processing. In this embodiment, the input interface can specifically include but is not limited to a USB interface, a serial interface, a voice input interface, a fingerprint input interface, a hard disk reading interface, etc.
[0086] The output interface is used to output various data generated by the processor to the terminal device connected thereto, so that other terminal devices connected to the output interface can obtain various data generated by the processor. In this embodiment, the output interface may specifically include but is not limited to a USB interface, a serial interface, etc.
[0087] The communication unit is used to establish a remote communication connection between the device for improving the stability of the k8s cluster and the external server, so that the device for improving the stability of the k8s cluster can mount the image file to the external server. In this embodiment, the communication unit may specifically include but is not limited to a remote communication unit based on wireless communication technology or wired communication technology.
[0088] The keyboard is used to obtain various parameter data or instructions input by the user by tapping the keycaps in real time.
[0089] The display is used to display the relevant information of the server power supply line short circuit locating process in real time.
[0090] The mouse can be used to assist users in inputting data and simplify user operations.
[0091] This embodiment provides a device for improving the stability of the k8s cluster. First, data is backed up through the etcd API to separate the etcd data from its own data storage mechanism. This effectively prevents the situation where etcd's own data cannot be restored due to problems, thereby ensuring the integrity of the data. Secondly, a method is adopted to separate the etcd cluster from the k8s cloud platform operating environment, thereby improving the stability of etcd itself and the stability of the k8s service.
[0092] Embodiment 4:
[0093] This embodiment also discloses a readable storage medium, which includes random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, register, hard disk, removable hard disk, CD-ROM or any other form of storage medium known in the technical field. The readable storage medium stores a program for improving the stability of the k8s cluster, and the program for improving the stability of the k8s cluster is executed by the processor to implement the following steps:
[0094] 1. Monitor the operating environment of the host machine. If the number of host machine restarts within the preset time interval exceeds the preset threshold or the IO read and write speed is lower than the preset threshold, back up the etcd cluster data in a scheduled synchronization manner through the etcd API.
[0095] 2. If the current etcd fails, use the backed-up cluster data to restore the data status.
[0096] 3. If the number of nodes in the current cluster is greater than the preset threshold, separate the k8s platform service from the etcd operating environment.
[0097] This embodiment provides a readable storage medium. First, data backup is performed through the etcd API to separate etcd data from its own data storage mechanism. If etcd fails and needs to be restored, it can be restored to the data state of the specified date normally. This prevents the situation where etcd's own data cannot be restored due to problems, and effectively ensures the integrity of the data. Secondly, a method of separating the etcd cluster from the k8s cloud platform operating environment is adopted. On the one hand, it avoids the resource preemption of etcd and the cloud platform service, and improves the stability of etcd itself and the stability of the k8s service; on the other hand, it realizes the decoupling of the operating environment. When the running node of the cloud platform service is abnormal, it will not have any impact on the etcd cluster service.
[0098] To sum up, the present invention improves the stability of the etcd cluster from the perspective of the important role of etcd stability in the k8s cloud platform, so that the etcd cluster can better support the normal operation of the k8s platform on the basis of high stability, thereby ensuring the normal operation of the business.
[0099] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. As for the method disclosed in the embodiment, since it corresponds to the system disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0100] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0101] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, systems and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of systems or units, which can be electrical, mechanical or other forms.
[0102] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0103] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, or each module may exist physically separately, or two or more modules may be integrated into one unit.
[0104] Similarly, each processing unit in each embodiment of the present invention may be integrated into one functional module, or each processing unit may exist physically, or two or more processing units may be integrated into one functional module.
[0105] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0106] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0107] The above is a detailed introduction to the method, system, device and readable storage medium for improving the stability of the k8s cluster provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, the present invention can also be improved and modified in several ways, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.
Claims
1. A method for improving the stability of a k8s cluster, characterized in that: include: Monitor the operating environment of the host machine. If the number of restarts of the host machine within a preset time interval exceeds a preset threshold or the IO read and write speed is lower than a preset threshold, back up the cluster data of the distributed key-value storage system in a timed synchronization manner through the application interface of the distributed key-value storage system. If the number of restarts of the host machine within a preset time interval exceeds a preset number threshold or the IO read / write speed is lower than a preset number threshold, it can be considered that the operating environment stability of the host machine is poor; If the current distributed key-value storage system fails, use the backed-up cluster data to restore the data status; When the distributed key-value storage system fails and needs to be restored, it can be restored to the data status on the specified date normally; If the number of nodes in the current cluster is greater than the preset number threshold, separate the k8s platform service from the operating environment of the distributed key-value storage system; The backing up of the cluster data of the distributed key-value storage system in a timed synchronization manner through the application interface of the distributed key-value storage system includes: Create storage space in the running environment of the distributed key-value storage system; Create a scheduled synchronization task in the running environment of the distributed key-value storage system and set the synchronization time for the scheduled synchronization task; Start the scheduled synchronization task through the cluster application interface of the distributed key-value storage system, and synchronize the cluster data of the distributed key-value storage system to the storage space according to the set synchronization time; A scheduled synchronization task is configured in each node of the distributed key-value storage system cluster, and a corresponding storage space is specified for each scheduled synchronization task; to prevent a single-node cluster application interface abnormality from causing backup data abnormality; The separation of the k8s platform service from the distributed key-value storage system operating environment includes: Deploy the cluster of distributed key-value storage system on a separate host node; Deploy the host node and the k8s cloud platform in the same cluster; Detect the scale of the current cluster. If the number of nodes in the current cluster is greater than the preset number threshold, it means that the current cluster scale is large. At this time, separate the distributed key-value storage system cluster running nodes from the service running nodes, and use a separate cluster to deploy the distributed key-value storage system service. The number of nodes selected for deploying a distributed key-value storage system cluster is an odd number.
2. The method for improving the stability of a k8s cluster according to claim 1, characterized in that: If the current distributed key-value storage system fails, restoring the data state using the backed-up cluster data includes: Monitor the operating status of the distributed key-value storage system; If the current distributed key-value storage system fails, specify the data recovery time, collect the cluster data of the corresponding time in the storage space, and use the collected cluster data to overwrite the cluster data of the current distributed key-value storage system.
3. The method for improving the stability of a k8s cluster according to claim 1, characterized in that: The specific steps of creating a storage space in the operating environment of the distributed key-value storage system are as follows: Create a fixed backup data space or access an external storage space in the operating environment of the distributed key-value storage system as the storage space for performing scheduled synchronization tasks.
4. A system for executing the method according to any one of claims 1 to 3, characterized in that: include: An environment monitoring unit, used to monitor the number of host machine restarts and IO read and write speeds within a preset time interval; A data backup unit, used to back up the cluster data of the distributed key-value storage system in a timed synchronization manner through an application interface of the distributed key-value storage system; If the number of restarts of the host machine within a preset time interval exceeds a preset number threshold or the IO read / write speed is lower than a preset number threshold, it can be considered that the operating environment stability of the host machine is poor; A recovery unit, used to recover data status using backed-up cluster data; When the distributed key-value storage system fails and needs to be restored, it can be restored to the data status on the specified date normally; A cluster monitoring unit, used to monitor the number of nodes in the cluster; The environment separation unit is used to separate the operating environment of the k8s platform service from the distributed key-value storage system; A specified module is used to configure a scheduled synchronization task for each node of the distributed key-value storage system cluster and specify a corresponding storage space for each scheduled synchronization task; The data backup unit comprises: A backup space creation module, used to create storage space in the running environment of the distributed key-value storage system; A task creation module is used to create a scheduled synchronization task in the operating environment of the distributed key-value storage system and set a synchronization time for the scheduled synchronization task; a task execution module is used to start the scheduled synchronization task through the cluster application interface of the distributed key-value storage system, and synchronize the cluster data of the distributed key-value storage system to the storage space according to the set synchronization time; a scheduled synchronization task is configured in each node of the distributed key-value storage system cluster, and a corresponding storage space is specified for each scheduled synchronization task; and a single-node cluster application interface abnormality is prevented from causing backup data abnormality; The environment separation unit is also used to deploy the cluster of the distributed key-value storage system on a separate host node; and deploy the host node and the k8s cloud platform in the same cluster; The system also includes: detecting the scale of the current cluster. If the number of nodes in the current cluster is greater than a preset number threshold, it means that the current cluster scale is large. At this time, the distributed key-value storage system cluster operation nodes and the service operation nodes are separated, and a separate cluster is used to deploy the distributed key-value storage system service; the number of nodes selected for deploying the distributed key-value storage system cluster is an odd number.
5. A device for improving the stability of a k8s cluster, characterized in that: include: Storage, used to store programs that improve the stability of the k8s cluster; A processor is used to implement the method steps for improving the stability of a k8s cluster as described in any one of claims 1 to 3 when executing the program for improving the stability of a k8s cluster.
6. A readable storage medium, characterized in that: The readable storage medium stores a program for improving the stability of the k8s cluster. When the program for improving the stability of the k8s cluster is executed by the processor, the method steps for improving the stability of the k8s cluster as described in any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Anomaly processing method and device, mobile terminal and storage medium
CN109753411A
Method for realizing large-scale container cluster
CN111443993A
Backup data recovery method and device, electronic equipment and storage medium
CN112214351A