A two-node Kubernetes cluster system and its deployment method

By using high-performance, high-availability data translation components and relational databases in Kubernetes clusters with two nodes, the high availability and cost problems in traditional clusters are solved, and high availability and automatic switching are achieved in two nodes, suitable for resource-limited resources environment.

CN118708409BActive Publication Date: 2024-12-31MINGYANG SHICHUANG (BEIJING) TECH CO LTD +1
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411182486.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-27
Publication Date
2024-12-31
Estimated Expiration
2044-08-27

AI Technical Summary

Technical Problem

Traditional Kubernetes cluster deployment requires at least three nodes to achieve high availability, but this increases server costs, and when two nodes fail, etcd cannot guarantee high availability of data, causing APIServer to be unable to query data.

Method used

Kubernetes cluster system with two nodes, each node is equipped with high-performance, high-available data translation components and relational databases (such as MySQL or PostgreSQL), which ensures data consistency and availability through watch mechanisms and transaction mechanisms, and utilizes high-performance, high-availability The data translation component maps the Kubernetes data model to a relational database, implements communication between apiserver and the database, and automatically switches when a node fails.

Benefits of technology

It realizes high availability in two node clusters, saves server costs, adaptive handover, resource savings, simplifies management and monitoring, is suitable for small workloads and rapid deployment, and reduces hardware and resource requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118708409B_ABST
    Figure CN118708409B_ABST
Patent Text Reader

Abstract

The present invention discloses a two-node Kubernetes cluster system and a deployment method thereof, wherein the Kubernetes cluster system is composed of a Master1 node and a Master2 node, wherein the Master1 node and the Master2 node are respectively provided with a high-performance and high-availability data translation component and a relational database. The present invention only requires two nodes to meet the high availability requirements of Kubernetes, and when one node fails, the other node can also manage the Kubernetes cluster, and saves server costs relative to a three-node cluster environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Kubernetes, and in particular to a two-node Kubernetes cluster system and a deployment method thereof. Background Art

[0002] In order to achieve high availability requirements, a kubernetes cluster needs to deploy at least three master nodes. On the one hand, all three master nodes can manage the cluster. In terms of data storage, kubernetes relies on etcd. As one of the core components of kubernetes, etcd mainly acts as a key-value repository. etcd requires at least three nodes to ensure data consistency and high availability.

[0003] The traditional kubernetes cluster cannot achieve high availability in a two-node environment, and high availability requires at least three nodes. When deploying a cluster with more than three nodes, the cost of the required servers increases. In addition, when two nodes fail in the three-node high availability environment, it does not comply with the high availability mechanism of etcd. When the kubernetes apiserver queries the pod status, it only queries the latest data in etcd. However, if two nodes are lost among the three nodes, etcd cannot reach a majority database and is unavailable, so the kubenetes apiserver cannot query the data. Summary of the invention

[0004] To this end, the technical problem to be solved by the present invention is to provide a two-node Kubernetes cluster system and a deployment method thereof, which only requires two nodes to meet the high availability requirements of Kubernetes. When one node fails, the other node can also manage the Kubernetes cluster, and saves server costs compared to a three-node cluster environment.

[0005] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0006] A two-node Kubernetes cluster system, the Kubernetes cluster system consists of a Master1 node and a Master2 node, wherein the Master1 node and the Master2 node are respectively provided with a high-performance and high-availability data translation component and a relational database, the relational database being a relational database suitable for the Master1 node and the Master2 node; the apiserver in the Master1 node is respectively communicated and connected with the relational database in the Master1 node and the relational database in the Master2 node through the high-performance and high-availability data translation component in the Master1 node, the relational database in the Master1 node is respectively communicated and connected with the high-performance and high-availability data translation component in the Master2 node and the relational database in the Master2 node, the high-performance and high-availability data translation component in the Master2 node is respectively communicated and connected with the apiserver in the Master2 node and the relational database in the Master2 node, the apiserver in the Master2 node is communicated and connected with the apiserver in the Master1 node, wherein the high-performance and high-availability data translation component in the Master1 node monitors the apiserver in the Master1 node by using a watch mechanism, and the high-performance and high-availability data translation component in the Master2 node monitors the apiserver in the Master2 node by using a watch mechanism.

