CN114138754A - Software deployment method and device based on Kubernetes platform - Google Patents

Software deployment method and device based on Kubernetes platform Download PDF

Info

Publication number
CN114138754A
CN114138754A CN202111502544.4A CN202111502544A CN114138754A CN 114138754 A CN114138754 A CN 114138754A CN 202111502544 A CN202111502544 A CN 202111502544A CN 114138754 A CN114138754 A CN 114138754A
Authority
CN
China
Prior art keywords
node
database
mha
platform
software
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111502544.4A
Other languages
Chinese (zh)
Inventor
李瑞友
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Anchao Cloud Software Co Ltd
Original Assignee
Anchao Cloud Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Anchao Cloud Software Co Ltd filed Critical Anchao Cloud Software Co Ltd
Priority to CN202111502544.4A priority Critical patent/CN114138754A/en
Publication of CN114138754A publication Critical patent/CN114138754A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • G06F11/1464Management of the backup or restore process for networked environments
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/76Adapting program code to run in a different environment; Porting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/4557Distribution of virtual machine instances; Migration and load balancing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/80Database-specific techniques

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Quality & Reliability (AREA)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)

Abstract

The application provides a software deployment method based on a Kubernetes platform, which comprises the following steps: the method comprises the steps that a MySQL cluster is deployed on a Kubernetes platform, and the Kubernetes platform comprises a main node and a slave node; providing MHA software, and establishing the connection between a Kubernetes platform and the MHA software, wherein the MHA software comprises a management node and a plurality of database nodes; responding to a request of a user for accessing the database, and selecting a database main node from a plurality of database nodes; generating a main node label and a slave node label of a Kubernetes platform according to the information of the database main node and the management node; and controlling the MHA software to send a service request to the Kubernets platform according to the main node label and the slave node label of the Kubernets platform. The application transplants the MHA to the Kubernetes platform, comprehensively containerizes the enterprise application, and improves the resource utilization rate and the operation and maintenance efficiency.

Description

