Background
Kubernetes is an open-source container-based cluster management platform, and aims to realize simple and efficient application of deploying containerization, and provide a mechanism for deploying, planning, updating and maintaining applications, namely K8S. A K8S system, commonly called a K8S Cluster (Cluster), mainly comprises two parts, namely a plurality of Master nodes (Master nodes) and a group of Node nodes (computing nodes). The K8S cluster is a containerized management system and is a set of cloud resources required by container operation. The system consists of a plurality of working nodes (cloud hosts or physical machines), load balancing, networks and other resources, and provides abundant and various functions of resource scheduling, deployment operation, service discovery, capacity expansion, capacity shrinkage and the like for containerized applications. Pod refers to the application load in the K8S cluster, and Pod runs on the node. Pod consists of one or more containers that share container storage, network, and container operating configuration items. The containers in Pod are always scheduled simultaneously, with a common operating environment, where:
Master nodes are mainly responsible for management and control, including API SERVER, schedulers, controller manager, and ETCD. API SERVER is the external interface of the whole system for the clients and other components to call, which is equivalent to a business hall. Schedulers are responsible for scheduling resources within a cluster, monitoring newly created pods that are not assigned to nodes, and selecting one node for their operation, i.e., scheduling of pods. Controller manager is responsible for managing the controller, which is equivalent to a "big manifold". ETCD is a default storage system provided by K8S, all cluster data are stored, and a backup plan is required to be provided for the ETCD data when the ETCD is used;
The Node nodes are nodes which truly run the workload, the Node nodes run the Pod distributed by the Master, and when one Node is down, the Pod on the Node is automatically transferred to other Node nodes. Each Node has installed Node components including Kubelet, kube-proxy, etc. Kubelet monitors the Pod allocated to the Node, takes charge of the lifecycle management of the Pod, and simultaneously, is closely cooperated with the Master to maintain and manage all containers on the Node, thereby realizing the basic functions of cluster management. Kube-proxy is primarily responsible for providing a proxy for Pod objects.
The K8S container is clustered, and in the using process, the capacity is too small to meet the new service requirement, and at the moment, the capacity expansion of the cluster Node is the simplest and most convenient way. The original container cluster Node capacity expansion mode is to manually create resources such as a cloud host and a cloud hard disk, mount the cloud hard disk to the cloud host after the resources are successfully created, then associate the cloud host which is successfully created to the container cluster by executing script commands, and finally manually configure related parameters to realize capacity expansion of the cluster, in a series of operation processes, certain functions in the container cluster need to be suspended, if the cloud host and the cloud hard disk are failed to be created, the cloud host and the cloud hard disk need to be manually deleted, and manual intervention is needed for the operation, so that automatic capacity expansion and cleaning of legacy data resources cannot be realized.
Disclosure of Invention
Aiming at the defects in the prior art, the invention provides a capacity expansion method based on a K8S container cluster computing node, which aims to solve the problems that the capacity expansion of the K8S container cluster in the prior art needs to be completed manually, the operation is inconvenient and the efficiency is low, and meanwhile, the related functions of the container cluster need to be suspended in the capacity expansion process.
The technical scheme provided by the invention is that the capacity expansion method based on the K8S container cluster computing node comprises the following steps:
According to the capacity expansion demand information of the K8S container cluster computing node of the user, establishing an initial basic resource of the K8S container cluster while the K8S container cluster works normally;
Judging whether the initial basic resource creation of the K8S container cluster is completed or not;
When the initial basic resource of the K8S container cluster is judged to be established, controlling to automatically install the K8S container cluster and establishing residual basic resources of the K8S container cluster;
After the automatic installation of the K8S container cluster and the creation of the residual basic resources are completed, controlling the registration of the computing nodes of the K8S container cluster;
judging whether the registration of the computing node is completed, if yes, determining that the K8S container cluster is successfully expanded, otherwise, determining that the K8S container cluster is failed to be expanded;
and when the initial basic resource creation of the K8S container cluster is judged to fail, determining that the expansion of the K8S container cluster fails, and ending.
Another object of the present invention is to provide a capacity expansion system based on a K8S container cluster computing node based on a capacity expansion method based on a K8S container cluster computing node, the system comprising:
The initial basic resource creation module is used for creating initial basic resources of the K8S container cluster when the K8S container cluster works normally according to the capacity expansion demand information of the K8S container cluster calculation node of the user;
The initial basic resource creation judging module is used for judging whether the initial basic resource creation of the K8S container cluster is completed or not;
The installation control module is used for controlling automatic installation of the K8S container cluster and creating residual basic resources of the K8S container cluster when the initial basic resource of the K8S container cluster is judged to be completely created;
The computing node registration module is used for controlling the registration of computing nodes of the K8S container cluster after the automatic installation of the K8S container cluster and the creation of the residual basic resources are completed;
a computing node registration judging module for judging whether the registration of the computing node is completed;
the capacity expansion success determining module is used for determining that the K8S container cluster is successfully expanded when the computing node registration judging module judges that the registration of the computing node is completed;
And the capacity expansion failure determining module is used for determining that the K8S container cluster fails in capacity expansion when judging that the initial basic resource of the K8S container cluster fails in establishment or when the computing node registration judging module judges that the computing node fails in registration, and ending.
According to the embodiment of the invention, according to the capacity expansion demand information of a K8S container cluster computing node of a user, initial basic resources of the K8S container cluster are created while the K8S container cluster works normally, whether the initial basic resources of the K8S container cluster are created is judged to be completed, when the initial basic resources of the K8S container cluster are judged to be created, the K8S container cluster is automatically installed and residual basic resources of the K8S container cluster are controlled to be created, when the automatic installation of the K8S container cluster and the creation of the residual basic resources are completed, the computing node registration of the K8S container cluster is controlled to be carried out, whether the registration of the computing node is completed is judged, if yes, the capacity expansion of the K8S container cluster is determined to be successful, otherwise, the capacity expansion failure of the K8S container cluster is determined, and the automatic capacity expansion of the K8S container cluster is finished is controlled to be achieved, and the K8S container cluster is not influenced, and the normal work is not convenient.
Detailed Description
Embodiments of the technical scheme of the present invention will be described in detail below with reference to the accompanying drawings. The following examples are only for the purpose of more clearly illustrating the technical aspects of the present invention, and thus are merely exemplary and are not to be construed as limiting the scope of the present invention.
Fig. 1 is a flowchart of implementation of a capacity expansion method based on a K8S container cluster computing node, which specifically includes the following steps:
In step S101, according to expansion demand information of a user' S K8S container cluster computing node, an initial basic resource of the K8S container cluster is created while the K8S container cluster is working normally;
In step S102, determining whether the initial basic resource creation of the K8S container cluster is completed, if yes, executing step S103, otherwise, executing step S07;
in step S103, when it is determined that the initial basic resource creation of the K8S container cluster is completed, controlling to automatically install the K8S container cluster and create the remaining basic resources of the K8S container cluster;
in step S104, after the automatic installation of the K8S container cluster and the creation of the remaining basic resources are completed, controlling the registration of the computing nodes of the K8S container cluster;
In step S105, it is determined whether the registration of the computing node is completed, if yes, step S106 is performed, otherwise step S107 is performed;
in step S106, when it is determined that the registration of the computing node is completed, it is determined that the K8S container cluster expansion is successful;
in step S107, when it is determined that the registration of the computing node fails, or when it is determined that the initial basic resource creation of the K8S container cluster fails, it is determined that the K8S container cluster fails in expansion, and ends.
In this embodiment, on the premise that the normal operation of the K8S container cluster is not affected, the capacity expansion of the container cluster computing nodes is automatically completed, so that the method is convenient and fast, and the number of the expanded computing nodes can be carried out according to actual requirements, which is not described herein.
In the embodiment of the present invention, the following steps are further required to be performed before the step S101 is performed:
(1) When the K8S container cluster is built, receiving the capacity expansion requirement of the K8S container cluster computing node input by a user, wherein the action of receiving the capacity expansion requirement of the K8S container cluster computing node input by the user is realized through middleware Cetus of a relational database, the middleware Cetus of the relational database is built in an open-source cloud computing management platform project OpenStack, cetus is the middleware of a relational database MySQL developed by a C language, and a comprehensive database access proxy function is mainly provided. The Cetus connection mode is basically compatible with MySQL, an application program can access the database through the Cetus with little modification, horizontal expansion and high availability of a database layer are achieved, and OpenStack provides extensible and elastic cloud computing services for private cloud and public cloud. The project aims to provide a cloud computing management platform which is simple to implement, can be expanded in a large scale, is rich and has unified standards;
(2) Analyzing the capacity expansion demand of the K8S container cluster computing node input by the user to obtain capacity expansion demand information of the K8S container cluster computing node;
(3) Calling an arrangement service component interface Heat according to capacity expansion demand information of a K8S container cluster computing node, wherein the arrangement service component interface Heat is used for creating initial basic resources of the K8S container cluster, and the initial basic resources of the K8S container cluster comprise a cloud host, a security group and a cloud hard disk;
The step of calling the orchestration service component interface Heat is implemented through middleware cetus of the relational database.
In the embodiment of the invention, as shown in the scheme of fig. 1, when the initial basic resource creation of the K8S container cluster is judged to fail, or when the registration of the computing node is judged to fail, the arrangement service component interface Heat is called to automatically delete the basic resource which is already created, and the created basic resource is automatically deleted, so that the left garbage resource is not generated, and the normal work of the K8S container cluster is not influenced.
In the embodiment of the invention, while the capacity expansion of the computing node is performed, the K8S container cluster is in a normal working state, wherein the cluster state of the K8S container cluster can be set as follows so as to clearly know the current state:
changing the cluster state of the K8S container cluster from available to available and expanding while executing the step of creating the initial basic resource of the K8S container cluster;
When the initial basic resource creation failure of the K8S container cluster is judged, or the registration failure of the computing node is judged, calling an arrangement service component interface Heat to automatically delete the basic resource which is already created, and changing the cluster state of the K8S container cluster from available to available and expansion failure;
And when the capacity expansion of the K8S container cluster is determined to be successful, changing the cluster state of the K8S container cluster from available to available in capacity expansion, and the capacity expansion is successful.
In the embodiment of the invention, the capacity of the container cluster Node is expanded under the condition that the external service of the cluster is not influenced. And because of external factors such as network, host memory and the like, when the cluster expansion fails, cetus and Heat related interfaces are automatically called, the automatic deletion of initial basic resources such as created cloud hosts, cloud hard disks, security groups and the like is realized, and no legacy garbage resources are generated.
Fig. 2 is a block diagram of a capacity expansion system based on a K8S container cluster computing node according to the present invention, and for convenience of explanation, only a portion related to an embodiment of the present invention is shown in the figure.
The capacity expansion system based on the K8S container cluster computing node comprises:
The initial basic resource creation module 11 is configured to create initial basic resources of a K8S container cluster while the K8S container cluster is working normally according to expansion demand information of a user' S K8S container cluster computing node;
an initial basic resource creation judging module 12, configured to judge whether initial basic resource creation of the K8S container cluster is completed;
an installation control module 13, configured to control automatic installation of the K8S container cluster and creation of remaining basic resources of the K8S container cluster when it is determined that initial basic resource creation of the K8S container cluster is completed;
A computing node registration module 14, configured to control registration of computing nodes of the K8S container cluster when automatic installation of the K8S container cluster and creation of the remaining basic resources are completed;
a computing node registration judging module 15, configured to judge whether registration of the computing node is completed;
The capacity expansion success determining module 16 is configured to determine that the capacity expansion of the K8S container cluster is successful when the registration of the computing node is determined to be completed by the computing node registration determining module;
and the capacity expansion failure determining module 17 is configured to determine that the K8S container cluster fails in capacity expansion when it is determined that the K8S container cluster fails in initial basic resource creation, or when the computing node registration determining module determines that the computing node fails in registration, and end.
In this embodiment, the system further comprises:
the capacity expansion requirement receiving module 18 is configured to receive a capacity expansion requirement of a K8S container cluster computing node input by a user when the K8S container cluster is created;
The capacity expansion demand analysis module 19 is configured to analyze the capacity expansion demand of the K8S container cluster computing node input by the user, and obtain capacity expansion demand information of the K8S container cluster computing node;
The first orchestration service component interface calling module 20 is configured to call an orchestration service component interface Heat according to capacity expansion requirement information of a K8S container cluster computing node, where the orchestration service component interface Heat is configured to create an initial base resource of the K8S container cluster, and the initial base resource of the K8S container cluster includes a cloud host, a security group, and a cloud hard disk.
In an embodiment of the present invention, the system further includes:
the second orchestration service component interface calling module 21 is configured to call an orchestration service component interface Heat to automatically delete a created base resource when it is determined that the initial base resource of the K8S container cluster fails to be created, or when it is determined that the registration of the computing node fails.
In an embodiment of the present invention, as shown in fig. 2, the system further includes:
The cluster state updating module 22 is configured to synchronously update the cluster state of the K8S container cluster during the execution of the capacity expansion of the K8S container cluster computing node;
wherein, the cluster state updating module 22 specifically includes:
A first cluster state updating module 23, configured to change the cluster state of the K8S container cluster from "available" to "available" while performing the step of creating the initial base resource of the K8S container cluster, and expanding the K8S container cluster;
A second cluster state updating module 24, configured to, when it is determined that the initial basic resource of the K8S container cluster fails to be created, or when it is determined that the registration of the computing node fails, invoke an orchestration service component interface Heat to automatically delete the basic resource that has been created, change the cluster state of the K8S container cluster from "available," in expansion, and "expansion failure";
And the third cluster state updating module 25 is configured to change the cluster state of the K8S container cluster from "available" to "available" in the expansion and to successfully expand the capacity while determining that the expansion of the K8S container cluster is successful.
Under the condition that the external service of the K8S container cluster is not influenced, the capacity of the K8S container cluster is expanded, and the beneficial effects are brought:
1. the method is convenient and quick, when the capacity of the cluster cannot meet the requirement of the newly added service, the capacity of the customer can be directly expanded, the original service function is not influenced, and after the capacity expansion is finished, the new service can be directly deployed;
2. the function of one-key capacity expansion is completely realized, and even for people unfamiliar with business, successful capacity expansion of the cluster can be realized, so that time and labor are saved;
3. Controllable, can expand one or more Node nodes according to the business needs, realize the Node is controllable, save the economic cost;
4. Under the condition that the external service of the K8S container cluster is not affected, the K8S container cluster is expanded, and when the expansion failure of the cluster is caused by external factors such as a network, a host memory and the like, cetus and Heat related interfaces are automatically called, the successfully created basic resources are automatically deleted, and the legacy garbage resources are not generated.
The embodiments are only used to illustrate the technical scheme of the present invention, but not to limit the technical scheme, and although the present invention has been described in detail with reference to the foregoing embodiments, it should be understood by those skilled in the art that the technical scheme described in the foregoing embodiments may be modified or some or all technical features may be equivalently replaced, and the modification or replacement does not make the essence of the corresponding technical scheme deviate from the scope of the technical scheme of the embodiments of the present invention, and is included in the scope of the claims and the specification of the present invention.