Software deployment method and device based on Kubernetes platform
By deploying MySQL cluster on the Kubernetes platform and combining it with MHA software to generate master node and slave node labels, the problem of high availability of databases on the platform is solved, efficient database management and operation and maintenance are realized, and the needs of containerization and serviceization are met.
Patent Information
- Application Number
- CN202111502544.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-09
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2041-12-09
AI Technical Summary
The Kubernetes platform lacks an effective database high-availability solution, which leads to fragmentation and complexity in the migration and management process of database clusters, making it difficult to achieve high availability and consistency.
Deploy MySQL cluster on the Kubernetes platform and combine it with MHA software to achieve high availability of the database by generating master node and slave node labels, replacing VIP maintenance and expanding the high availability database management capabilities of Kubernetes.
It achieves high availability and rapid deployment of database clusters, reduces operation and maintenance costs and error rates, improves resource utilization and operation and maintenance efficiency, and conforms to the containerization and service-oriented trends.
Smart Images

Figure CN114138754B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud computing technology, and in particular to a software deployment method, device, electronic device, and computer-readable storage medium based on a Kubernetes platform. Background Art
[0002] Before software development, it is usually necessary to prepare various operating environments, IDEs (integrated development environments), auxiliary tools, etc. The delivery process of a usable software usually includes two parts: development and maintenance. In actual operation, it is difficult to ensure that the software in the software development and testing and operation and maintenance stages can run in exactly the same environment. Container technology solves the above problems very well. It effectively divides the resources of a single operating system into isolated groups, which can better balance conflicting resource usage requirements between isolated groups. Container technology has become a very popular technology that can shield infrastructure inconsistencies. The container orchestration framework is the core of the system to connect the entire software life cycle, including development, testing, deployment, and operation and maintenance. As a Paas (platform-as-a-service) platform that provides standardized operation and maintenance processes, it can provide one-click deployment, dynamic scheduling, scaling, and a variety of daemon mechanisms for applications.
[0003] In recent years, Kubernetes has gradually unified the container orchestration field, and many companies have begun to try to use k8s as the infrastructure to build application systems. However, although the application has been migrated, the application data is too fragmented and difficult to manage uniformly. At the same time, it is necessary to maintain two systems and build a communication network. Therefore, migrating the database has become an urgent idea for many companies.
[0004] MHA (master high availability) is currently a relatively mature solution for MySQL high availability. During the MySQL failover process, MHA can automatically complete the database failover operation within 0 to 30 seconds, and during the failover process, MHA can ensure data consistency to the greatest extent to achieve true high availability. However, the traditional MySQL MHA installation method is more troublesome throughout the installation process, and may be affected by the uncontrollable network. Under normal circumstances, the DBA (Database Administrator) generally completes the deployment in about 2 to 3 hours, and many tasks need to be repeated on at least three server nodes. Chinese patent application CN202010616118.2 discloses a system and method for ensuring the high availability and consistency of the MHA cluster, which mainly avoids the inability of the MySQL cluster to switch normally due to the simultaneous failure of the MHA and the MySQL cluster, and ensures the availability of user applications. The technical solution adopted is: Redis cluster is used to provide the ability to publish locks and configure global notifications; when performing disaster recovery switching, the MHA module registers an exclusive lock in the Redis cluster to prevent other MHA instances from performing disaster recovery switching operations at the same time, and pushes the post-switching configuration to the Redis cluster and releases the lock after the switch is completed; the MHA module is based on the MHA native tool, and implements the locking and release of exclusive locks and configuration push functions in the two custom scripts secondary_check_script and ip_failove r_script; the configuration manager ensures that the local configuration of the MHA node is consistent with other MHAs at all times. The system formed by the above scheme is dependent on external systems. For example, the use of Redis increases the error probability of the system, and it is not a cloud-native solution. Chinese patent application CN202010805534.7 discloses a one-click deployment method and system of mysql-mha cluster based on ansiable, including the following steps: installing mysql database on the server; creating an account in the main library and configuring the main node; the step of configuring the database to connect to the main library is used to deploy and configure the mha basic node; deploy and configure the MHA management node; node deployment monitoring. However, the deployment of Ansible for this non-cloud native solution is procedural and takes a long time to run. Each link must be run once, which can easily lead to dependency failures.
[0005] In summary, database containerization is imperative, but the Kubernetes platform does not have a particularly good design solution for high-availability solutions for database clusters. Based on this, it is necessary to improve the existing Kubernetes-based database. Summary of the invention
[0006] The purpose of this application is to achieve the adaptation of the Kubernetes platform and the database high availability solution to enable full containerization of enterprise applications.
[0007] The purpose of this application is achieved by the following technical solutions:
[0008] In a first aspect, the present application provides a software deployment method based on a Kubernetes platform, including: deploying a MySQL cluster on the Kubernetes platform, the Kubernetes platform including a master node and a slave node; providing MHA software, and establishing a connection between the Kubernetes platform and the MHA software, the MHA software including a management node and multiple database nodes; responding to a user's request to access a database, selecting a database master node from the multiple database nodes; generating a master node label and a slave node label of the Kubernetes platform according to information of the database master node and the management node; and controlling the MHA software to send a business request to the Kubernetes platform according to the master node label and the slave node label of the Kubernetes platform. The beneficial effect of this technical solution is that the database cluster is deployed to the Kubernetes environment, and the MySQL cluster is deployed on the Kubernetes platform. A "master-slave replication" MySQL cluster is formed in the Kubernetes environment. This structure can match the "one master and two slaves" of the MHA software; in addition, considering that the MHA software requires VIP to operate, and the IP of Kubernetes is dynamic, this application selects the database master node from multiple database nodes, and generates the master node label and slave node label of the Kubernetes platform according to the information of the database master node and the management node. The above labeling method replaces the maintenance of VIP, and the MHA software is adapted to the database of the Kubernetes environment, which expands the ability of Kubernetes to manage stateful and highly available databases. Furthermore, the embodiments of the present application can meet the requirements of standardized rapid delivery, the elastic demand of resources, and containerization, and are in line with the trend of containerization and service-oriented.
[0009] In some optional embodiments, the master node and the slave node are determined in the following manner: the master node is selected through the write server of the Kubernetes platform to expose an access interface to the business application to read and write data; and the remaining nodes excluding the master node are selected as slave nodes through the read server of the Kubernetes platform.
[0010] In some optional embodiments, on the Kubernetes platform, a MySQL cluster is deployed by statefulset; a semi-synchronous mode is adopted to form a structure including at least one master node and two slave nodes.
[0011] In some optional embodiments, the Kubernetes platform also includes an Operator, the Operator includes a label controller and an MHA controller, the MHA controller includes an MHA software manager and an application configurator, the MHA software manager is used to create the management node, and the application configurator is used to implement CRD status maintenance.
[0012] In some optional embodiments, generating the master node label and the slave node label of the Kubernetes platform according to the information of the database master node and the management node includes:
[0013] Use the tag controller to connect to the management node, read the log printed by the management node, and obtain the master node information of the management node in real time;
[0014] Connect to the database node configured in the configuration file of the MHA software manager through the MySQL client, enter the database to detect the master node information of the database;
[0015] In response to the master node information of the management node and the master node information of the database being consistent, a master node label and / or a slave node label is generated for the node of the Kubernetes platform.
[0016] In some optional embodiments, the MHA software includes a management node and three database nodes, and the management node and the database node respectively include sshd_sidecar.
[0017] In some optional embodiments, the method further includes: detecting whether a node of the database is down; in response to the node of the database being down and after the node of the database is restored, restoring the management mode of the MHA software.
[0018] In a second aspect, the present application provides a software deployment device based on the Kubernetes platform, including:
[0019] A Kubernetes platform module, including a Kubernetes platform, wherein the Kubernetes platform includes a master node and a slave node, and is used to deploy a MySQL cluster on the Kubernetes platform;
[0020] MHA software module, used to provide MHA software and establish a connection between the Kubernetes platform and the MHA software, wherein the MHA software includes a management node and multiple database nodes;
[0021] A label marking module is used to respond to a user's request to access the database and select a database master node from the multiple database nodes; generate a master node label and a slave node label of the Kubernetes platform according to the information of the database master node and the management node;
[0022] The service sending module is used to control the MHA software to send service requests to the Kubernetes platform according to the master node label and slave node label of the Kubernetes platform. The beneficial effect of this technical solution is that the existing mature database high availability solution MHA software is transplanted to the Kubernetes platform, which contributes to the comprehensive containerization of enterprise applications, improving resource utilization, and operation and maintenance efficiency. The container deployment of the MySQL cluster database saves a lot of manual operation processes of the database administrator (Database Administrator, DBA), improves efficiency, reduces error rate, and saves operation and maintenance costs. The containerization of the MHA software also solidifies the cumbersome operations and reduces the skill requirements of the DBA a lot. The overall cloud nativeization of stateful and stateless applications makes full use of the ecosystem functions of Kubernetes such as resource scheduling, service discovery, and load balancing, and improves the level of enterprise IT governance.
[0023] In a third aspect, the present application provides an electronic device, comprising a memory, a processor, and a hardware module for performing tasks, wherein the memory stores a computer program, and the processor implements the steps of any of the above methods when executing the computer program.
[0024] In a fourth aspect, the present application provides a computer-readable storage medium storing a computer program, which implements the steps of any of the above methods when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The present application is further described below in conjunction with the accompanying drawings and embodiments.
[0026] Figure 1 This is a flowchart of a software deployment method based on the Kubernetes platform according to an embodiment of the present application;
[0027] Figure 2 A schematic diagram of a flow chart of a method for determining a master node and a slave node according to an embodiment of the present application;
[0028] Figure 3A schematic diagram of a method for generating a master node label and a slave node label according to an embodiment of the present application;
[0029] Figure 4 This is a flowchart of a software deployment method based on the Kubernetes platform according to another embodiment of the present application;
[0030] Figure 5 This is a software system structure diagram based on the Kubernetes platform according to an embodiment of the present application;
[0031] Figure 6 This is a structural diagram of a software deployment device based on a Kubernetes platform according to an embodiment of the present application;
[0032] Figure 7 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application;
[0033] Figure 8 It is a structural diagram of a program product for implementing a selection method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0034] Below, the present application is further described in conjunction with the accompanying drawings and specific implementation methods. It should be noted that, under the premise of no conflict, the various embodiments or technical features described below can be arbitrarily combined to form a new embodiment.
[0035] Kubernetes is a declarative resource orchestration framework that supports automated deployment, large-scale scalability, and containerized application management. When deploying an application in a production environment, you usually need to deploy multiple instances of the application to load balance application requests. In Kubernetes, you can create multiple containers, each of which runs an application instance, and then use the built-in load balancing strategy to manage, discover, and access this group of application instances. These details do not require the operation and maintenance personnel to perform complex manual configuration and processing. However, Kubernetes has its own unique usage mode. For example, the IP address of the container is not fixed and will change after switching. Traditional software and system solutions need to be transformed to a platform architecture such as cloud native. Database containerization is imperative, but the Kubernetes platform does not have a particularly good ready-made design for high-availability solutions for database clusters.
[0036] This application proposes a software deployment method based on the Kubernetes platform, which can transplant the existing mature database high availability solution MHA (Master High Availability) to the Kubernetes platform, contributing to the comprehensive containerization of enterprise applications, improving resource utilization, and operation and maintenance efficiency.
[0037] See also Figure 1 The embodiment of the present application provides a software deployment method based on the Kubernetes platform, which can realize the migration of traditional software and system solutions to the cloud native platform architecture based on Kubernetes. The software deployment method based on the Kubernetes platform includes steps S101 to S105.
[0038] Step S101, deploying a MySQL cluster on a Kubernetes platform, where the Kubernetes platform includes a master node and a slave node.
[0039] Step S102, provide MHA software, and establish a connection between the Kubernetes platform and the MHA software, the MHA software includes a management node and multiple database nodes.
[0040] Step S103, in response to the user's request to access the database, a database master node is selected from multiple database nodes.
[0041] Step S104, generating a master node label and a slave node label of the Kubernetes platform according to the information of the database master node and the management node.
[0042] Step S105, according to the master node label and the slave node label of the Kubernetes platform, control the MHA software to send a service request to the Kubernetes platform.
[0043] In the embodiments of the present application, a MySQL cluster is deployed on the Kubernetes platform, and a MySQL cluster with "master-slave replication" is formed in the Kubernetes environment. This structure can match the "one master and two slaves" of the MHA software. Additionally, considering that MHA requires a VIP to operate, while the IPs in Kubernetes are dynamic, the present application selects a database master node from multiple database nodes and generates master node labels and slave node labels for the Kubernetes platform based on the information of the database master node and the management node. The above method of tagging replaces the maintenance of the VIP, making it possible for MHA to run in the Kubernetes environment and expanding the ability of Kubernetes to manage stateful highly available databases. Further, the embodiments of the present application can meet the requirements of standardized and rapid delivery, the elastic demand for resources, containerization, and conform to the trend of containerization and serviceization.
[0044] In one embodiment, on the Kubernetes platform, the MySQL cluster is deployed by means of a statefulset. Exemplarily, the statefulset controller starts one Pod at a time in the order of ordinal index, and the statefulset controller waits until each Pod reports readiness before starting the next Pod. The statefulset controller assigns a unique and stable name to each Pod, in the form of <statefulset name>-<ordinal index>. The Pods are finally named mysql-0, mysql-1, and mysql-2. Further, considering that the statefulset requires a stable access name, a headless also needs to be created. The statefulset can be responsible for the stable network identification of the Pod through the headless. When accessing within the cluster, $(pod name) and $(DNS domain name of the service to which it belongs) need to be used, where the service to which it belongs is set by the serviceName field of the statefulset.
[0045] The Kubernetes platform may include a master node and slave nodes. In this embodiment, the Kubernetes platform adopts a semi-synchronous mode to form a structure including 1 master node (Master) and multiple slave nodes (Slave) by deploying a MySQL cluster.
[0046] As Figure 2 shown, the master node and slave nodes are determined in the following manner:
[0047] Step S201, select the master node through the write server of the Kubernetes platform to expose the access interface for the business application to read and write data;
[0048] Step S202, through the read server of the Kubernetes platform, select the remaining nodes excluding the master node as slave nodes. In the embodiment of the present application, the nodes involved can be horizontally expanded, and all write operations can only be performed on the master node; read operations can be performed on all nodes.
[0049] In one embodiment, when MySQL statefulset generates a database cluster for the first time, mysql-0 is the master node. The statefulset controller of the Kubernetes platform ensures that after mysql-0 is generated, mysql-1 and mysql-2 are generated again through the script logic defined in the statefulsetyaml file.
[0050] For example, statefulset yaml defines init container and application container, and each container adds initialization script. The init container can include init-mysql container and clone-mysql container, where: the init-mysql container can determine whether it is a master library (master database) or a slave library (slave database) according to the pod ordinal index, thereby generating the corresponding database configuration file; before the Slave Pod is started, the clone-mysql container copies the database data from the Master or other Slave Pod to its own directory, that is, if the ordinal index is not equal to 0, it uses ncat and xtrabackup to back up the complete data from the previous container and apply it to the current pod.
[0051] For example, the application pod also includes containers and xtrabackup containers. For containers, if this container already has backup data, it is directly started as a slave mysql container, a regular database instance is deployed, and storage volumes and health checks are set. For xtrabackup container, after the initialization of the MySQL node is completed, the second task of this sidecar container is to start a data transmission service, expose a transmission port with ncat, and prepare backup data for the next pod in sequence.
[0052] The MHA software may include a management node and multiple database nodes, and the management node and the database node each include an sshd sidecar. In one embodiment, the MHA software is a containerized MHA, and the MHA manager (management) node and the MHA node (database) node basic images are made respectively, and the PERL dependency package is installed. The MHA node node has the MySQL database installed, and the communication between the MHA manager node and the MHA node node is through the SSH protocol. Optionally, the image system needs to make an SSH password-free account, and for simplicity, a unified pair of public and private keys can be used.
[0053] Exemplarily, the MHA software switching logic may include:
[0054] First, the MHA manager node is verified when it starts, and the replication configuration is verified and the current master is identified according to the configuration file; if an exception occurs, the MHA configuration is checked and the current master is confirmed;
[0055] Next, the new master is determined based on the above judgment process, and writing to the current master is blocked;
[0056] Then, wait for all slave servers to complete synchronization with the existing master, grant write permissions to the new master, and switch slave libraries in parallel.
[0057] Understandably, after the MHA software switch, you need to manually delete the app1.failover.complete file before you can restart the MHA manager. And once the switch occurs, the management process will exit, and you need to manually re-add the failed database to the MHA environment.
[0058] The Kubernetes platform also includes an Operator, which includes an MHA-controller and a label-controller, wherein: the MHA-controller includes an MHA software manager and an application configurator, the MHA software manager is used to create the management node, and the application configurator is used to implement CRD status maintenance. In one embodiment, the MHA software manager (MHA-manager) is responsible for the creation of the MHA-manager pod; the real-time generation of the configuration file app.conf, the configmap, and status maintenance. The label-controller can generate master node labels and slave node labels.
[0059] In one embodiment, the logic of the MHA-controller includes:
[0060] First, the Operator must define the Kubernetes custom object MHAManagerInstance struct. The structure contains two fields: spec and status. The spec internally references the pod definition and configmap definition. The pod mainly defines the YAML information required for the containerized MHA-manager instance, such as the containerized image, CPU, and memory specifications.
[0061] Secondly, configmap needs to generate the server segment definition required by the MHA-manager instance configuration file based on the name and number of replicas of MySQL statefulset, especially the hostname. In traditional environments, the hostname is configured with the internal IP address of the IaaS infrastructure, while in the Kubernetes environment, the pod IP uses the clusterIP, which is dynamically generated with scheduling. As long as the pod is rescheduled for some reason, a new IP may be generated. Therefore, the configmap can only configure the unique internal DNS name assigned to the pod by the Kubernetes controller.
[0062] In addition, there is CRD status maintenance. When the database goes down, label-controller detects the abnormality, notifies MHA-controller, and updates CRD MHAManagerInstance status to down.
[0063] In one embodiment, label-controller can implement the labeling process: the key point of label-controller design is to transform the original VIP attached to the master in the IaaS environment into a MySQL role in the Kubernetes environment, which is attached to the master pod in the form of a label. The specific method is to connect the MHA-manager pod by label-controller, read the log printed by the MHA-manager, and obtain the MySQL master node information in real time. To ensure security, connect to the database node configured in the configuration file of the MHA-manager through the MySQL client, enter the database to check the master-slave information again. If the two pieces of information are consistent, call the Kubernetes controller object, label the corresponding pod with label_M (master node label), and label the remaining nodes with label_S (slave node labels).
[0064] In this embodiment, the two controllers included in the Operator can generate master node labels and slave node labels based on the information of the database master node and management node:
[0065] Step S301, using the tag controller to connect to the management node, reading the log printed by the management node, and obtaining the master node information of the management node in real time;
[0066] Step S302, connecting to the database node configured in the configuration file of the MHA software manager through the MySQL client, entering the database to detect the master node information of the database;
[0067] Step S303, in response to the master node information of the management node and the master node information of the database being consistent, generate a master node label and / or a slave node label for the node of the Kubernetes platform.
[0068] Considering that the MHA software does not automatically repair the downed node and restore it to the cluster, it requires DBA personnel to intervene and manually restore it, make the old master a slave again, and add it to the database cluster. The label-controller of this application also has the function of recovering the failed node: after detecting that the database node has been recovered, delete the failover.complete file, call the MHA-controller, and update the CRD MHAManagerInstance status field to recovery-complete. The Reconcile function of the MHA-controller listens to the update event, calls the generation logic of creating the MHA-manager pod and configmap, restarts the mha-manager instance, and restores the MHA high-availability management mode.
[0069] In one embodiment, the software deployment method based on the Kubernetes platform includes steps S401 to S407.
[0070] Step S401, deploying a MySQL cluster on a Kubernetes platform, where the Kubernetes platform includes a master node and a slave node.
[0071] Step S402, provide MHA software, and establish a connection between the Kubernetes platform and the MHA software, the MHA software includes a management node and multiple database nodes.
[0072] Step S403, in response to the user's request to access the database, a database master node is selected from multiple database nodes.
[0073] Step S404, generating a master node label and a slave node label of the Kubernetes platform according to the information of the database master node and the management node.
[0074] Step S405, detect whether the database node is down. If the detection result is yes (the database node is down), proceed to step S406; if the detection result is no (the database node is not down), proceed to step S407.
[0075] Step S406, after the database node is restored, the management mode of the MHA software is restored, and the process proceeds to step S407.
[0076] Step S407, according to the master node label and the slave node label of the Kubernetes platform, control the MHA software to send a service request to the Kubernetes platform.
[0077] In the embodiments of the present application, considering that the MHA software requires VIP to operate, and the Kubernetes platform requires dynamic IPs, the maintenance of VIP is replaced by labeling, so that the MHA software can run on the Kubernetes platform, expanding the ability of Kubernetes to manage stateful high-availability databases; the container deployment of the MySQL cluster database saves a lot of manual operation processes of database administrators (Database Administrator, DBA), improves efficiency, reduces error rate, and saves operation and maintenance costs; the containerization of the MHA software also solidifies cumbersome operations and reduces the skill requirements for DBAs a lot; the overall cloud-nativeization of stateful and stateless applications makes full use of Kubernetes's ecosystem functions such as resource scheduling, service discovery, and load balancing, and improves the level of enterprise IT governance.
[0078] It should be noted that the above description of the software deployment method process based on the Kubernetes platform is provided for illustrative purposes only and is not intended to limit the scope of this application. For those of ordinary skill in the art, various changes and modifications can be made according to the teachings of this application. However, these changes and modifications will not deviate from the scope of this application. In some embodiments, the step of controlling the MHA software to send a business request to the Kubernetes platform according to the master node label and slave node label of the Kubernetes platform can be performed first; and then the database node is detected whether it is down, that is, the step of detecting whether it is down is performed after sending the business request.
[0079] like Figure 5This is a schematic diagram of the software system structure based on the Kubernetes platform in an embodiment of the present application, which includes: an application unit, a statefulset unit, an Operator unit and an MHA unit. Among them, biz_app in the application unit is a user microservice business application, which can select the mysql-0 master node through the write_service of the Kubernetes platform and expose the access interface to the business application to read and write data; biz_app selects the remaining pods generated by the statefulset through the read_service of the Kubernetes platform, that is, selects the slave node. The MHA software includes a management node and three database nodes, and the management node and the database node respectively contain sshd_sidecar. The mha-manager configuration file is provided by appconfigmap. On the Kubernetes platform, the statefulset unit deploys the MySQL cluster, adopts a semi-synchronous mode, and forms a structure of one master and two slaves (label_M and label_S in the figure). At the same time, a headless is also established so that the statefulset has a stable access name. The biz_apps user's application accesses the database, supporting read-write separation. The write_service object selects the master database pod label and forwards the write request to the master database. The read service object selects the slave database pod label and forwards the read request to the two slave databases in a round-robin manner. The above system can achieve load balancing or analytical SQL.
[0080] In the event of a physical node crash or an abnormality in the database itself, the mysql-0 master node will fail abnormally. The MHA software will select a slave as the new master node based on the health status and the newness of the slave node data. At this time, from the perspective of kubernetes statefulset, it is impossible to distinguish between the master node and the slave node. The Operator unit of one embodiment of the present application includes two controllers: MHA-controller and label-controller. MHA-controller customizes CR resources and maintains MHA-manager and app.conf configmap. According to the MHA-manager information and the real database master node after monitoring the switching of the three database nodes, label-controller adds label_M write node labels and label_S slave node labels respectively.
[0081] See also Figure 6, the embodiment of the present application also provides a software deployment device based on the Kubernetes platform, and the software deployment device based on the Kubernetes platform includes: a Kubernetes platform module, an MHA software module, a label marking module and a business sending module. Among them, the Kubernetes platform module includes a Kubernetes platform, and the Kubernetes platform includes a master node and a slave node, which are used to deploy a My SQL cluster on the Kubernetes platform. The MHA software module is used to provide MHA software and establish a connection between the Kubernetes platform and the MHA software. The MHA software includes a management node and multiple database nodes. The label marking module is used to respond to user requests to access the database, select a database master node from multiple database nodes, and generate a master node label and a slave node label of the Kubernetes platform based on the information of the database master node and the management node. The business sending module is used to control the MHA software to send business requests to the Kubernetes platform based on the master node label and the slave node label of the Kubernetes platform.
[0082] In one embodiment, the master node (Master) and the slave node (Slave) are determined in the following manner: the master node is selected through the write server of the Kubernetes platform to expose the access interface to the business application to read and write data; and the remaining nodes excluding the master node are selected as slave nodes through the read server of the Kubernetes platform.
[0083] In one embodiment, on the Kubernetes platform, a MySQL cluster is deployed in a statefulset manner; a semi-synchronous mode is adopted to form a structure including at least one master node and two slave nodes. When mysql statefulset generates a database cluster for the first time, mysql-0 is the master node. The controller of kubernetes statefulset ensures that after mysql-0 is generated, two slave nodes mysql-1 and mysql-2 are generated by defining the script logic in the statefulset_yaml file.
[0084] In one embodiment, the Kubernetes platform also includes an Operator, the Operator includes a label controller and an MHA controller, the MHA controller includes an MHA software manager and an application configurator, the MHA software manager is used to manage node creation, and the application configurator is used to implement CRD status maintenance.
[0085] In one embodiment, generating the master node label and slave node label of the Kubernetes platform according to the information of the database master node and the management node includes: connecting the management node by using the label controller, reading the log printed by the management node, and obtaining the master node information of the management node in real time; connecting to the database node configured by the configuration file of the MHA software manager through the MySQL client, entering the database to detect the master node information of the database; in response to the master node information of the management node and the master node information of the database being consistent, generating the master node label and / or slave node label for the node of the Kubernetes platform.
[0086] In one embodiment, the software deployment device based on the Kubernetes platform can also achieve: detecting whether a database node is down; responding to a database node downtime, and after the database node is restored, restoring the management mode of the MHA software.
[0087] See also Figure 7 The embodiment of the present application further provides an electronic device 200, which includes at least one memory 210, at least one processor 220, and a bus 230 connecting different platform systems.
[0088] The memory 210 may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) 211 and / or a cache memory 212 , and may further include a read only memory (ROM) 213 .
[0089] The memory 210 also stores a computer program, which can be executed by the processor 220, so that the processor 220 executes a method for high-availability deployment of a database based on the Kubernetes platform.
[0090] The software deployment method based on the Kubernetes platform includes: deploying a MySQL cluster on the Kubernetes platform, the Kubernetes platform includes a master node and a slave node; providing MHA software and establishing a connection between the Kubernetes platform and the MHA software, the MHA software includes a management node and multiple database nodes; responding to user requests to access the database, selecting a database master node from multiple database nodes; generating master node labels and slave node labels of the Kubernetes platform based on the information of the database master node and management node; and controlling the MHA software to send business requests to the Kubernetes platform based on the master node label and slave node label of the Kubernetes platform. The aforementioned method steps are applicable to underlying technical architectures such as cloud computing and Internet finance, and can meet the requirements of standardized rapid delivery, the elastic demand for resources, and are in line with the trend of containerization and service-oriented.
[0091] The specific implementation is consistent with the implementation and technical effects recorded in the above method embodiment, and some contents are not repeated. The memory 210 may also include a program / utility 214 having a set (at least one) of program modules 215, such program modules 215 include but are not limited to: an operating system, one or more application programs, other program modules and program data, each of these examples or some combination may include the implementation of a network environment.
[0092] Accordingly, the processor 220 may execute the above-mentioned computer programs, and may execute the program / utility 214 .
[0093] Bus 230 may be a bus representing one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures.
[0094] The electronic device 200 may also communicate with one or more external devices 240 such as keyboards, pointing devices, Bluetooth devices, etc., and may also communicate with one or more devices that can interact with the electronic device 200, and / or communicate with any device (such as a router, a modem, etc.) that enables the electronic device 200 to communicate with one or more other computing devices. Such communication may be performed through an input / output (I / O) interface 250. In addition, the electronic device 200 may also communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN) and / or a public network, such as the Internet) through a network adapter 260. The network adapter 260 may communicate with other modules of the electronic device 200 through the bus 230. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 200, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage platforms.
[0095] The present application also provides a computer-readable storage medium for storing a computer program, which, when executed, implements:
[0096] Deploy a MySQL cluster on the Kubernetes platform. The Kubernetes platform includes a master node and slave nodes: provide MHA software and establish a connection between the Kubernetes platform and the MHA software. The MHA software includes a management node and multiple database nodes: respond to user requests to access the database and select a database master node from multiple database nodes: generate the master node label and slave node label of the Kubernetes platform based on the information of the database master node and management node; control the MHA software to send business requests to the Kubernetes platform based on the master node label and slave node label of the Kubernetes platform.
[0097] The embodiment of the present application replaces the maintenance of the VIP of the MHA software by labeling, making it possible for the MHA software to run on the Kubernetes platform, expanding the ability of Kubernetes to manage stateful high-availability databases; the overall cloud nativeization of stateful and stateless applications fully utilizes the ecosystem functions of Kubernetes such as resource scheduling, service discovery, and load balancing, thereby improving the level of enterprise IT governance. The specific implementation method is consistent with the implementation method and the technical effect achieved in the embodiment of the above method, and some contents will not be repeated.
[0098] Figure 8 The program product 300 provided in this embodiment for implementing the above method is shown, which can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product 300 of the present invention is not limited to this. In this document, the readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it. The program product 300 can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0099] Computer-readable storage media may include data signals propagated in baseband or as part of a carrier wave, wherein readable program codes are carried. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable storage medium may also be any readable medium other than the readable storage medium, which may send, propagate, or transmit a program used by or in combination with an instruction execution system, an apparatus, or a device. The program code contained on the readable storage medium may be transmitted with any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above. The program code for performing the operation of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and also conventional procedural programming languages such as "C" language or similar programming languages. The program code may be executed entirely on a user computing device, partially on a user device, as an independent software package, partially on a user computing device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0100] This application is explained from the perspectives of purpose of use, effectiveness, progress and novelty. The practical progress it has is in line with the functional enhancement and usage requirements emphasized by the Patent Law. The above description and drawings of this application are only the preferred embodiments of this application, and are not intended to limit this application. Therefore, all structures, devices, features, etc. that are similar or identical to those of this application, that is, all equivalent replacements or modifications made in accordance with the scope of the patent application of this application, should fall within the scope of protection of the patent application of this application.
Claims
1. A software deployment method based on the Kubernetes platform, It is characterized in that include: A MySQL cluster is deployed on the Kubernetes platform, wherein the Kubernetes platform includes a master node and a slave node, and the master node and the slave node are determined in the following manner: the master node is selected by the write server of the Kubernetes platform to expose an access interface to the business application to read and write data; and the remaining nodes excluding the master node are selected as slave nodes by the read server of the Kubernetes platform; Providing MHA (Master High Availability) software and establishing a connection between the Kubernetes platform and the MHA software, wherein the MHA software includes a management node and multiple database nodes; In response to a user's request to access a database, a database master node is selected from the plurality of database nodes; Generating the master node label and the slave node label of the Kubernetes platform according to the information of the database master node and the management node, specifically including: connecting the management node by using the label controller, reading the log printed by the management node, and obtaining the master node information of the management node in real time; Connect to the database node configured in the configuration file of the MHA software manager through the My SQL client, enter the database to detect the master node information of the database; in response to the master node information of the management node and the master node information of the database being consistent, generate a master node label and / or a slave node label for the node of the Kubernetes platform; According to the master node label and the slave node label of the Kubernetes platform, the MHA software is controlled to send a service request to the Kubernetes platform.
2. According to the software deployment method based on the Kubernetes platform according to claim 1, It is characterized in that On the Kubernetes platform, deploy the MySQL cluster using the statefulset method; A semi-synchronous mode is adopted to form a structure including at least one master node and two slave nodes.
3. According to the software deployment method based on the Kubernetes platform according to claim 1, It is characterized in that The Kubernetes platform also includes an Operator, which includes a label controller and an MHA controller. The MHA controller includes an MHA software manager and an application configurator. The MHA software manager is used to create the management node, and the application configurator is used to implement CRD state maintenance.
4. According to the software deployment method based on the Kubernetes platform according to claim 1, It is characterized in that The MHA software includes a management node and three database nodes, and the management node and the database node respectively include sshd_sidecar.
5. The software deployment method based on the Kubernetes platform according to any one of claims 1 to 4, It is characterized in that The method further comprises: Detecting whether a node of the database is down; In response to the node of the database being down, and after the node of the database is restored, the management mode of the MHA software is restored.
6. A software deployment device based on the Kubernetes platform, It is characterized in that include: A Kubernetes platform module includes a Kubernetes platform, wherein the Kubernetes platform includes a master node and a slave node, and is used to deploy a MySQL cluster on the Kubernetes platform. The master node and the slave node are determined in the following manner: the master node is selected through the write server of the Kubernetes platform to expose an access interface to the business application to read and write data; and the remaining nodes excluding the master node are selected as slave nodes through the read server of the Kubernetes platform; MHA software module, used to provide MHA software and establish a connection between the Kubernetes platform and the MHA software, wherein the MHA software includes a management node and multiple database nodes; A label marking module, used to respond to a user's request to access the database and select a database master node from the plurality of database nodes; Generate the master node label and slave node label of the Kubernetes platform according to the information of the database master node and the management node, specifically including: connect the management node by using the label controller, read the log printed by the management node, and obtain the master node information of the management node in real time; connect to the database node configured by the configuration file of the MHA software manager through the MySQL client, enter the database to detect the master node information of the database; in response to the master node information of the management node and the master node information of the database being consistent, generate the master node label and / or slave node label for the node of the Kubernetes platform; The business sending module is used to control the MHA software to send a business request to the Kubernetes platform according to the master node label and the slave node label of the Kubernetes platform.
7. An electronic device comprising a memory, a processor and a hardware module for performing tasks, wherein the memory stores a computer program, and the processor implements the steps of any one of the methods of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any one of the methods of claims 1 to 5.