Software deployment method and device based on Kubernetes platform
Technical Field
The present application relates to the field of cloud computing technologies, and in particular, to a kubernets platform-based software deployment method and apparatus, an electronic device, and a computer-readable storage medium.
Background
Before software development, various running environments, IDE (integrated development environment), auxiliary tools and the like are generally required to be prepared. The delivery process of available software usually includes two parts of development and maintenance, and it is difficult to ensure that the software in the development testing and operation maintenance stages can operate in the same environment in actual operation. The container technique solves the above problems well, effectively partitions the resources of a single operating system into isolated groups, and is able to better balance conflicting resource usage requirements among the isolated groups. Container technology has become a very popular technology that can mask infrastructure inconsistencies. The container arrangement framework is used as a system core to serially develop, test, deploy, operate and maintain the whole software life cycle, is used as a platform as a service (Paas) platform for providing a standardized operation and maintenance process, and can provide one-key deployment, dynamic scheduling, capacity expansion and reduction and various guard mechanisms for application.
In recent years Kubernetes has gradually consolidated the field of container organization, and many companies have begun to try to build application systems using k8s as an infrastructure. However, although the application is migrated, the data of the application is too fragmented to be uniformly managed, and meanwhile, two sets of systems need to be maintained, and a communication network needs to be erected, so that the migration of the database is an urgent idea of many enterprises.
The MHA (master high availability) is a relatively mature solution in the aspect of MySQL high availability at present, in the MySQL fault switching process, the MHA can automatically complete the fault switching operation of the database within 0-30 seconds, and in the fault switching process, the MHA can ensure the consistency of data to the maximum extent so as to achieve the high availability in the true sense. However, in the conventional MySQL MHA installation method, the whole installation process is troublesome and may be influenced by network uncontrollable, and normally, the D BA (Database Administrator) is generally deployed and completed in about 2-3 hours, and many jobs need to be repeatedly operated on at least three server nodes. Chinese patent application CN202010616118.2 discloses a system and method for ensuring high availability and consistency of MHA clusters, which mainly avoids that MySQL clusters cannot be switched normally due to simultaneous failure of MHA and MySQ L clusters, and ensures availability of user applications. The technical scheme adopted by the method is as follows: the Redis cluster is used for providing a public distributed lock and configuring global notification issuing capacity; when the MHA module executes disaster recovery switching, an exclusive lock is registered in the Redis cluster, so that other MHA instances are prevented from executing disaster recovery switching operation at the same time, and the MHA module is configured to the Redis cluster and releases the lock after the switching is finished and the pushing switching is finished; the MHA module is based on an MHA native tool, and realizes the locking and releasing of an exclusive lock and the configuration pushing function at a custom script at a secondary _ check _ script and an ip _ failure r _ script; the configuration manager ensures that the local configuration of MHA nodes is kept consistent with other MHA time instants. The system formed by the scheme has dependence on an external system, for example, the Redis is used to increase the error probability of the system, and the scheme is not cloud-native. Chinese patent application CN202010805534.7 discloses mysql-mha cluster one-key deployment method and system based on ansable, comprising the following steps: installing a mysql database in a server; creating an account in a master library and configuring a master node; configuring the database with the master library connection is used for deploying and configuring mha base nodes; carrying out deployment configuration on the MHA management node; and monitoring node deployment. However, the deployment of the infrastructure of the non-cloud native scheme is procedural, the running process time is long, each link needs to be run once, and the dependency failure is easy to occur.
In conclusion, database containerization is imperative, but the Kub ernets platform does not have a particularly good design solution for the highly available solutions of database clusters. Based on this, there is a need for improvements to existing kubernets platform-based databases.
Disclosure of Invention
The application aims to realize the adaptation of a Kubernetes platform and a database high-availability scheme so as to realize comprehensive containerization of enterprise application.
The purpose of the application is realized by adopting the following technical scheme:
in a first aspect, the present application provides a software deployment method based on a Kubernetes platform, including: deploying a MySQL cluster on the Kubernets platform, wherein the Kubernets platform comprises a main node and a slave node; providing MHA software, and establishing the connection between the Kubernetes platform and the MHA software, wherein the M HA software comprises a management node and a plurality of database nodes; responding to a request of a user for accessing the database, and selecting a database main node from the plurality of database nodes; generating a main node label and a slave node label of the Kubernetes platform according to the information of the database main node and the management node; and controlling the MHA software to send a service request to the Kubernets platform according to the main node label and the slave node label of the Kuberne tes platform. The technical scheme has the advantages that the database cluster is deployed to a Kubernets environment, the MySQL cluster is deployed on a Kubernets platform, a master-slave copy MySQL cluster is formed in the Kubernets environment, and the structure can be matched with one master and two slaves of MHA software; in addition, considering that MHA software can only operate by VIP and IP of Kubernets is dynamic, the host node label and the slave node label of the Kubernets platform are generated according to information of the database host node and the management node by selecting the database host nodes from a plurality of database nodes, the label printing mode replaces VIP maintenance, the MHA software is adapted to the database of the Kubernets environment, and the capacity of Kubernets to manage the high-availability database with the state is expanded. Furthermore, the embodiment of the application can meet the requirements of standardized quick delivery and the containerization of the elastic requirements of resources, and conforms to the trend of containerization and service.
In some optional embodiments, the master node and the slave node are determined by: selecting a main node through a write server of the Kubernetes platform to expose an access interface to read and write data for service application; and selecting the residual node except the main node as a slave node through a read server of the Kubernetes platform.
In some optional embodiments, in the kubernets platform, the MySQL cluster is deployed by a stateful approach; and adopting a semi-synchronous mode to form a structure comprising at least one main node and two slave nodes.
In some optional embodiments, the kubernets platform further includes an Operator, the Operator includes a tag controller and an MHA controller, the MHA controller includes an MHA software manager and an application configurator, the MHA software manager is used for creation of the management node, and the application configurator is used for implementing CRD status maintenance.
In some optional embodiments, the generating the master node tag and the slave node tag of the kubernets platform according to the information of the database master node and the management node includes:
connecting the management node by using the tag controller, reading a log printed by the management node, and acquiring the main node information of the management node in real time;
the method comprises the steps that a database node configured by a configuration file of the MHA software manager is connected through a MySQL client, and the database node enters a database to detect main node information of the database;
and generating a master node label and/or a slave node label for the node of the Kubernets platform in response to the consistency of the master node information of the management node and the master node information of the database.
In some optional embodiments, the MHA software includes one management node and three database nodes, and the management node and the database nodes respectively include sshd _ sidecar.
In some optional embodiments, the method further comprises: detecting whether a node of the database is down; and responding to the crash of the nodes of the database, and recovering the management mode of the MHA software after the nodes of the database are recovered.
In a second aspect, the present application provides a kubernets platform-based software deployment apparatus, including:
the Kubernets platform module comprises a Kubernets platform, wherein the Kubernets platform comprises a main node and a slave node and is used for deploying a MySQL cluster on the Kubernets platform;
the MHA software module is used for providing MHA software and establishing the connection between the Kubernetes platform and the MHA software, and the MHA software comprises a management node and a plurality of database nodes;
the label marking module is used for responding to a request of a user for accessing the database and selecting a database main node from the database nodes; generating a main node label and a slave node label of the Kuber nets platform according to the information of the database main node and the management node;
and the service sending module is used for controlling the MHA software to send a service request to the Kubernets platform according to the main node label and the slave node label of the Kubernets platform. The technical scheme has the advantages that the existing mature database high-availability scheme MHA software is transplanted to a Kubernetes platform, so that contribution is made to the aspects of comprehensive containerization of enterprise application, improvement of resource utilization rate, operation and maintenance efficiency and the like; the container deployment of the MySQL cluster Database saves a large amount of manual operation processes of Database administrators (DBAs), improves the efficiency, reduces the error rate and saves the operation and maintenance cost; the containerization of MHA software also solidifies the complicated operation, and the skill requirement on DBA is greatly reduced; for the whole cloud protogenesis of the stateful application and the stateless application, the ecological system functions of Kubernetes such as resource scheduling, service discovery, load balancing and the like are fully utilized, and the IT treatment level of an enterprise is improved.
In a third aspect, the present application provides an electronic device, which includes a memory, a processor, and a hardware module for performing tasks, where the memory stores a computer program, and the processor implements the steps of any one of the above methods when executing the computer program.
In a fourth aspect, the present application provides a computer-readable storage medium storing a computer program which, when executed by a processor, implements the steps of any of the methods described above.
Drawings
The present application is further described below with reference to the drawings and examples.
Fig. 1 is a schematic flow chart of a software deployment method based on a Kubernetes platform according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a method for determining a master node and a slave node according to an embodiment of the present application;
fig. 3 is a schematic flowchart of a method for generating a master node tag and a slave node tag according to an embodiment of the present application;
fig. 4 is a schematic flowchart of a software deployment method based on a Kubernetes platform according to another embodiment of the present application;
fig. 5 is a diagram illustrating a software system architecture based on the kubernets platform according to an embodiment of the present disclosure;
fig. 6 is a block diagram of a software deployment apparatus based on a kubernets platform according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a program product for implementing a type selection method according to an embodiment of the present application.
Detailed Description
The present application is further described with reference to the accompanying drawings and the detailed description, and it should be noted that, in the present application, the embodiments or technical features described below may be arbitrarily combined to form a new embodiment without conflict.
Kubernetes is a set of declarative resource orchestration frameworks that support automated deployment, large-scale scalable, application containerization management. When an application is deployed in a production environment, multiple instances of the application are typically deployed to load balance application requests. In Kubernetes, a plurality of containers can be created, each container runs an application instance, and then management, discovery and access of the group of application instances are realized through a built-in load balancing strategy, and the details do not need operation and maintenance personnel to perform complicated manual configuration and processing. However, Kubernetes has its own unique usage patterns, such as: the IP address of the container is not fixed and changes after the switch. In a traditional software and system solution, certain transformation is needed to be carried out on a set of platform architecture such as cloud and native. Database containerization is imperative, but the kubernets platform does not have a particularly good off-the-shelf design for the highly available solution for database clustering.
The application provides a software deployment method based on a Kubernetes platform, which can transplant the existing mature database High availability scheme MHA (Master High availability) to the Kubernetes platform, and makes contributions to the aspects of enterprise application comprehensive containerization, resource utilization rate improvement, operation and maintenance efficiency and the like.
Referring to fig. 1, an embodiment of the present application provides a software deployment method based on a Kubernetes platform, which can implement migration of a conventional software and system solution to a cloud native platform architecture based on Kubernetes. The software deployment method based on the Kubernetes platform comprises the steps S101 to S105.
Step S101, the MySQL cluster is deployed on a Kubernets platform, and the Kubernets platform comprises a main node and a slave node.
Step S102, providing MHA software, and establishing the connection between the Kubernetes platform and the MHA software, wherein the MHA software comprises a management node and a plurality of database nodes.
Step S103, responding to a request of a user for accessing the database, and selecting a database main node from a plurality of database nodes.
And step S104, generating a main node label and a slave node label of the Kubernetes platform according to the information of the main node and the management node of the database.
And step S105, controlling the MHA software to send a service request to the Kubernets platform according to the main node label and the slave node label of the Kubernets platform.
In the embodiment of the application, the MySQL cluster is deployed on a Kubernets platform, a master-Slave Replication MySQL cluster is formed in a Kubernets environment, and the structure can be matched with one master and two slaves of MHA software; in addition, considering that MHA can only operate by VIP and IP of Kubernets is dynamic, the host node label and the slave node label of the Kubernets platform are generated according to information of the database host node and the management node by selecting the database host nodes from a plurality of database nodes, and the label printing mode replaces VIP maintenance, so that MHA can operate in a Kubernets environment, and the capacity of Kubernets to manage stateful and highly available databases is expanded. Furthermore, the embodiment of the application can meet the requirements of standardized quick delivery and the containerization of the elastic requirements of resources, and conforms to the trend of containerization and service.
In one embodiment, the MySQL cluster is deployed by stateful means on a kubernets platform. Illustratively, the stateful controller starts one Pod at a time sequentially by a sequence number index, and the st atemulset controller waits until each Pod reports ready to start the next Pod. The stateful controller assigns a unique, stable name to each Pod, such as < stateful name > - < ordinal index >. Pods are finally named mysql-0, mysql-1 and mysql-2. Further, considering that stateful requires a stable access name, a header is also required to be created. The stateful et can be responsible for the stable network identification of Pod through the headset, and the intra-cluster access needs to use $ (Pod name), $ (DN S domain name of the belonging service), wherein the belonging service is set by the serviceName domain of the stateful et.
The kubernets platform may include a master node and a slave node. In this embodiment, the kubernets platform adopts a semi-synchronous mode to form a structure including 1 Master node (Master) and a plurality of Slave nodes (Slave) by deploying MySQL cluster.
As shown in fig. 2, the master node and the slave node are determined by:
step S201, selecting a main node through a write server of a Kubernetes platform to expose an access interface to read and write data for service application;
and step S202, selecting the residual node without the main node as a slave node through a read server of the Kubernetes platform. In the embodiment of the application, the related nodes can be horizontally expanded, and all write operations can be executed only on the main node; the read operation may be performed on all nodes.
In one embodiment, when the database cluster is generated by the MySQL stateful firstly, MySQL-0 is the m aster node, and after the stateful controller of the Kubernetes platform ensures that MySQL-0 is generated, the MySQL-1 and MySQL-2 are generated by defining script logic in a stateful yaml file.
Illustratively, stateful yaml defines an init container and an application container, each of which adds an initialization script. The init container may comprise an init-mysql container and a clone-mysql container, wherein: the init-mysql container can judge whether the main database or the slave database is the main database or the slave database according to the pod addressing index, so as to generate a corresponding database configuration file; the clone-mysql container copies the database data from the M master or other Slave Pod into its own directory before the Slave Pod starts, i.e. if the ordial index is not equal to 0, then the ncat and xtrabeckup are used to back up the complete data from the previous container and apply it to the present Pod.
Illustratively, the application pod further comprises containers and a xtrabeckup container. Wherein for containers: if the container already has backup data, directly starting the container as a slave mys ql container, deploying a conventional database instance, setting a storage volume and performing health check; for the xtrabackup container: after the initialization of the MySQL node is completed, the second job of the sidecar container is to start a data transfer service, expose a transfer port with ncat, and prepare backup data for the next pod in the sequence.
The MHA software may comprise a management node and a plurality of database nodes, and the management node and the database nodes each contain sshd sidecar. In one embodiment, the MHA software is a containerized MHA, and the MHA manager node and the MHA node base image are respectively manufactured and a pe rl dependent packet is installed. The MHA node installs the MySQL database, and the communication between the MHA manager node and the MHA node is through ssh protocol. Optionally, the mirroring system should make ssh password-free user type, and a uniform pair of public and private keys may be used for simplicity.
For example, the MHA software switching logic may include:
firstly, verifying when an MHA manager node is started, verifying and copying configuration according to a configuration file and identifying a current master; detecting the MHA configuration and confirming the current master when the abnormality occurs;
then, determining a new master according to the judging process, and blocking and writing the master into the current master;
then, wait for all slave servers to complete synchronization with the existing master, grant write authority at the new master, and switch slave libraries in parallel.
It can be understood that the app1.failover. complete file needs to be manually deleted after MHA software switching to start the MHA manager again. And the failure database needs to be manually added into the MHA environment again once the switching management process exits.
The kubernets platform also includes an Operator that includes an MHA-controller and a label-controller, wherein: the MHA-controller comprises an MHA software manager and an application configurator, wherein the MHA software manager is used for creating the management node, and the application configurator is used for realizing CRD state maintenance. In one embodiment, the MHA software manager (MHA-manager) is responsible for the creation of the MHA-manager pod; conf is the real-time generation of this configmap, and state maintenance. The label-c controller can generate a master node label and a slave node label.
In one embodiment, the logic of the MHA-controller comprises:
firstly, an Operator firstly defines a Kubernets self-defining object MHAManagerInstancest ruct, a structure body comprises two fields spec and status, the spec internally refers to pod definition and configma p definition, and the pod is mainly yaml information required for defining containerized MHA-manager instances, such as containerized mirror images, cpu, memory specification and the like;
secondly, the configmap generates a server segment definition, particularly a hostname, needed by the MHA-manager instance configuration file according to the name and copy number of the MySQL stateful et. In the conventional environment, hostname configures an internal IP address of an IaaS infrastructure, while in the kubernets environment, the IP of a pod uses clusterIP, which is dynamically generated along with scheduling, and a new IP may be generated as long as the pod is rescheduled for some reason. So only the unique internal DNS name assigned by the Kubernetes controller to the pod can be configured in the configmap.
In addition, the state of the CRD is maintained, a down machine is generated in the database, the label-controller detects an abnormity, the MHA-controller is informed, and the state of the CRD MHAMananagement status is updated to be down.
In one embodiment, the label-controller is capable of implementing a labeling procedure: the key point of the label-controller design is that the original characteristic that VIP is attached to a master in an IaaS environment is modified into a mode that MySQL roles are attached to a master pod in a Kubernetes environment in a label mode. In order to ensure safety, the mobile terminal is connected to a database node configured by a configuration file of the MHA-manager through the MySQL client, and enters the database to detect master-slave information again.
In this embodiment, two controllers included in the Operator can generate a master node tag and a slave node tag according to the information of the database master node and the management node:
step S301, connecting a management node by using a tag controller, reading a log printed by the management node, and acquiring the master node information of the management node in real time;
step S302, connecting to a database node configured by a configuration file of an MHA software manager through a MySQL client, and entering a database to detect the main node information of the database;
step S303, responding to the consistency of the master node information of the management node and the master node information of the database, and generating a master node label and/or a slave node label for the node of the Kubernetes platform.
Considering that the MHA software does not automatically repair the downtime node to the cluster, but needs the intervention of DBA personnel, manually restores the downtime node, makes the old owner as slave again, and adds the slave into the database cluster. The label-controller of the application also has a fault node recovery function: and after detecting that the database node is recovered, deleting the failure over. complete file, calling the MHA-controller, and updating the CRD MHAManagerInstance status field to recovery-complete. The Reconfile function of the MHA-controller monitors an update event, invokes the generation logic for creating the MHA-manager pod and the configmap, restarts the MHA-manager instance and restores the MHA high-availability management mode.
In one embodiment, the software deployment method based on the Kubernetes platform comprises the steps S401 to S407.
Step S401, the MySQL cluster is deployed on a Kubernets platform, and the Kubernets platform comprises a main node and a slave node.
Step S402, providing MHA software, and establishing the connection between the Kubernetes platform and the MHA software, wherein the MHA software comprises a management node and a plurality of database nodes.
Step S403, in response to a request from a user to access the database, selecting a database master node from the plurality of database nodes.
And S404, generating a main node label and a slave node label of the Kubernetes platform according to the information of the main node and the management node of the database.
Step S405, detect whether a node of the database is down? If the detection result is yes (the node of the database is down), the step S406 is executed; if the detection result is no (the nodes of the database are not down), the step S407 is entered.
Step S406, after the node of the database is recovered, the management mode of the MHA software is recovered, and step S407 is performed.
Step S407, according to the main node label and the slave node label of the Kubernets platform, the MHA software is controlled to send a service request to the Kubernets platform.
In the embodiment of the application, the MHA software needs VIP to operate, the Kubernets platform needs IP to be dynamic, and the Kubernets platform replaces VIP maintenance in a labeling mode, so that the MHA software operates on the Kubernets platform, and the capacity of managing a high-availability database with states is expanded; the container deployment of the MySQL cluster Database saves a large amount of manual operation processes of Database administrators (DBAs), improves the efficiency, reduces the error rate and saves the operation and maintenance cost; the containerization of MHA software also solidifies the complicated operation, and the skill requirement on DBA is greatly reduced; for the whole cloud protogenesis of the stateful application and the stateless application, the ecological system functions of Kubernetes such as resource scheduling, service discovery, load balancing and the like are fully utilized, and the IT treatment level of an enterprise is improved.
It should be noted that the above description of the kubernets platform-based software deployment method flow is provided for illustrative purposes only and is not intended to limit the scope of the present application. Many variations and modifications may be made to the teachings of the present application by those of ordinary skill in the art in light of the present disclosure. However, such changes and modifications do not depart from the scope of the present application. In some embodiments, the step of controlling the MHA software to send a service request to the kubernets platform according to the master node tag and the slave node tag of the kubernets platform may be performed first; then whether the nodes of the database are down is detected, namely: the step of detecting whether the service request is down is executed after the service request is sent.
Fig. 5 is a schematic structural diagram of a software system based on a kubernets platform in an embodiment of the present application, which includes: an application unit, a stateful unit, an Operator unit and an MHA unit. The biz _ app in the application unit is user microservice service application, and mysql-0 main node can be selected through write _ service of a Kubernets platform to expose an access interface to read and write data for the service application; the biz _ app selects the pod generated by the rest stateful through the read _ service of the Kub internets platform, namely selects the slave node. The MHA software comprises one management node and three database nodes, and the management node and the database nodes respectively contain sshd _ sidecar. The mha-manager configuration file is provided by app configmap, and in a kubernet S platform, a stateful unit deploys MySQL cluster, and a semi-synchronous mode is adopted to form a structure of one master and two slaves (label _ M and label _ S in the figure). A header is also established so that the stateful et has a stable access name. The application of the biz _ apps user accesses the database, read-write separation is supported, a main library pod label is selected through a write _ service object in a writing mode, a writing request is forwarded to a master database, a read service object selects a slave library pod label, and the reading request is forwarded to two slave databases in a training mode. The system can realize load balancing or analytical SQL.
For the condition that a physical node is down or a database is abnormal, a mysql-0 main node is hung abnormally, MHA software selects a certain s-lave as a new main node according to the health condition and the freshness of slave node data, so that the main node and the slave node cannot be distinguished from each other from the perspective of kubernets statefull at this time, and an Operator unit in the embodiment of the application comprises two controllers: MHA-co ntroller and label-controller. And the MHA-controller self-defines CR resources and maintains the MHA-manager and app. And respectively marking a label of a label writing node of label _ M and a label of a slave node of label _ S by the label-controller according to the MHA-manager information and the real database master node after monitoring the switching of the 3 database nodes.
Referring to fig. 6, an embodiment of the present application further provides a software deployment apparatus based on a kubernets platform, where the software deployment apparatus based on the kubernets platform includes: the system comprises a Kubernetes platform module, an MHA software module, a label marking module and a service sending module. The Kubernets platform module comprises a Kubernets platform, the Kubernets platform comprises a main node and a slave node, and the Kubernets platform is used for deploying the My SQL cluster on the Kubernets platform. And the MHA software module is used for providing MHA software and establishing the connection between the Kubernets platform and the M HA software, and the MHA software comprises a management node and a plurality of database nodes. And the label marking module is used for responding to a request of a user for accessing the database, selecting a database main node from the plurality of database nodes, and generating a main node label and a slave node label of the Kubernetes platform according to the information of the database main node and the management node. And the service sending module is used for controlling the MHA software to send a service request to the Kubernets platform according to the main node label and the slave node label of the Kubernets platform.
In one embodiment, the Master node (Master) and the Slave node (Slave) are determined by: selecting a main node through a write server of a Kubernetes platform to expose an access interface to read and write data for service application; and selecting the residual node except the main node as a slave node through a read server of the Kubernetes platform.
In one embodiment, the MySQL cluster is deployed in a stateful manner on a kubernets platform; and adopting a semi-synchronous mode to form a structure comprising at least one main node and two slave nodes. When the mysql st atefulset generates a database cluster for the first time, mysql-0 is a master node, and after the controller of the kubernetes stateful guarantees that the mysql-0 is generated, the script logic is defined in the stateful _ yaml file to regenerate two slave nodes mysql-1 and mysql-2.
In one embodiment, the kubernets platform further comprises an Operator, the Operator comprises a tag controller and an MHA controller, the MHA controller comprises an MHA software manager and an application configurator, the MHA software manager is used for managing the creation of the nodes, and the application configurator is used for realizing the CRD state maintenance.
In one embodiment, generating the master node tag and the slave node tag of the kubernets platform according to the information of the database master node and the management node comprises: connecting the management node by using a tag controller, reading a log printed by the management node, and acquiring the main node information of the management node in real time; the method comprises the steps that a database node configured by a configuration file of an MHA software manager is connected through a MySQL client, and main node information of a database detection database is entered; and generating a main node label and/or a slave node label for the node of the Kuberne tes platform in response to the consistency of the main node information of the management node and the main node information of the database.
In one embodiment, the software deployment device based on the kubernets platform can also realize that: detecting whether a node of a database is down; and responding to the crash of the nodes of the database, and recovering the management mode of the MHA software after the nodes of the database are recovered.
Referring to fig. 7, an embodiment of the present application further provides an electronic device 200, where the electronic device 200 includes at least one memory 210, at least one processor 220, and a bus 230 connecting different platform systems.
The memory 210 may include readable media in the form of volatile memory, such as random access memory (pram) 211 and/or cache memory 212, and may further include Read Only Memory (ROM) 213.
The memory 210 further stores a computer program that can be executed by the processor 220, such that the processor 220 executes a method for high availability deployment based on a kubernets platform database.
The software deployment method based on the Kubernetes platform comprises the following steps: the method comprises the steps that a MySQL cluster is deployed on a Kubernetes platform, and the Kubernetes platform comprises a main node and a slave node; providing MHA software, and establishing the connection between a Kubernet es platform and the MHA software, wherein the MHA software comprises a management node and a plurality of database nodes; responding to a request of a user for accessing the database, and selecting a database main node from a plurality of database nodes; generating a main node label and a slave node label of a Kubernetes platform according to the information of the database main node and the management node; and controlling the MHA software to send a service request to the Kubernets platform according to the main node label and the slave node label of the Kubernets platform. The method steps are suitable for underlying technical architectures such as cloud computing, internet finance and the like, can meet the requirements of standardized rapid delivery and the containerization of the elastic requirements of resources, and meet the trend of containerization and service.
The specific implementation manner is consistent with the implementation manner and the achieved technical effect described in the embodiment of the method, and some contents are not described again. Memory 210 may also include a program/utility 214 having a set (at least one) of program modules 215, such program modules 215 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may comprise an implementation of a network environment.
Accordingly, processor 220 may execute the computer programs described above, as well as may execute programs/utilities 214.
Bus 230 may be a local 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 any other type of bus structure.
The electronic device 200 may also communicate with one or more external devices 240, such as a keyboard, pointing device, Bluetooth device, etc., and may also communicate with one or more devices capable of interacting with the electronic device 200, and/or with any devices (e.g., routers, modems, etc.) that enable the electronic device 200 to communicate with one or more other computing devices. Such communication may occur via an input/output (I/O) interface 250. Also, the electronic device 200 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network such as the Internet) via the network adapter 260. The network adapter 260 may communicate with other modules of the electronic device 200 via the bus 230. It should be appreciated that although not shown in the figures, 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, to name a few.
Embodiments of the present application further provide a computer-readable storage medium for storing a computer program, where the computer program is executed to implement:
the MySQL cluster is deployed on a Kubernets platform, and the Kubernets platform comprises a main node and a slave node: providing MHA software, and establishing connection between a Kubernetes platform and the MHA software, wherein the MHA software comprises a management node and a plurality of database nodes: responding to a request of a user for accessing the database, selecting a database master node from a plurality of database nodes: generating a main node label and a slave node label of a Kubernetes platform according to the information of the database main node and the management node; and controlling the MHA software to send a service request to the Kubernets platform according to the main node label and the slave node label of the Kubernets platform.
According to the embodiment of the application, the maintenance of VIP of MHA software is replaced by a labeling mode, so that the MH A software can run on a Kubernets platform, and the capacity of managing a stateful high-availability database by kubernets is expanded; the ecological system functions of kubernets such as resource scheduling, service discovery, load balancing and the like are fully utilized for the integral cloud protogenesis of the stateful application and the stateless application, and the IT management level of enterprises is improved. The specific implementation manner is consistent with the implementation manner and the achieved technical effect described in the embodiment of the method, and some contents are not described again.
Fig. 8 shows a program product 300 provided by the present embodiment for implementing the method, which may employ a portable compact disc read only memory (CD-ROM) and include program codes, and may be run on a terminal device, such as a personal computer. However, the program product 300 of the present invention is not so limited, and in this document, a readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. Program product 300 may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
A computer readable storage medium may include a propagated data signal with readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A readable storage medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing. Program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind 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).
The foregoing description and drawings are only for purposes of illustrating the preferred embodiments of the present application and are not intended to limit the present application, which is, therefore, to the contrary, the intention is to cover all modifications, equivalents, and alternatives falling within the spirit and scope of the present application.