[0007] In the above two-node Kubernetes cluster system, the relational database is one or both of MySQL and PostgreSQL.

[0008] The above two-node Kubernetes cluster system, the high-performance and high-availability data translation component has a built-in adapter, which is used to provide an interface for implementing basic operations on the relational database, and the basic operations include inserting, updating, deleting and querying.

[0009] In the above two-node Kubernetes cluster system, the high-performance and high-availability data translation component uses the database transaction mechanism to manage data operations in the relational database.

[0010] In the above two-node Kubernetes cluster system, the adapter converts the request of the high-performance and high-availability data translation component into specific database operations, and then executes the corresponding database operations and returns the execution results.

[0011] In the above two-node Kubernetes cluster system, the high-performance and high-availability data translation component pre-stores the definition of the interface for performing basic operations on the relational database, and the adapter provides an interface for performing basic operations on the relational database according to the definition of the interface for performing basic operations on the relational database.

[0012] In the above two-node Kubernetes cluster system, the high-performance and high-availability data translation component realizes the communication between the relational database and the Master1 node and the Master2 node by mapping the Kubernetes data model to the tables and records of the relational database.

[0013] The above two-node Kubernetes cluster system deployment method includes the following steps:

[0014] S1) A high-performance and high-availability data translation component and a relational database are respectively set in the Master1 node and the Master2 node, and the apiserver in the Master1 node is respectively connected to the relational database in the Master1 node and the relational database in the Master2 node through the high-performance and high-availability data translation component in the Master1 node, and the relational database in the Master1 node is respectively connected to the high-performance and high-availability data translation component in the Master2 node and the relational database in the Master2 node, and the high-performance and high-availability data translation component in the Master2 node is respectively connected to the apiserver in the Master2 node and the relational database in the Master2 node;

[0015] S2) Configure database connections for the relational databases in the Master1 and Master2 nodes.

[0016] In the above two-node Kubernetes cluster system deployment method, the database connection configuration includes the database type and the connection string. The connection string includes the relational database host name, database port number, database name, and database user credentials.

[0017] In the above two-node Kubernetes cluster system deployment method, in step S1), before the apiserver in the Master1 node is respectively connected to the relational database in the Master1 node and the relational database in the Master2 node through the high-performance and high-availability data translation component in the Master1 node, and before the high-performance and high-availability data translation component in the Master2 node is connected to the apiserver in the Master2 node, the definition of the interface for performing basic operations on the relational database and the preset adapter are pre-stored in the high-performance and high-availability data translation component in the Master1 node and the high-performance and high-availability data translation component in the Master2 node, and the interface for performing basic operations on the relational database is implemented according to the definition of the interface for performing basic operations on the relational database.

[0018] The technical solution of the present invention achieves the following beneficial technical effects:

[0019] 1. The present invention first solves the problem of high availability of two-node clusters, and secondly saves the number of servers to build and saves costs. Although a two-node cluster cannot provide high availability like a three-node or more node cluster, it can still provide some redundancy. If one node fails, the other node can still continue to provide services.

[0020] 2. Adaptive adjustment: It can adapt to two-node and multi-node high-availability clusters at the same time, and can adaptively switch as needed.

[0021] 3. Resource saving: A two-node cluster requires less hardware and resources than a cluster with more nodes. This is especially useful for development and testing environments with limited resources.

[0022] 4. Simplified management: Managing a two-node cluster is relatively simple, especially in terms of maintenance and monitoring. Operations and maintenance personnel can more easily manage smaller clusters and reduce the complexity of configuration and maintenance.

[0023] 5. Suitable for small workloads: For small applications or microservices, especially those in large-scale production environments that do not require high concurrency and high availability, a two-node cluster is sufficient.

[0024] 6. Rapid deployment and testing: During the development and testing phases, a two-node cluster can be quickly deployed and adjusted, helping the development team to verify and test new features and changes more quickly.

