Disclosure of Invention
The embodiment of the invention aims to solve the technical problem that: migration issues for application clusters, container node configuration files, runtime data, topology, and network configuration.
According to an aspect of the embodiments of the present invention, a method for migrating an application cluster based on a service model is provided, which includes: acquiring a service model file of an application cluster, and extracting a resource deployment attribute and a container node state of the application cluster in the service model file, wherein the resource deployment attribute comprises: a resource dependency relationship, a software dependency relationship and a topological connection relationship; and completing the migration of the application cluster according to the resource deployment attribute and the container node state.
In one embodiment, the obtaining a service model file of an application cluster, and extracting a resource deployment attribute and a container node state of the application cluster in the service model file specifically include: acquiring a service model file of an application cluster from a service model library of a source data center; importing the service model file into a service model library of a target data center; and extracting the resource dependency relationship, the software dependency relationship, the topological connection relationship and the container node state in the service model file.
In one embodiment, the completing migration of the application cluster according to the resource dependency, the software dependency, the topology dependency and the container node information of the application cluster specifically includes: setting the states of the resource dependency relationship and the software dependency relationship as unbound, setting the state of the topological connection relationship as not established, and setting the state of the container node as not established; allocating resources for the target application cluster according to the container node state and the resource dependency relationship; migrating software for the target application cluster according to the software dependency relationship; migrating the data of the source application cluster to the target application cluster; and carrying out topology connection configuration on the target application cluster according to the topology dependency relationship.
In one embodiment, allocating resources to the target application cluster according to the resource dependency relationship specifically includes: creating a virtual machine in the target application cluster container according to the resource dependency relationship and the container node state; creating a virtual data volume for a virtual machine in a target application cluster container according to the resource dependency relationship; creating a virtual network for the target application cluster according to the container node state; and binding the container resources for the target application cluster container according to the resource dependency relationship.
In one embodiment, creating a virtual machine in a target application cluster container according to a resource dependency relationship and container node information specifically includes: calculating the resource requirement of the virtual container node according to the virtual container node state in the container node state, the dependency relationship between the container node and the virtual container node in the resource dependency relationship and the resource quota requirement of the container node; creating a virtual machine for the virtual container node according to the resource requirement of the virtual container node, binding a virtual machine mirror image, and setting the state of the container node in the container node to be created, wherein the virtual machine mirror image comprises: a system kernel and a container engine.
In one embodiment, creating a virtual data volume for a target application cluster according to a container node state specifically includes: and creating a virtual data volume for the target application cluster according to the virtual data volume in the container node information, and setting the virtual machine state depended by the container node as created.
In one embodiment, creating a virtual network for a target application cluster according to resource dependencies comprises: and creating a virtual network for the target application cluster according to the container node state of the virtual network depended by the container node, and setting the virtual network state depended by the container node as created.
In one embodiment, binding a container resource for a target application cluster container according to a resource dependency relationship specifically includes: binding a virtual data volume for the container node according to the virtual machine dependency relationship in the resource dependency relationship, and binding a virtual data volume for the container node according to the data volume dependency relationship in the resource dependency relationship; binding a virtual network for the container node according to the network dependency relationship in the resource dependency relationship; the states of the virtual machine dependency, the data volume dependency and the network dependency are set to bound.
In one embodiment, migrating software for a target application cluster according to a software dependency relationship specifically includes: obtaining a container mirror image list of a virtual machine container node according to the inverse dependency relationship between the virtual machine and the container in the resource dependency relationship and the dependency relationship between the container and the container mirror image; calling a container engine of the virtual machine, acquiring a non-stored container mirror image from a container mirror image warehouse of the target data center, and if the specified container mirror image does not exist in the container mirror image warehouse of the target data center, acquiring the non-existing container mirror image from the container mirror image warehouse of the source data center by the container mirror image warehouse; the container engine installs the file of the container mirror image according to the mirror image dependency relationship in the resource dependency relationship; and binding the top-level mirror image of the container mirror image file for the container, and setting the mirror image dependency relationship in the resource dependency relationship as bound.
In one embodiment, when the states of all the mirror dependencies are bound, runtime data migration of the data container node is started, and data of the source application cluster is migrated to the target application cluster.
In one embodiment, migrating data of a source application cluster to a target application cluster to stop the source application cluster specifically includes: stopping the source application cluster, and acquiring data of the data container nodes in the source application cluster during operation; generating a snapshot mirror according to the data of the data container node in the source application cluster during operation; uploading the snapshot mirror to a container mirror warehouse of the source data center; and the container engine of the target data center acquires the mirror image snapshot from the source mirror image warehouse and imports the mirror image snapshot into the specified container node.
In one embodiment, performing topology connection configuration for a target application cluster according to a topology connection relationship specifically includes: acquiring connection information in a topological connection relation; configuring topological connection attribute parameters for the container; and starting the topological connection attribute parameters, and setting the state of the topological connection relation to be established.
In one embodiment, the method of this embodiment further includes: when the resource dependency relationship, the software dependency relationship and the topology connection dependency relationship are all bound, setting the state of the container node to be ready; and when the states of all the container nodes are set to be ready, confirming that the migration of the application cluster is completed.
According to an aspect of the present invention, a migration apparatus for migrating an application cluster based on a service model is provided, which is characterized by comprising: the information acquisition module is used for acquiring a service model file of the application cluster and extracting a resource deployment attribute and a container node state of the application cluster in the service model file, wherein the resource deployment attribute comprises: a resource dependency relationship, a software dependency relationship and a topological connection relationship; and the cluster migration module is used for completing the migration of the application cluster according to the resource deployment attribute and the container node state.
In one embodiment, the information acquisition module includes: the system comprises an export subunit, an import subunit and an information extraction unit, wherein the export subunit is used for acquiring a service model file of an application cluster from a service model library of a source data center; the importing subunit imports the service model file into a service model library of the target data center; and the information extraction unit is used for extracting the resource dependency relationship, the software dependency relationship, the topological connection relationship and the container node state in the service model file.
In one embodiment, a cluster migration module includes: the system comprises a state setting unit, a resource allocation unit, a software migration unit, a data migration unit and a topology configuration unit, wherein the state setting unit is used for setting the states of the resource dependency relationship and the software dependency relationship as unbound, setting the state of the topology connection relationship as not established and setting the state of the container node as not established; the resource allocation unit is used for allocating resources to the target application cluster according to the container node state and the resource dependency relationship; the software migration unit is used for migrating software for the target application cluster according to the software dependency relationship; the data migration unit is used for migrating the data of the source application cluster to the target application cluster; and the topology configuration unit is used for carrying out topology connection configuration on the target application cluster according to the topology dependency relationship.
In one embodiment, the resource allocation unit includes: the system comprises a resource creating subunit and a resource binding unit, wherein the resource creating subunit is used for creating a virtual machine in a target application cluster container according to a resource dependency relationship and a container node state; the virtual data volume is created for the virtual machine in the target application cluster container according to the resource dependency relationship; the virtual network is also used for establishing a virtual network for the target application cluster according to the container node state; and the resource binding unit is used for binding the container resources for the target application cluster container according to the resource dependency relationship.
In one embodiment, the resource creating subunit is specifically configured to calculate the resource requirement of each virtual machine node according to the resource quota requirement of the container node and the dependency relationship between the container node and the virtual machine node; the resource creating subunit is further configured to create a virtual machine for the virtual container node according to the resource requirement of the virtual container node, bind a virtual machine image, and set a state of the virtual machine on which the container node depends as created, where the virtual machine image includes: a system kernel and a container engine.
In an embodiment, the resource creating subunit is specifically configured to create a virtual data volume for the target application cluster according to the virtual data volume in the container node information, and set a state of a virtual machine on which the container node depends as created.
In an embodiment, the resource creating subunit is specifically configured to create a virtual network for the target application cluster according to a virtual network container node state that the container node depends on, and set the virtual network state that the container node depends on as created.
In one embodiment, the resource binding unit is specifically configured to bind the virtual machine dependency relationship according to the resource dependency relationship; the virtual data volume is bound for the container node; the virtual data volume is bound for the container node according to the data volume dependency relationship in the resource dependency relationship; the virtual network binding system is also used for binding the virtual network for the container node according to the network dependency relationship in the resource dependency relationship; and also for setting the states of the virtual machine dependencies, data volume dependencies, and network dependencies to bound.
In an embodiment, the software migration unit is specifically configured to obtain a container mirror list of a virtual machine container node according to an inverse dependency relationship between a virtual machine and a container in a resource dependency relationship and a dependency relationship between a container and a container mirror; the system comprises a container mirror warehouse, a virtual machine and a virtual machine, wherein the container mirror warehouse is used for storing container mirror images of a host computer; the system is also used for installing the file of the container mirror image according to the mirror image dependency relationship in the resource dependency relationship; and the system is also used for binding the top-level mirror image of the container mirror image file for the container and setting the mirror image dependency relationship in the resource dependency relationship as bound.
In one embodiment, the data migration unit is further configured to start runtime data migration of the data container node and migrate data of the source application cluster to the target application cluster when the states of all the mirror dependencies are bound.
In one embodiment, the data migration unit is specifically configured to stop the source application cluster, and obtain runtime data of a data container node in the source application cluster; the snapshot mirror image is generated according to the data of the data container nodes in the source application cluster during the operation; uploading the snapshot mirror to a container mirror warehouse of the source data center; and the container engine of the target data center acquires the mirror image snapshot from the source mirror image warehouse and imports the mirror image snapshot into the specified container node.
In an embodiment, the topology configuration unit is specifically configured to obtain connection information in a topology connection relationship; the topology connection attribute parameter configuration module is also used for configuring topology connection attribute parameters for the container; and the method is also used for starting the topological connection attribute parameters and setting the state of the topological connection relation to be established.
In an embodiment, the apparatus of this embodiment further includes a cluster migration unit, configured to set the state of the container node to be ready when the resource dependency, the software dependency, and the topology connection dependency are all bound; and the method is also used for confirming that the migration of the application cluster is completed after the state of all the container nodes is set to be ready.
In the embodiment, automatic migration of all nodes and dependency relationships of an application cluster is realized through a service model; by analyzing the software images depended on by each host, the software images depended on are installed on the hosts of the target data center in batch, the cluster migration speed is increased, and therefore the downtime of cluster migration is reduced; binding the environmental parameters of the target cluster for the node configuration file template to generate the configuration file of the target cluster, thereby improving the migration efficiency of the configuration file of the cluster; and the mirror image warehouse of the target data center is used as a mirror image agent of the target application cluster, and the required mirror image is acquired from the mirror image warehouse of the source data center and cached as required, so that the mirror image installation of the cluster is accelerated.
Other features of the present invention and advantages thereof will become apparent from the following detailed description of exemplary embodiments thereof, which proceeds with reference to the accompanying drawings.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The relative arrangement of the components and steps, the numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless specifically stated otherwise.
Meanwhile, it should be understood that the sizes of the respective portions shown in the drawings are not drawn in an actual proportional relationship for the convenience of description.
Techniques, methods, and apparatus known to those of ordinary skill in the relevant art may not be discussed in detail, but are intended to be part of the specification where appropriate.
In all examples shown and discussed herein, any particular value should be construed as merely illustrative, and not limiting. Thus, other examples of the exemplary embodiments may have different values.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus once an item is referenced in one figure, further discussion of it is not necessary in subsequent figures.
Fig. 1 shows an architecture diagram of a typical cloud application cluster, and referring to fig. 1, it is assumed that a container application cluster is composed of 4 container nodes, which are respectively a load balancing node nginx, two Web server nodes WebApp + tomcat, and a database node mysql, and the application cluster is deployed on 3 virtual machines, wherein the nginx node, the two Web server nodes, and the mysql are respectively deployed on one virtual machine, and the virtual machine and the container of the whole cluster share the same IP subnet. The mysql nodes are stateful nodes, mount virtual volumes, have runtime data, and the other nodes are stateless nodes.
FIG. 2 shows an abstract container application service model, describing the components of the container application service model. The container application service model is composed of a container list, a software list, a resource list and connection relations and dependency relations, wherein the container, the resource and the software are all nodes of an attribute model, and the nodes can possess one or more attributes, zero or more operations and zero or more relations. The relationship between nodes is divided into two types: the dependency relationship specifies the installation order of the nodes, and the connection relationship specifies the communication direction of the nodes. Relationships may also have attributes and operations, simple relationships may be defined within a source node, and complex relationships may be defined separately. In addition, the service model also possesses some common attributes and common operations at the service model level, such as mirror repository URLs, cloud resource management URLs, and the like. The service model library comprises a Web server, when the service model is loaded by the service model library, the attributes and the states of the nodes and the relations of the service model can be accessed and modified through REST API, and the operations of the nodes and the relations can be called through RESTAPI. Wherein the state of the container node comprises: the method comprises the steps of non-creation, ready and operation, wherein the non-creation means that a container does not exist, the ready means that the container is created, the resource dependence, the software dependence and the connection dependence of the container are bound, and only the container process is started in the operation and can provide services to the outside.
Fig. 3 shows an exemplary diagram of a service model of the container application cluster, which is illustrated in fig. 1, and describes the dependency and connection relationships of 4 container nodes. The device comprises a virtual machine A, a network A, a container mirror image Nginx, a WebApp container A, a WebApp container B, a Mysql container A and a container snapshot MysqlA, wherein the Nginx container A depends on the virtual machine A, the network A and the container mirror image Nginx, the WebApp container A and the WebApp container B depend on the virtual machine B, the network A and the container mirror image WebApp, and the Mysql container A depends on the virtual machine C, a data volume A, the network A. Virtual machine a, virtual machine B, virtual machine C, both rely on a virtual machine image Centos _ DockerEngine that encapsulates an operating system Centos base version and a container engine DockerEngine. The container mirror WebApp depends on the container mirror Tomcat, and the container mirror Nginx, the container mirror Tomcat and the container mirror Mysql all depend on the container mirror CentosExt which encapsulates the system library on which the upper container mirror depends.
The service model can be defined by description languages such as YAML, xml or json, and the like, can be loaded into the service model engine, can be mapped into classes and objects (such as Java) of a specific language, and in the service model engine, the attributes, operations and relationships of the service model can be directly called and accessed through the objects at the language level, and meanwhile, the service model engine externally provides a REST API interface to allow an external module to remotely access the service model through the REST API based on HTTP.
Taking the container nginnxa as an example, the node model defined by YAML is as follows:
a container:
nginx Container A
Type Nginx Container
State of not creating
Runtime data none
Network attribute { network mode host, host IP }
Quota attribute { CPU core number: 2, memory size: 2G, disk size: 1G }
List of operations:
-creating a container
-priming the container
-stopping the container
Resource dependency list:
virtual host { ID: virtual machine A, state: unbound, -operation: bound virtual machine }
Virtual network { ID: network A, State: unbound, -operation: bound network }
List of software dependencies:
container mirror { ID: Container mirror Nginx, State: unbound, -operation: bound mirror }
List of connection relationships:
connection of a rear-end agent { ID: connection of a rear-end agent 1, state: not established, operation: configuration of a rear-end agent, connection attribute { front-end port: 80, rear-end IP: < WebApp container A. network attribute. host IP >, rear-end port: < WebApp container A. network attribute. host port > }
Connection of a rear-end agent { ID: connection of a rear-end agent 2, state: not established, operation: configuration of a rear-end agent, connection attribute { front-end port: 80, rear-end IP: < WebApp container B. network attribute. host IP >, rear-end port: < WebApp container B. network attribute. host port > }
The model of WebApp Container A is defined as follows:
a container:
ID WebApp Container A
Type WebApp Container
State of not creating
Runtime data none
Network attribute { network mode: bridge, container IP, container port, host IP, host port, port mapping }
Quota attribute { CPU core number: 2, memory size: 2G, disk size: 5G }
Container operation list:
-creating a container
-priming the container
-stopping the container
Resource dependency list:
virtual host { ID: virtual machine B, state: unbound, -operation: bound virtual machine }
Virtual network { ID: network A, State: unbound, -operation: bound network }
List of software dependencies:
container mirror { ID: Container mirror WebApp, State: unbound, -operation: bound mirror }
List of connection relationships:
database connection { ID: database connection 1, state: not established, -operation: database connection configuration, attribute { database IP: < Mysql container a. network attribute. host IP >,
database IP < Mysql container a. network attributes host port >,
database name < Mysql container a. database attribute database name >,
database account number < Mysql container a. database attribute database account number >,
database password: < Mysql container a. database attribute. database password > }
The service model of Mysql container a is defined as follows:
a container:
ID Mysql Container A
Type Mysql container
State of not creating
Runtime data having
Container network attributes { Intranet IP, Intranet Port, Extranet IP, Extranet Port 3306, Port mapping }
Container quota attribute { CPU core number: 4, memory size: 4G, disk size: 50G }
Database attribute { database name, database account, database password }
Container operation list:
-creating a container
-priming the container
-stopping the container
-export container snapshots
Resource dependency list:
virtual host { ID: virtual machine C, state: unbound, operation: bound virtual machine }
Data volume { ID: data volume A, status: unbound, operation: bound data volume }
Virtual network { ID: network A, State: unbound, operation: bound network }
List of software dependencies:
container mirror { ID: Container mirror Mysql, State: unbound, operation: bound mirror }
Container snapshot { ID: container snapshot MysqlA, state: unbound, operation: bound mirror }
FIG. 4 is a flow chart of one embodiment of the method of the present invention. As shown in fig. 4, the method of this embodiment includes:
step S401, obtaining a service model file of an application cluster, and extracting a resource deployment attribute and a container node state of the application cluster in the service model file, wherein the resource deployment attribute comprises: resource dependencies, software dependencies, and topological connectivity.
And step S402, completing the migration of the application cluster according to the resource deployment attribute and the container node state.
In the embodiment, automatic migration of all nodes and dependency relationships of an application cluster is realized through a service model; by analyzing the software images depended on by each host, the software images depended on are installed on the hosts of the target data center in batch, the cluster migration speed is increased, and therefore the downtime of cluster migration is reduced; binding the environmental parameters of the target cluster for the node configuration file template to generate the configuration file of the target cluster, thereby improving the migration efficiency of the configuration file of the cluster; and the mirror image warehouse of the target data center is used as a mirror image agent of the target application cluster, and the required mirror image is acquired from the mirror image warehouse of the source data center and cached as required, so that the mirror image installation of the cluster is accelerated.
The inventive service model-based application cluster migration method is detailed below:
firstly, migrating a service model.
Referring to fig. 5, in the application cluster migration method based on the service model, migrating the service model specifically includes the following steps:
step S501, exporting the service model file of the application cluster from the service model library of the source data center.
Step S502, importing a service model file into a service model library of a target data center; extracting the resource dependency relationship, the software dependency relationship, the topological connection relationship and the container node state in the service model file, setting all the container node states as 'not established', setting the resource dependency relationship and the software dependency relationship as unbound, setting the topological connection relationship as not established, and setting the container node state as not established.
In one embodiment, migrating the service model may further include:
step S503, modifying the cloud resource management URL of the service model, and pointing the cloud resource management URL to the management URL of the target data center management agent.
Step S504, the URL attribute of the mirror image warehouse of the application model is modified, and the URL attribute of the mirror image warehouse points to the mirror image warehouse URL of the target data center.
Secondly, allocating resources to the target cluster in the application cluster migration method based on the service model, where, referring to fig. 6, the step of allocating resources to the target cluster in the present invention may include the following operations:
step S601, a virtual machine is created for the target cluster.
Step S602, a virtual storage is created for the target cluster.
Step S603, a virtual network is created for the target cluster.
Step S604, binding network resources for the target cluster.
Referring to fig. 7, the operation step S601 of creating a virtual machine for a target cluster specifically includes the following operations:
step S701, calling a virtual machine node query interface of a service model engine, and acquiring all virtual machines with the container node states of 'not created'.
Step S702, calculating a resource requirement of each virtual machine node according to the resource quota of the container node and the dependency relationship between the container node and the virtual machine node, where the resource requirement is the sum of specifications of each container on the virtual machine, and includes the number of CPU cores, the size of the memory of the virtual machine, the size of the disk, and the like.
Step S703, obtaining a virtual machine specification with a resource specification not less than the resource requirement through a cloud resource management platform of the management agent, for example, a virtual machine query interface API of the cloud computing management platform openstack.
Step S704, invoke a creation operation of a virtual machine node, for example, an interface of a service model proxy may be invoked, allocate a virtual machine to the virtual machine node according to a virtual machine image identifier and a virtual machine resource specification ID, bind the virtual machine image, and set a container node state in the container node to be created, where the virtual machine image includes: a system kernel and a container engine.
Step S705, after the virtual machine is successfully created, updating information such as the IP address and the host name of the virtual machine node, and setting the state of the container node to "created", thereby completing the creation of the virtual machine.
Referring to fig. 8, creating virtual storage 602 for a target cluster specifically includes the following operations:
in step S801, a virtual data volume with a container node state of "not created" is obtained, for example, a virtual storage node query interface of the service model may be called to perform querying and obtaining.
Step S802, a creation interface of the storage node of the virtual machine is called, for example, the creation and calling may be performed according to the size and type of the virtual data volume.
In step S803, the virtual network node in the state of "not created" is obtained, for example, by calling a virtual storage node query interface of the service model.
Step S804, a "creation" operation of each virtual network node is invoked, for example, the invocation and creation can be implemented according to information such as network bandwidth.
Step S805, a virtual network is created by calling a network management API interface of a cloud resource management platform in the target data center management agent through the service model engine.
Step S806, after the Virtual Network is successfully created, information such as a Network address, a gateway IP, a subnet mask, a Virtual Local Area Network identifier (VlAN) of the Virtual Network node is updated, and the state of the Virtual Network node is set to "created".
Referring to fig. 9, the step S603 of binding network resources to the target cluster may specifically include the following steps:
step S901, obtaining a resource dependency relationship that the container node state is "unbound", for example, a virtual query interface of a service model may be called to perform query and obtaining.
Step S902, for the dependency of the virtual machine, executing a binding virtual machine operation, updating a host IP of the container node, creating a container on the virtual machine through a container creation interface of a container engine of the management agent, and performing initialization configuration related to the container, for example, the initialization configuration may include an environment variable, a resource quota, and the like of the container, so as to change the state of the dependency of the virtual machine to "bound".
Step S903, for the data volume dependency, executing the data volume binding operation, and through the mount data volume interface of the container engine, mounting the data volume for the container, changing the state of the dependency into 'bound'.
Step S904, for the network dependency, executing a virtual network binding operation, first configuring a container network through a container engine network configuration interface, allocating a virtual network card to the container, bridging the virtual network card of the container to a host network bridge of the virtual machine, then adding a host IP and a host port of the container to a VLAN of the virtual machine network through a network management interface of the cloud resource management platform, and finally updating a network attribute of the container node, and setting a state of the network dependency as "bound".
And thirdly, migrating application cluster software.
Referring to fig. 10, the step of migrating software to an application cluster in the service model-based application cluster migration method according to the present invention may include:
step S1001, a container mirror image list required to be installed by each virtual machine node is obtained according to the inverse dependency relationship between the virtual machine and the container and the dependency relationship between the container and the container mirror image.
Step S1002, call the container engine on each virtual machine, and download the container images that do not exist on the virtual machines from the container image warehouse of the target data center.
Step S1003, if there is no designated container mirror image in the container mirror image warehouse of the target data center, the container mirror image warehouse downloads the wall-hanging storage container mirror image from the container mirror image warehouse of the source data center.
At step S1004, the container engine installs the mirror hierarchy into the host' S local mirror repository according to the mirror dependency hierarchy in the container mirror, where the local mirror repository is typically implemented by some federated file system supporting a hierarchical file structure, such as AUFS or BTRFS.
Step S1005, calling the binding mirror image operation of the container engine, binding the top container mirror image for each container, and setting the container mirror image dependency relationship as 'bound'
Step S1006, when the container mirror dependency relationships of all container nodes are "bound", it indicates that the software of the stateless node and the stateful node of the application cluster is installed, and the runtime data migration operation of the stateful node may be started.
In an embodiment, referring to fig. 11, the operation of runtime data migration of a stateful node may specifically include:
step S1101, stops the source application cluster.
Step S1102, exporting the runtime data with the state node in the source application cluster, and exporting the runtime data with the state container into a snapshot mirror by invoking a snapshot exporting operation of the container engine, where the snapshot mirror is a special container mirror and only includes runtime incremental data in the container.
And step S1103, uploading the snapshot mirror image to a container mirror image warehouse of the source data center.
In step S1104, the container engine of the target data center requests the target mirror repository to obtain a snapshot mirror.
In step S1105, the target image repository downloads the image snapshot from the source image repository.
In step S1106, the container engine imports the mirror snapshot into a designated container, thereby implementing runtime data migration.
Referring to fig. 12, the operation of the topology connection configuration in this embodiment may specifically include the following steps:
step S1201, a topology connection query interface of the service engine is called, and a topology connection list in which the state is "not established" in each container node is obtained.
Step S1202, setting a connection attribute parameter of the topology connection, for example, referring to the backend proxy connection definition of the above-mentioned Nginx container a, the content in "< >" in the connection attribute may be replaced with an attribute value of a corresponding node in the model, < WebApp container a. network attribute. host IP > represents a host IP attribute of the network attribute set of the WebApp container a node, and is assumed to be 10.10.10.11, < WebApp container a. network attribute. host port > represents a host port attribute of the network attribute set of the WebApp container a node, and is assumed to be 8080. The instantiated connection attributes are 80 for the front-end port, 10.10.10.10 for the back-end IP, 8080 for the back-end port.
Step S1103, a connection configuration operation is performed, each topology connection relationship has a configuration operation, the configuration operation binds a configuration API of the management agent, and the REST API of the container engine of the management agent is called to perform the connection configuration operation of the corresponding container. There is a need to extend the container engine, provide the script configuration REST API within the container, and execute the specified configuration script on the specified container. For example: the REST API for performing nginx backend connection configuration is:
http:// < container host IP >, < container engine port >/< container ID >/configshell/? sh & fe _ port 80& be _ ip 10.10.10.10& be _ port 8080.
And after receiving the REST API request, the container engine is connected with the specified container through a pipeline mechanism or an SSH mechanism according to the container ID in the URI parameters, and executes the specified configuration script nginx _ config.
Step S1204, after the configuration script is successfully executed, changes the state of the topology connection relationship to "established".
Fifthly, starting the target application cluster
Referring to fig. 13, the operation of starting the target application cluster according to the present invention may specifically include the following steps:
step S1301, when the resource dependency relationship, the software dependency relationship, and the topology connection dependency relationship of the container node are all bound, the state of the container node is set to "ready".
Step S1302, sequentially starting the containers with the "ready" status according to the topological connection dependency relationship of the containers, calling the REST API of the container engine to start the containers, and setting the status of the container node as "running" after the container node is started. Firstly, a node at the end of a dependency relationship in reference fig. 1, that is, a depended root node, which is a Mysql container a node in this embodiment, is started, then dependent child nodes of the root node, a WebApp container a node and a WebApp container B node are started in sequence, and finally, a top-level node with topology dependence, that is, an Nginx container a node, is started.
Step S1303, after all container nodes of the cluster are started, migration work of the whole application cluster is completed
Fig. 14 is a schematic structural diagram of a migration apparatus for migrating an application cluster based on a service model according to an embodiment of the present invention. Referring to fig. 14, the apparatus of the present embodiment includes: an information acquisition module 1401 and a cluster migration module 1402.
An information obtaining module 1401, configured to obtain a service model file of an application cluster, and extract a resource deployment attribute and a container node state of the application cluster in the service model file, where the resource deployment attribute includes: a resource dependency relationship, a software dependency relationship and a topological connection relationship;
and the cluster migration module 1402 is configured to complete migration of the application cluster according to the resource deployment attribute and the container node state.
In one embodiment, referring to fig. 15, the information acquisition module 1401 includes: an export sub-unit 1501, an import sub-unit 1502, and an information extraction unit 1503.
The export subunit 1501 is configured to obtain the service model file of the application cluster from the service model library of the source data center.
The import sub-unit 1502 imports the service model file into the service model library of the target data center.
The information extraction unit 1503 is configured to extract the resource dependency relationship, the software dependency relationship, the topology connection relationship, and the container node state in the service model file.
In one embodiment, referring to fig. 16, cluster migration module 1402 comprises: a state setting unit 1601, a resource allocation unit 1602, a software migration unit 1603, a data migration unit 1604, and a topology configuration unit 1605.
Wherein,
the state setting unit 1601 is configured to set the states of the resource dependency relationship and the software dependency relationship as unbound, set the state of the topology connection relationship as not established, and set the state of the container node as not created.
A resource allocating unit 1602, configured to allocate resources for the target application cluster according to the container node state and the resource dependency relationship.
A software migration unit 1603, configured to migrate software for the target application cluster according to the software dependency relationship.
A data migration unit 1604 for migrating data of the source application cluster to the target application cluster.
A topology configuration unit 1605, configured to perform topology connection configuration for the target application cluster according to the topology dependency relationship.
In one embodiment, referring to fig. 17, the resource allocation unit 1602 includes: a resource creation subunit 1701 and a resource binding unit 1702.
A resource creating subunit 1701, configured to create a virtual machine in the target application cluster container according to the resource dependency relationship and the container node state; the virtual data volume is created for the virtual machine in the target application cluster container according to the resource dependency relationship; and the virtual network is created for the target application cluster according to the resource dependency relationship.
A resource binding unit 1702, configured to bind the container resource for the target application cluster container according to the resource dependency relationship.
In one embodiment, the resource creating subunit 1701 is specifically configured to calculate the resource requirement of each virtual machine node according to the resource quota requirement of the container node and the dependency relationship between the container node and the virtual machine node; the resource creating subunit is further configured to create a virtual machine for the virtual container node according to the resource requirement of the virtual container node, bind a virtual machine image, and set a state of the virtual machine on which the container node depends as created, where the virtual machine image includes: a system kernel and a container engine.
In one embodiment, the resource creation subunit 1701 is specifically configured to create a virtual data volume for the target application cluster according to the virtual data volume in the container node information, and set the virtual machine state on which the container node depends to be created.
In one embodiment, the resource creating subunit 1701 is specifically configured to create a virtual network for the target application cluster according to a virtual network container node state in the container node states, and set a virtual network state on which the container node depends to be created.
In an embodiment, the resource binding unit 1702 is specifically configured to determine, according to a virtual machine dependency in the resource dependencies; the virtual data volume is bound for the container node; the virtual data volume is bound for the container node according to the data volume dependency relationship in the resource dependency relationship; the virtual network binding system is also used for binding the virtual network for the container node according to the network dependency relationship in the resource dependency relationship; and also for setting the states of the virtual machine dependencies, data volume dependencies, and network dependencies to bound.
In an embodiment, the software migration unit 1603 is specifically configured to obtain a container mirror list of a virtual machine container node according to an inverse dependency relationship between a virtual machine and a container in a resource dependency relationship and a dependency relationship between a container and a container mirror; the system comprises a container mirror warehouse, a virtual machine and a virtual machine, wherein the container mirror warehouse is used for storing container mirror images of a host computer; the system is also used for installing the file of the container mirror image according to the mirror image dependency relationship in the resource dependency relationship; and the system is also used for binding the top-level mirror image of the container mirror image file for the container and setting the mirror image dependency relationship in the resource dependency relationship as bound.
In one embodiment, the data migration unit 1604 is configured to initiate runtime data migration of the data container node to migrate runtime data of the source application cluster to the target application cluster when states of all mirror dependencies are bound.
In an embodiment, the data migration unit 1604 is specifically configured to stop the source application cluster, and obtain data of a data container node in the source application cluster during running; the snapshot mirror image is generated according to the data of the data container nodes in the source application cluster during the operation; uploading the snapshot mirror to a container mirror warehouse of the source data center; the container engine, which is also used in the target data center, takes the mirror snapshot from the source mirror repository and imports the mirror snapshot into the designated container node.
In an embodiment, the topology configuration unit 1605 is specifically configured to obtain connection information in the topology connection relationship; the topology connection attribute parameter configuration module is also used for configuring topology connection attribute parameters for the container; and the method is also used for starting the topological connection attribute parameters and setting the state of the topological connection relation to be established.
In one embodiment, referring to fig. 16, the migration apparatus in this implementation may further include: the cluster migration unit 1606 is configured to set the state of the container node to ready when the resource dependency relationship, the software dependency relationship, and the topology connection dependency relationship are all bound; and the method is also used for confirming that the migration of the application cluster is completed after the state of all the container nodes is set to be ready.
It will be understood by those skilled in the art that all or part of the steps of implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.