Claims (10)

1. A software deployment method based on a Kubernetes platform is characterized by comprising the following steps:
deploying a MySQL cluster on the Kubernets platform, wherein the Kubernets platform comprises a main node and a slave node;
providing MHA (Master High availability) software, and establishing connection between the Kubernets platform and the MHA software, wherein the MHA software comprises a management node and a plurality of database nodes;
responding to a request of a user for accessing the database, and selecting a database main node from the plurality of database nodes;
generating a main node label and a slave node label of the Kubernetes platform according to the information of the database main node and the management node;
and controlling the MHA software to send a service request to the Kubernets platform according to the main node label and the slave node label of the Kubernets platform.
2. The Kubernetes platform-based software deployment method according to claim 1, wherein the master node and the slave nodes are determined by:
selecting a main node through a write server of the Kubernetes platform to expose an access interface to read and write data for service application;
and selecting the residual node except the main node as a slave node through a read server of the Kubernetes platform.
3. The Kubernetes platform-based software deployment method according to claim 2, wherein the MySQL cluster is deployed on the Kubernetes platform in a stateful manner;
and adopting a semi-synchronous mode to form a structure comprising at least one main node and two slave nodes.
4. The Kubernets platform-based software deployment method according to claim 1, wherein the Kubernets platform further comprises an Operator, the Operator comprises a tag controller and an MHA controller, the MHA controller comprises an MHA software manager and an application configurator, the MHA software manager is used for creating the management node, and the application configurator is used for realizing CRD state maintenance.
5. The Kubernets platform-based software deployment method of claim 4, wherein generating the master node tag and the slave node tag of the Kubernets platform according to the information of the database master node and the management node includes:
connecting the management node by using the tag controller, reading a log printed by the management node, and acquiring the main node information of the management node in real time;
the method comprises the steps that a database node configured by a configuration file of the MHA software manager is connected through a MySQL client, and the database node enters a database to detect main node information of the database;
and generating a master node label and/or a slave node label for the node of the Kubernets platform in response to the consistency of the master node information of the management node and the master node information of the database.
6. The Kubernetes platform-based software deployment method according to claim 5, wherein the MHA software comprises one management node and three database nodes, and the management node and the database nodes respectively comprise sshd _ sidecar.
7. The Kubernetes platform-based software deployment method according to any one of claims 1-6, further comprising:
detecting whether a node of the database is down;
and responding to the crash of the nodes of the database, and recovering the management mode of the MHA software after the nodes of the database are recovered.
8. A software deployment device based on a Kubernetes platform is characterized by comprising:
the Kubernets platform module comprises a Kubernets platform, wherein the Kubernets platform comprises a main node and a slave node and is used for deploying a MySQL cluster on the Kubernets platform;
the MHA software module is used for providing MHA software and establishing the connection between the Kubernetes platform and the MHA software, and the MHA software comprises a management node and a plurality of database nodes;
the label marking module is used for responding to a request of a user for accessing the database and selecting a database main node from the database nodes; generating a main node label and a slave node label of the Kubernetes platform according to the information of the database main node and the management node;
and the service sending module is used for controlling the MHA software to send a service request to the Kubernets platform according to the main node label and the slave node label of the Kubernets platform.
9. An electronic device comprising a memory, a processor and hardware modules for performing tasks, the memory storing a computer program, the processor implementing the steps of the method according to any of claims 1-7 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
CN202111502544.4A 2021-12-09 2021-12-09 Software deployment method and device based on Kubernetes platform Pending CN114138754A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111502544.4A CN114138754A (en) 2021-12-09 2021-12-09 Software deployment method and device based on Kubernetes platform

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111502544.4A CN114138754A (en) 2021-12-09 2021-12-09 Software deployment method and device based on Kubernetes platform