[0025] 7. Cost-effectiveness: Less hardware and resource requirements mean lower costs, especially for projects or businesses with limited budgets. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 This is a working principle diagram of the two-node Kubernetes cluster system in the present invention. DETAILED DESCRIPTION

[0027] The present invention is further described below with reference to examples.

[0028] like Figure 1 As shown, the two-node Kubernetes cluster system in the present invention is composed of a Master1 node and a Master2 node, wherein the Master1 node and the Master2 node are respectively provided with a high-performance and high-availability data translation component and a relational database, and the relational database is a relational database suitable for the Master1 node and the Master2 node; the apiserver in the Master1 node is respectively communicated and connected with the relational database in the Master1 node and the relational database in the Master2 node through the high-performance and high-availability data translation component in the Master1 node, and the relational database in the Master1 node is respectively communicated and connected with the high-performance and high-availability data translation component in the Master2 node and the relational database in the Master2 node, and the high-performance and high-availability data translation component in the Master2 node is respectively communicated and connected with the apiserver in the Master2 node and the relational database in the Master2 node, and the apiserver in the Master2 node is communicated and connected with the apiserver in the Master1 node, wherein the high-performance and high-availability data translation component in the Master1 node monitors the apiserver in the Master1 node by using a watch mechanism and a long polling method, and the high-performance and high-availability data translation component in the Master2 node monitors the apiserver in the Master2 node by using a watch mechanism and a long polling method. Among them, the high-performance and highly available data translation component is named MY_HHADTT in this embodiment, specifically: High-performance, highly available data translation tools. The high-performance and highly available data translation component realizes communication between the relational database and the Master1 node and the Master2 node by mapping the Kubernetes data model (such as ConfigMaps, Pods, Services, etc.) to the tables and records of the relational database.

[0029] Specifically, users can choose a relational database suitable for the Master1 node and the Master2 node according to their needs. For example, users can choose MySQL, PostgreSQL, or other similar relational databases.

[0030] In order to simplify the connection structure and realize the connection between the high-performance and high-availability data translation component and the relational database at the same time, in the present invention, an adapter is built into the high-performance and high-availability data translation component, and the adapter is used to provide an interface for implementing basic operations on the relational database, and the basic operations include inserting, updating, deleting and querying. Specifically, the adapter converts the request of the high-performance and high-availability data translation component into a specific database operation, and then executes the corresponding database operation and returns the execution result. Furthermore, the high-performance and high-availability data translation component pre-stores the definition of the interface for performing basic operations on the relational database, and the adapter provides an interface for implementing basic operations on the relational database according to the definition of the interface for performing basic operations on the relational database.

[0031] Among the basic operations, the insert operation is to insert new Kubernetes object data into the table of the relational database; the update operation is to update the existing records in the relational database to reflect the status changes of the Kubernetes object; the delete operation is to delete the specified record from the table of the relational database, which usually corresponds to the deletion operation of the Kubernetes object; the query operation is to execute SQL queries to obtain data, such as retrieving information about all Pods.

[0032] In order to ensure data consistency and reliability, the high-performance and high-availability data translation component uses the transaction mechanism of the relational database to manage data operations. The transaction mechanism of the relational database is as follows:

[0033] Transaction start: Before performing a series of operations, MY_HHADTT starts a database transaction.

[0034] Operation execution: Perform operations such as insert, update, and delete within a transaction.

[0035] Transaction commit: If all operations are successful, MY_HHADTT commits the transaction and persists all changes to the database.

[0036] Transaction rollback: If an error occurs, MY_HHADTT will roll back the transaction, undoing all changes to maintain data consistency.

[0037] At the same time, when interacting with a relational database, the high-performance and high-availability data translation component also needs to handle various error situations, such as connection errors, such as network problems or unavailability of the relational database, query errors, such as SQL syntax errors or data constraint conflicts, and retry mechanisms. Specifically, the high-performance and high-availability data translation component can implement a retry mechanism to deal with temporary errors or network problems.

[0038] In the present invention, the two-node Kubernetes cluster system deployment party implements deployment through the following steps:

[0039] S1) A high-performance and high-availability data translation component and a relational database are respectively set in the Master1 node and the Master2 node, and the apiserver in the Master1 node is respectively connected to the relational database in the Master1 node and the relational database in the Master2 node through the high-performance and high-availability data translation component in the Master1 node, and the relational database in the Master1 node is respectively connected to the high-performance and high-availability data translation component in the Master2 node and the relational database in the Master2 node, and the high-performance and high-availability data translation component in the Master2 node is respectively connected to the apiserver in the Master2 node and the relational database in the Master2 node;

[0040] S2) Configure database connections for the relational databases in the Master1 and Master2 nodes.

[0041] The purpose of configuring the relational database connection information is to facilitate interaction with the target database. The database connection configuration includes the database type and the connection string. The connection string includes the relational database host name, database port number, database name, and database user credentials. The configuration of the database type is to specify the database type to be used, such as SQLite, MySQL, and PostgreSQL. The configuration of the connection string is to configure the string including the database host name, port number, database name, user credentials, and other information. For example, for MySQL, the connection string may be mysql: / / user:password@host:port / dbname, where "mysql: / / " means connecting to the database using the MySQL protocol, user is the user name used to connect to the database, password is the password corresponding to the user name, host is the host or IP address where the MySQL database is located (if the database is running locally, localhost is usually used), port is the port number that the MySQL database listens on, and dbname is the name of the database to be connected. At the same time, other configurations can be performed according to specific circumstances. For example, according to different database backends, additional configurations may be required, such as the size of the connection pool, timeout, etc.

[0042] In step S1), before the apiserver in the Master1 node is respectively connected to the relational database in the Master1 node and the relational database in the Master2 node through the high-performance and high-availability data translation component in the Master1 node and the high-performance and high-availability data translation component in the Master2 node is connected to the apiserver in the Master2 node, the definition of the interface for performing basic operations on the relational database and the preset adapter are pre-stored in the high-performance and high-availability data translation component in the Master1 node and the high-performance and high-availability data translation component in the Master2 node, and the interface for performing basic operations on the relational database is implemented according to the definition of the interface for performing basic operations on the relational database.

[0043] When the two-node Kubernetes cluster system is deployed, the high-performance and high-availability data translation component maps the Kubernetes data model (such as ConfigMaps, Pods, Services, etc.) to tables and records in the relational database. This mapping usually includes the following aspects:

[0044] Table structure: Each Kubernetes object type corresponds to a table in the database. For example, ConfigMap may correspond to a table configmaps, and Pods may correspond to a table pods.

[0045] Field mapping: The fields of a Kubernetes object are mapped to columns in a database table. For example, the name, namespace, and status of a Pod are mapped to the corresponding columns in the pods table.

[0046] In the present invention, a high-performance and high-availability data translation component is used plus the relational database available in the other two nodes to replace the existing etcd database, and the high-performance and high-availability data translation component is used to translate the k / v operations of etcd into operations on the data in the relational database, and the interface of the high-performance and high-availability data translation component is exposed to the apiserver in the Kubernetes cluster system. In this way, the read and write operations of the etcd database that appear to be the Kubernetes cluster system can actually be converted into operations on other relational databases, and the high availability of the visual environment database can be achieved in a Kubernetes cluster system with only two nodes, thereby solving the problem that the dual Master cannot be highly available in a Kubernetes cluster system consisting of only two nodes.

[0047] Compared with the method of storing Kubernetes data in a relational database through a high-performance and high-availability translation component in the present invention, the traditional method is kine, whose biggest disadvantage is that it cannot provide strong consistency guarantee, and the complex etcd specific function efficient notification mechanism cannot be fully supported in kine, and kine cannot achieve adaptive two-node and multi-node clusters. The present invention provides a watch mechanism to monitor data and ensure data consistency. When a node is offline, data is only transmitted to the online node, and after the offline node is restored, the original online node will sense the offline node online and synchronize data, thereby solving the huge defects of data consistency and function limitations faced by the kine method, and also provides adaptive high-availability cluster switching.