Publications (1)

Publication Number Publication Date
CN114138754A true CN114138754A (en) 2022-03-04

Family

ID=80385474

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111502544.4A Pending CN114138754A (en) 2021-12-09 2021-12-09 Software deployment method and device based on Kubernetes platform

Country Status (1)

Country Link
CN (1) CN114138754A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114363092A (en) * 2022-03-17 2022-04-15 万商云集(成都)科技股份有限公司 Gateway and method for cloud container engine micro-service deployment
CN114666202A (en) * 2022-03-18 2022-06-24 中国建设银行股份有限公司 Monitoring method and device for master-slave switching based on cloud database
CN114661420A (en) * 2022-03-28 2022-06-24 江苏安超云软件有限公司 Application protection method, device and system based on Kubernetes container platform
CN115348185A (en) * 2022-08-19 2022-11-15 招银云创信息技术有限公司 Control method and control device of distributed query engine
CN117056132A (en) * 2023-10-11 2023-11-14 武汉吧哒科技股份有限公司 MySQL database switching method and device in Docker container, computer equipment and medium

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114363092A (en) * 2022-03-17 2022-04-15 万商云集(成都)科技股份有限公司 Gateway and method for cloud container engine micro-service deployment
CN114363092B (en) * 2022-03-17 2022-05-17 万商云集(成都)科技股份有限公司 Gateway and method for cloud container engine micro-service deployment
CN114666202A (en) * 2022-03-18 2022-06-24 中国建设银行股份有限公司 Monitoring method and device for master-slave switching based on cloud database
CN114666202B (en) * 2022-03-18 2024-04-26 中国建设银行股份有限公司 Monitoring method and device for master-slave switching based on cloud database
CN114661420A (en) * 2022-03-28 2022-06-24 江苏安超云软件有限公司 Application protection method, device and system based on Kubernetes container platform
CN114661420B (en) * 2022-03-28 2023-08-11 安超云软件有限公司 Application protection method, device and system based on Kubernetes container platform
CN115348185A (en) * 2022-08-19 2022-11-15 招银云创信息技术有限公司 Control method and control device of distributed query engine
CN115348185B (en) * 2022-08-19 2023-12-05 招银云创信息技术有限公司 Control method and control device of distributed query engine
CN117056132A (en) * 2023-10-11 2023-11-14 武汉吧哒科技股份有限公司 MySQL database switching method and device in Docker container, computer equipment and medium