[0048] Obviously, the above embodiments are merely examples for the purpose of clear explanation, and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived therefrom are still within the scope of protection of the claims of this patent application.

Claims

1. A two-node Kubernetes cluster system, the Kubernetes cluster system consisting of a Master1 node and a Master2 node, characterized in that: A data translation component and a relational database are respectively provided in the Master1 node and the Master2 node, and the relational database is a relational database suitable for the Master1 node and the Master2 node; the apiserver in the Master1 node is respectively communicated and connected with the relational database in the Master1 node and the relational database in the Master2 node through the data translation component in the Master1 node, the relational database in the Master1 node is respectively communicated and connected with the data translation component in the Master2 node and the relational database in the Master2 node, the data translation component in the Master2 node is respectively communicated and connected with the apiserver in the Master2 node and the relational database in the Master2 node, the apiserver in the Master2 node is communicated and connected with the apiserver in the Master1 node, wherein the data translation component in the Master1 node monitors the apiserver in the Master1 node by using the watch mechanism, and the data translation component in the Master2 node monitors the apiserver in the Master2 node by using the watch mechanism.

2. The two-node Kubernetes cluster system according to claim 1, characterized in that: The relational database is one or both of MySQL and PostgreSQL.

3. The two-node Kubernetes cluster system according to claim 1, characterized in that: The data translation component has a built-in adapter, which is used to provide an interface for implementing basic operations on a relational database, wherein the basic operations include inserting, updating, deleting, and querying.

4. The two-node Kubernetes cluster system according to claim 3, characterized in that: The data translation component uses the database transaction mechanism to manage data operations within the relational database.

5. The two-node Kubernetes cluster system according to claim 4, characterized in that: The adapter converts the request of the data translation component into specific database operations, then executes the corresponding database operations and returns the execution results.

6. The two-node Kubernetes cluster system according to claim 4, characterized in that: The data translation component pre-stores the definition of the interface for performing basic operations on the relational database, and the adapter provides the interface for performing basic operations on the relational database according to the definition of the interface for performing basic operations on the relational database.

7. The two-node Kubernetes cluster system according to claim 1, characterized in that: The data translation component enables communication between the relational database and the Master1 and Master2 nodes by mapping the Kubernetes data model to the tables and records of the relational database.

8. The two-node Kubernetes cluster system deployment method of claim 1, characterized in that: The steps include: S1) Set up a data translation component and a relational database in the Master1 node and the Master2 node respectively, connect the apiserver in the Master1 node to the relational database in the Master1 node and the relational database in the Master2 node respectively through the data translation component in the Master1 node, connect the relational database in the Master1 node to the data translation component in the Master2 node and the relational database in the Master2 node respectively, and connect the data translation component in the Master2 node to the apiserver in the Master2 node and the relational database in the Master2 node respectively; S2) Configure database connections for the relational databases in the Master1 and Master2 nodes.

9. The two-node Kubernetes cluster system deployment method according to claim 8, characterized in that: The database connection configuration includes the database type and the connection string. The connection string includes the relational database host name, database port number, database name, and database user credentials.

10. The two-node Kubernetes cluster system deployment method according to claim 8, characterized in that: In step S1), before the apiserver in the Master1 node is respectively connected to the relational database in the Master1 node and the relational database in the Master2 node through the data translation component in the Master1 node and the data translation component in the Master2 node is connected to the apiserver in the Master2 node, the definition of the interface for performing basic operations on the relational database and the preset adapter are pre-stored in the data translation component in the Master1 node and the data translation component in the Master2 node, and the interface for performing basic operations on the relational database is implemented according to the definition of the interface for performing basic operations on the relational database.

Citation Information

Patent Citations

  • Data storage system and method

    CN116644119A

  • LDAP high-availability system based on Kubernetes environment and implementation method

    CN117675835A

  • Shared file system-based Kubernetes cloud platform SAN (Storage Area Network) storage use method and system

    CN117827101A

  • Kubernetes-based data processing method, system, device, equipment, medium and product

    CN118193796A

  • Data processing method, cluster storage system, computing device, medium and system

    CN118535639A