Similar Documents

Publication Publication Date Title
CN114138754A (en) Software deployment method and device based on Kubernetes platform
US11226847B2 (en) Implementing an application manifest in a node-specific manner using an intent-based orchestrator
CN108270726B (en) Application instance deployment method and device
US9880827B2 (en) Managing software version upgrades in a multiple computer system environment
US10061665B2 (en) Preserving management services with self-contained metadata through the disaster recovery life cycle
US20060259594A1 (en) Progressive deployment and maintenance of applications on a set of peer nodes
US9792150B1 (en) Detecting site change for migrated virtual machines
US11635752B2 (en) Detection and correction of robotic process automation failures
CN111343219B (en) Computing service cloud platform
WO2020123693A1 (en) Control token and hierarchical dynamic control
US20200057618A1 (en) Software Acceleration Platform for Supporting Decomposed, On-Demand Network Services
KR102114339B1 (en) Method for operating kubernetes system supporting active/standby model
EP3648405A1 (en) System and method to create a highly available quorum for clustered solutions
US11635953B2 (en) Proactive notifications for robotic process automation
CN110784347A (en) Node management method, system, equipment and storage medium for container cluster
CN111355605A (en) Virtual machine fault recovery method and server of cloud platform
Khalel et al. Enhanced load balancing in kubernetes cluster by minikube
CN113934711B (en) Method for automatically deploying gbase8s cluster
CN113746676B (en) Network card management method, device, equipment, medium and product based on container cluster
CN103617077A (en) Intelligent cloud migration method and system
KR100763781B1 (en) Server management system and migration method
EP3387533B1 (en) Disaster recovery of cloud resources
CN112468349B (en) Main node suitable for FT2000+ platform to deploy Ceph
CN117389713B (en) Storage system application service data migration method, device, equipment and medium
US20240022640A1 (en) Rapid Error Detection through Command Validation

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination