CN115174644B - Container cluster service start-stop control method, device, equipment and storage medium - Google Patents

Container cluster service start-stop control method, device, equipment and storage medium Download PDF

Info

Publication number
CN115174644B
CN115174644B CN202210751234.4A CN202210751234A CN115174644B CN 115174644 B CN115174644 B CN 115174644B CN 202210751234 A CN202210751234 A CN 202210751234A CN 115174644 B CN115174644 B CN 115174644B
Authority
CN
China
Prior art keywords
service
pod
detection module
control
preset
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.)
Active
Application number
CN202210751234.4A
Other languages
Chinese (zh)
Other versions
CN115174644A (en
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.)
Fiberhome Telecommunication Technologies Co Ltd
Wuhan Fiberhome Technical Services Co Ltd
Original Assignee
Fiberhome Telecommunication Technologies Co Ltd
Wuhan Fiberhome Technical Services 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 Fiberhome Telecommunication Technologies Co Ltd, Wuhan Fiberhome Technical Services Co Ltd filed Critical Fiberhome Telecommunication Technologies Co Ltd
Priority to CN202210751234.4A priority Critical patent/CN115174644B/en
Publication of CN115174644A publication Critical patent/CN115174644A/en
Application granted granted Critical
Publication of CN115174644B publication Critical patent/CN115174644B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/12Protocols specially adapted for proprietary or special-purpose networking environments, e.g. medical networks, sensor networks, networks in vehicles or remote metering networks
    • H04L67/125Protocols specially adapted for proprietary or special-purpose networking environments, e.g. medical networks, sensor networks, networks in vehicles or remote metering networks involving control of end-device applications over a network

Abstract

The invention discloses a method, a device, equipment and a storage medium for controlling start and stop of container cluster service, wherein the method scans service in a pod at regular time through a service detection module to generate service state information; after the service control module receives the service health state at regular time, a control instruction is issued to the service detection module according to a preset starting sequence or a preset stopping sequence; the service detection module starts or stops the service in the same pod as the service detection module according to the control instruction, so that the software system can be started and stopped in sequence after being deployed on the pod; more flexible service control functions can be realized through the design of the control module and the detection module; the state of the pod is represented by the state of the detection module, the detection module is started quickly, the occupied resources are very small, the accuracy of judging whether the service is really available is improved, and meaningless consumption of pod resources is avoided.

Description

Container cluster service start-stop control method, device, equipment and storage medium
Technical Field
The present invention relates to the field of computer software container cluster technologies, and in particular, to a method, an apparatus, a device, and a storage medium for controlling startup and shutdown of a container cluster service.
Background
A container cluster is a system that orchestrates and manages containers; the container technology encapsulates the running environment and resources of the application by adopting the virtualization technology, so that the deployment capability of the application is greatly improved, and when the container application is wider and wider, the container cluster provides support for large-scale container arrangement and management.
Software systems that operate in a container manner are typically deployed in container clusters, such as kubernates, where each service is packaged as a separate object, such as a pod in kubernates, where the service operates in a container; the pod is scheduled and started by the cluster of containers, and once the pod is created, the containers in the pod are started; if the software system contains a plurality of services, which are distributed in different pod and have a certain sequence requirement at the time of starting, then this control manner cannot well support the requirement of starting in sequence, and in general, when the service that needs to be started first is deployed and then the next service is deployed, but the following problems still exist: 1. the service start-up completion does not represent that the service is truly initialized, and can provide service to the outside, and if other services depending on the service are started up immediately at this time, other service start-up failures can be caused; 2. some services are started with long time or problems occur in the service starting process to cause the process to hang up; then the pod will always be in the pendant state consuming system resources.
Disclosure of Invention
The invention mainly aims to provide a method, a device, equipment and a storage medium for controlling start and stop of container cluster service, and aims to solve the technical problems that in the prior art, a process is hung up due to the occurrence of problems in the process of starting the container service, service start failure is easy to occur, service start time is long, and a large amount of system resources are wasted.
In a first aspect, the present invention provides a method for controlling start-stop of a container cluster service, where the method includes the following steps:
setting a service control module in a container cluster, and setting a service detection module in a pod, wherein the service detection module independently operates in a container mode;
the service detection module scans the service in the pod at regular time to generate service state information;
the service control module receives the service state information to judge the service health state, and issues a control instruction to the service detection module according to a preset starting or stopping rule;
and the service detection module starts or stops the service which is in the same pod with the service detection module according to the control instruction.
Optionally, the service detection module scans the services in the pod at regular time to generate service status information, including:
The service detection module scans the service in the pod at regular time, and obtains an identification reflecting whether the service is currently available according to a state interface provided by the service;
and determining the service health state of each service according to the identification.
Optionally, the service control module receives the service state information to determine a service health state, and issues a control instruction to the service detection module according to a preset start or stop rule, including:
the service control module searches the starting sequence corresponding to the service health state and the service information from a preset starting sequence file to serve as a preset starting sequence, and obtains a preset stopping sequence according to a preset stopping sequence description file;
the service control module is communicated with the service detection module in each pod at regular time, receives the service health state and obtains service information in the pod where the service control module is located;
and the service control module issues a control instruction to the service detection module according to the preset starting sequence or the preset stopping sequence, and performs the starting and stopping process of the next service after the current starting and stopping service finishes the starting and stopping actions.
Optionally, the service control module communicates with the service detection module in each pod at regular time, receives the service health status and obtains service information in the pod where the service health status is located, including:
The service control module is communicated with the service detection module in each pod at regular time, and the service detection module analyzes the service description file corresponding to each service to obtain service information in the pod where the service description file is located;
and the service control module receives the service health state and the service information in each pod sent by the service detection module.
Optionally, the service detection module starts or stops a service in the same pod with the service detection module according to the control instruction, including:
when the control instruction is a starting instruction, the service detection module starts the service in the same pod with the control instruction according to the starting instruction;
and when the control instruction is a stop instruction, the service detection module stops the service which is in the same pod with the control instruction according to the stop instruction.
Optionally, after the service detection module starts or stops the service in the same pod with the service detection module according to the control instruction, the container cluster service start-stop control method further includes:
when the service control module detects that the current service starts overtime, processing according to a preset overtime control strategy, wherein the preset overtime control strategy comprises restarting the current service, destroying the pod, restarting the pod or skipping the current overtime service to start the next service;
And when the service control module detects that the service health state is unhealthy, processing according to a preset abnormal control strategy, wherein the preset abnormal control strategy comprises not processing abnormal service, restarting the abnormal service or restarting the pod where the abnormal service is located.
Optionally, the service detection module scans the service in the pod at regular time, and before generating the service status information, the container cluster service start-stop control method further includes:
the pod takes the state of the detection module as the state of the pod, and the completion of the start of the detection module indicates that the pod is in a running state.
In order to achieve the above object, the present invention further provides a container cluster service start-stop control device, where the container cluster service start-stop control device includes:
the service detection module is arranged in the pod and independently operates in a container mode and is used for scanning the service in the pod at fixed time to generate service state information;
the service control module is arranged in the container cluster and used for executing the start or stop of the service according to a preset start sequence or stop sequence, and the service state information is received by the detection module at fixed time to judge the health state of the service and send a control instruction to the service detection module in the execution process;
And the service detection module is also used for starting or stopping the service which is in the same pod with the service detection module according to the control instruction.
In order to achieve the above object, the present invention further provides a container cluster service start-stop control device, where the container cluster service start-stop control device includes: the system comprises a memory, a processor and a container cluster service start-stop control program stored on the memory and capable of running on the processor, wherein the container cluster service start-stop control program is configured to realize the steps of the container cluster service start-stop control method.
In a fourth aspect, to achieve the above object, the present invention further provides a storage medium, where a container cluster service start-stop control program is stored, where the container cluster service start-stop control program, when executed by a processor, implements the steps of the container cluster service start-stop control method as described above.
According to the container cluster service start-stop control method, the service in the pod is scanned at regular time through the service detection module, and service state information is generated; the service control module receives the service state information to judge the service health state, and issues a control instruction to the service detection module according to a preset starting or stopping rule; the service detection module starts or stops the service in the same pod with the service detection module according to the control instruction, so that the software system can be started and stopped in sequence after being deployed on the pod; more flexible service control functions can be realized through the design of the control module and the detection module; the state of the pod is represented by the state of the detection module, the detection module is started rapidly, the resource occupation is extremely small, the problem that the pod is in the filling state for a long time due to overlong service starting time is avoided, the influence on the conventional system transformation is small, the accuracy of judging whether the service is truly available is improved, meaningless consumption of the pod resource is avoided, and the speed and the efficiency of the start-stop control of the container cluster service are improved.
Drawings
FIG. 1 is a schematic diagram of a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a flowchart of a first embodiment of a method for controlling start/stop of a container cluster service according to the present invention;
FIG. 3 is a flowchart illustrating a second embodiment of a method for controlling start/stop of a container cluster service according to the present invention;
FIG. 4 is a flowchart illustrating a third embodiment of a method for controlling start/stop of a container cluster service according to the present invention;
FIG. 5 is a flowchart illustrating a fourth embodiment of a method for controlling start/stop of a container cluster service according to the present invention;
FIG. 6 is a flowchart of a fifth embodiment of a method for controlling start/stop of a container cluster service according to the present invention;
FIG. 7 is a flowchart of a sixth embodiment of a method for controlling start-stop of a container cluster service according to the present invention;
FIG. 8 is a functional block diagram of a first embodiment of a container cluster service start-stop control device according to the present invention.
The achievement of the objects, functional features and advantages of the present invention will be further described with reference to the accompanying drawings, in conjunction with the embodiments.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
The solution of the embodiment of the invention mainly comprises the following steps: the service detection module scans the service in the pod at regular time to generate service state information; the service control module receives the service state information to judge the service health state, and issues a control instruction to the service detection module according to a preset starting or stopping rule; the service detection module starts or stops the service in the same pod with the service detection module according to the control instruction, so that the software system can be started and stopped in sequence after being deployed on the pod; more flexible service control functions can be realized through the design of the control module and the detection module; the state of the pod is represented by the state of the detection module, the detection module is started rapidly, the resource occupation is extremely small, the problem that the pod is in the filling state for a long time due to overlong service starting time is avoided, the influence on the conventional system transformation is small, the accuracy of judging whether the service is truly available is improved, meaningless consumption of the pod resource is avoided, the speed and the efficiency of the start-stop control of the container cluster service are improved, the technical problems that the process is hung due to the problem in the container service starting process in the prior art, the service starting failure is easy to be caused, the service starting time is long, and a large amount of system resources are wasted are solved.
Referring to fig. 1, fig. 1 is a schematic device structure diagram of a hardware running environment according to an embodiment of the present invention.
As shown in fig. 1, the apparatus may include: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein the communication bus 1002 is used to enable connected communication between these components. The user interface 1003 may include a Display, an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may further include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., wi-Fi interface). The Memory 1005 may be a high-speed RAM Memory or a stable Memory (Non-Volatile Memory), such as a disk Memory. The memory 1005 may also optionally be a storage device separate from the processor 1001 described above.
It will be appreciated by those skilled in the art that the apparatus structure shown in fig. 1 is not limiting of the apparatus and may include more or fewer components than shown, or may combine certain components, or a different arrangement of components.
As shown in fig. 1, an operating device, a network communication module, a user interface module, and a container cluster service start-stop control program may be included in a memory 1005 as one type of storage medium.
The apparatus of the present invention calls a container cluster service start-stop control program stored in the memory 1005 through the processor 1001, and performs the following operations:
setting a service control module in a container cluster, and setting a service detection module in a pod, wherein the service detection module independently operates in a container mode;
the service detection module scans the service in the pod at regular time to generate service state information;
the service control module receives the service state information to judge the service health state, and issues a control instruction to the service detection module according to a preset starting or stopping rule;
and the service detection module starts or stops the service which is in the same pod with the service detection module according to the control instruction.
The device of the present invention invokes the container cluster service start-stop control program stored in the memory 1005 through the processor 1001, and also performs the following operations:
the service detection module scans the service in the pod at regular time, and obtains an identification reflecting whether the service is currently available according to a state interface provided by the service;
and determining the service health state of each service according to the identification.
The device of the present invention invokes the container cluster service start-stop control program stored in the memory 1005 through the processor 1001, and also performs the following operations:
The service control module searches the starting sequence corresponding to the service health state and the service information from a preset starting sequence file to serve as a preset starting sequence, and obtains a preset stopping sequence according to a preset stopping sequence description file;
the service control module is communicated with the service detection module in each pod at regular time, receives the service health state and obtains service information in the pod where the service control module is located;
and the service control module issues a control instruction to the service detection module according to the preset starting sequence or the preset stopping sequence, and performs the starting and stopping process of the next service after the current starting and stopping service finishes the starting and stopping actions.
The device of the present invention invokes the container cluster service start-stop control program stored in the memory 1005 through the processor 1001, and also performs the following operations:
the service control module is communicated with the service detection module in each pod at regular time, and the service detection module analyzes the service description file corresponding to each service to obtain service information in the pod where the service description file is located;
and the service control module receives the service health state and the service information in each pod sent by the service detection module.
The device of the present invention invokes the container cluster service start-stop control program stored in the memory 1005 through the processor 1001, and also performs the following operations:
When the control instruction is a starting instruction, the service detection module starts the service in the same pod with the control instruction according to the starting instruction;
and when the control instruction is a stop instruction, the service detection module stops the service which is in the same pod with the control instruction according to the stop instruction.
The device of the present invention invokes the container cluster service start-stop control program stored in the memory 1005 through the processor 1001, and also performs the following operations:
when the service control module detects that the current service starts overtime, processing according to a preset overtime control strategy, wherein the preset overtime control strategy comprises restarting the current service, destroying the pod, restarting the pod or skipping the current overtime service to start the next service;
and when the service control module detects that the service health state is unhealthy, processing according to a preset abnormal control strategy, wherein the preset abnormal control strategy comprises not processing abnormal service, restarting the abnormal service or restarting the pod where the abnormal service is located.
The device of the present invention invokes the container cluster service start-stop control program stored in the memory 1005 through the processor 1001, and also performs the following operations:
the pod takes the state of the detection module as the state of the pod, and the completion of the start of the detection module indicates that the pod is in a running state.
According to the scheme, the service detection module scans the service in the pod at regular time to generate service state information; the service control module receives the service state information to judge the service health state, and issues a control instruction to the service detection module according to a preset starting or stopping rule; the service detection module starts or stops the service in the same pod with the service detection module according to the control instruction, so that the software system can be started and stopped in sequence after being deployed on the pod; more flexible service control functions can be realized through the design of the control module and the detection module; the state of the pod is represented by the state of the detection module, the detection module is started rapidly, the resource occupation is extremely small, the problem that the pod is in the filling state for a long time due to overlong service starting time is avoided, the influence on the conventional system transformation is small, the accuracy of judging whether the service is truly available is improved, meaningless consumption of the pod resource is avoided, and the speed and the efficiency of the start-stop control of the container cluster service are improved.
Based on the hardware structure, the embodiment of the container cluster service start-stop control method is provided.
Referring to fig. 2, fig. 2 is a flowchart illustrating a first embodiment of a method for controlling start-stop of a container cluster service according to the present invention.
In a first embodiment, the container cluster service start-stop control method includes the following steps:
step S10, setting a service control module in the container cluster, and setting a service detection module in the pod, wherein the service detection module independently operates in a container mode.
It can be understood that a service control module and a service detection module are required to be set before the start-stop control of the container cluster service is performed, the service control module is generally set in the container cluster, the service detection module is set in the pod, and the service detection module independently operates in a container mode; the detection module is deployed in the pod of each service and independently operates in a container mode, the pod takes the state of the detection module as the state of the pod, and the completion of the start of the detection module indicates that the pod is in a running state.
And step S20, the service detection module scans the service in the pod at regular time to generate service state information.
It should be noted that, the service detection module is a module for scanning and detecting the service in the pod, and the service detection module can be used for scanning the service in the pod at regular time, so as to obtain the self health status of the service, and of course, the service in the pod can also be scanned in real time, which is not limited in this embodiment.
And step S30, the service control module receives the service state information to judge the service health state, and issues a control instruction to the service detection module according to a preset starting or stopping rule.
It can be understood that the service detection module can periodically acquire the service state after starting the service and report the service state to the service control module, and the service control module is used for controlling the service detection module, and after the service control module receives the service health state at regular time, the service control module can issue a corresponding control instruction to the service detection module according to a preset starting sequence or stopping sequence.
And step S40, the service detection module starts or stops the service in the same pod with the service detection module according to the control instruction.
It should be understood that the service detection module may start or stop a service in the same pod as it is according to the control instructions; the embodiment can realize the starting and stopping of the service in sequence after the software system is deployed on the pod; more flexible service control functions can be realized through the design of the control module and the detection module; the state of the pod is represented by the state of the detection module, the detection module is started rapidly and the resource occupation is very little, so that the problem that the pod is in the pendant state for a long time due to the overlong service starting time is avoided; the condition that a service process is hung up is processed by introducing a timeout mechanism into the pod through the control module, so that meaningless consumption of pod resources is avoided; the method has little influence on the transformation of the existing system, and even if the health check interface of the existing system service does not support the check mechanism of the pod, the method does not need to be modified.
According to the scheme, the service detection module scans the service in the pod at regular time to generate service state information; the service control module receives the service state information to judge the service health state, and issues a control instruction to the service detection module according to a preset starting or stopping rule; the service detection module starts or stops the service in the same pod with the service detection module according to the control instruction, so that the software system can be started and stopped in sequence after being deployed on the pod; more flexible service control functions can be realized through the design of the control module and the detection module; the state of the pod is represented by the state of the detection module, the detection module is started rapidly, the resource occupation is extremely small, the problem that the pod is in the filling state for a long time due to overlong service starting time is avoided, the influence on the conventional system transformation is small, the accuracy of judging whether the service is truly available is improved, meaningless consumption of the pod resource is avoided, and the speed and the efficiency of the start-stop control of the container cluster service are improved.
Further, fig. 3 is a flow chart of a second embodiment of the container cluster service start-stop control method of the present invention, as shown in fig. 3, according to the second embodiment of the present invention, the step S20 specifically includes the following steps:
And S21, the service detection module scans the service in the pod at regular time, and obtains an identification reflecting whether the service is currently available according to the state interface provided by the service.
It should be noted that, the service detection module scans the service in the pod at regular time, and an interface for indicating the health status of the service can be provided externally according to the service, that is, the status interface obtains an identifier reflecting whether the service is currently available.
And S22, determining the service health state of each service according to the identification.
It will be appreciated that the service provides an interface to the outside that represents the health status of itself, which is an accurate indication that reflects whether the service is currently available, from which the health status of each service can be determined.
According to the scheme, the service detection module scans the service in the pod at regular time, and the identification reflecting whether the service is available currently is obtained according to the state interface provided by the service; and determining the service health state of each service according to the identification, so that service state information can be accurately generated, the accuracy of judging whether the service is truly available is improved, and meaningless consumption of pod resources is avoided.
Further, fig. 4 is a flow chart of a third embodiment of the container cluster service start-stop control method according to the present invention, as shown in fig. 4, and the third embodiment of the container cluster service start-stop control method according to the present invention is proposed based on the first embodiment, in which the step S30 specifically includes the following steps:
step S31, the service control module searches the starting sequence corresponding to the service health state and the service information from a preset starting sequence file to serve as a preset starting sequence, and obtains a preset stopping sequence according to a preset stopping sequence description file.
It can be understood that the starting sequence corresponding to the service health status and the service information can be found from the preset starting sequence file as the preset starting sequence, and the preset stopping sequence can be obtained according to the preset stopping sequence description file.
In a specific implementation, a service initiation order file may be written that lists the initiation order of services in the software system by service name.
And step S32, the service control module communicates with the service detection module in each pod at regular time, receives the service health state and obtains the service information in the pod where the service health state is located.
It should be noted that, the service control module communicates with the service detection module in each pod at regular time, and the service control module is deployed in the pod separately and communicates with the detection module in each pod in the software system, so as to obtain service information in the pod, for example: service name, etc.
Further, the step S32 specifically includes the following steps:
the service control module is communicated with the service detection module in each pod at regular time, and the service detection module analyzes the service description file corresponding to each service to obtain service information in the pod where the service description file is located;
and the service control module receives the service health state and the service information in each pod sent by the service detection module.
It should be understood that the detection module may periodically scan the services in its pod, and obtain the health status of the services through the health status interface, where the service detection module analyzes the service description file corresponding to each service to obtain the service information in the pod where it is located, where the service description file includes but is not limited to: name, path, start mode and start script path of service; and the service control module receives the service health state and the service information in each pod sent by the service detection module.
And step S33, the service control module issues a control instruction to the service detection module according to the preset starting sequence or the preset stopping sequence, and the next service starting and stopping process is performed after the current starting and stopping service finishes the starting and stopping actions.
It should be understood that respective control instructions corresponding to different start orders or stop orders are issued to the service detection module by the preset start orders or the preset stop orders.
Through the scheme, the embodiment is communicated with the service detection module in each pod at regular time through the service control module, receives the service health state and obtains the service information in the pod where the service health state is located; the service control module searches the starting sequence corresponding to the service health state and the service information from a preset starting sequence file to serve as a preset starting sequence, and obtains a preset stopping sequence according to a preset stopping sequence description file; the service control module issues control instructions to the service detection module according to the preset starting sequence or the preset stopping sequence, and performs the starting and stopping process of the next service after the current starting and stopping service finishes the starting and stopping actions, so that the corresponding control instructions can be accurately issued, and the speed and the efficiency of the container cluster service starting and stopping control are improved.
Further, fig. 5 is a flowchart of a fourth embodiment of the container cluster service start-stop control method according to the present invention, as shown in fig. 5, and the fourth embodiment of the container cluster service start-stop control method according to the present invention is proposed based on the first embodiment, in which the step S40 specifically includes the following steps:
and step S41, when the control instruction is a starting instruction, the service detection module starts the service in the same pod according to the starting instruction.
When the control instruction is a start instruction, the service in the same pod with the control instruction may be started in sequence according to the start instruction and the preset start sequence.
And step S42, when the control instruction is a stop instruction, the service detection module stops the service in the same pod with the control instruction according to the stop instruction.
It will be appreciated that when the control instruction is a stop instruction, services in the same pod as the control instruction may be stopped according to the stop instruction.
In a specific implementation, when the whole application system is stopped, a control module issues a stopping instruction to a detection module of each service according to a formulated stopping sequence, the detection module stops the service in the pod after receiving the formulation and reports the service state to the control module, and the control module stops the next service after receiving the state that the service to be stopped is stopped currently.
It should be understood that the service start-stop control system in the pod is used for converging the start and stop operations of the services scattered on different pods to one node for control, so that the requirement of controlling the service start-stop sequence in the pod system is realized; the service start-stop sequence is described through the file, so that the method is visual, good in expandability and good in compatibility; the detection of the service health state in the embodiment can improve the accuracy of judging whether the service is truly available; and a timeout mechanism for the pod inspection is introduced into the pod through an external module, so that meaningless consumption of cluster resources is avoided.
According to the scheme, when the control instruction is the starting instruction, the service detection module starts the service in the same pod according to the starting instruction; when the control instruction is a stop instruction, the service detection module stops the service in the same pod with the control instruction according to the stop instruction; nonsensical consumption of pod resources is avoided, and the speed and efficiency of start-stop control of container cluster service are improved.
Further, fig. 6 is a flowchart of a fifth embodiment of the container cluster service start-stop control method according to the present invention, as shown in fig. 6, based on the first embodiment, the fifth embodiment of the container cluster service start-stop control method according to the present invention is provided, and in this embodiment, after step S40, the container cluster service start-stop control method further includes the following steps:
And S50, when the service control module detects that the current service starts overtime, processing according to a preset overtime control strategy, wherein the preset overtime control strategy comprises restarting the current service, destroying the pod, restarting the pod or skipping the current overtime service to start the next service.
It should be noted that, the service control module may set a timeout period for service start and communicate with the pod, and when the service start times out, may select to restart the service, destroy/restart the pod, and skip the timeout service to start the next service according to the policy.
In a specific implementation, the service control module acquires the state of the service currently being started from the detection module, and only when the service state is that the starting is completed, the next service is started in sequence; the service control module can set a timeout mechanism, and when a certain service cannot reach a state of completing starting for a long time and times out, the control module can process according to a rule formulated in advance, wherein the processing options comprise: skipping the service starts the next service, restarting the pod where the service is located.
And step S60, when the service control module detects that the service health state is unhealthy, processing according to a preset abnormal control strategy, wherein the preset abnormal control strategy comprises not processing abnormal service, restarting the abnormal service or restarting a pod where the abnormal service is located.
It can be understood that when the service control module detects that the service health status is unhealthy, the service control module may perform processing according to a preset abnormal control policy, and in actual operation, if an abnormality occurs in a service in a pod when the whole application system is running, the service control module performs processing according to a rule set in advance, where the rule includes: the service is not processed, restarted, and the pod where the service is located is restarted.
In a specific implementation, the service control module periodically checks the health status of the service after all the services are started, and when the unhealthy service status is detected, a command is issued to the detection module, and the detection module receives the command to restart the service.
According to the scheme, when the service control module detects that the current service starts overtime, the current service is processed according to the preset overtime control strategy, wherein the preset overtime control strategy comprises restarting the current service, destroying the pod, restarting the pod or skipping the current overtime service to start the next service; when the service control module detects that the service health state is unhealthy, the service control module processes the service according to a preset abnormal control strategy, wherein the preset abnormal control strategy comprises not processing abnormal service, restarting the abnormal service or restarting the pod where the abnormal service is located, the state of the pod can be represented by the state of the detection module, the detection module is started quickly, the occupied resources are extremely small, the problem that the pod is in a filling state for a long time due to overlong service starting time is avoided, the influence on the transformation of the existing system is small, the accuracy of judging whether the service is truly available or not is improved, and meaningless consumption of pod resources is avoided.
Further, fig. 7 is a flowchart of a sixth embodiment of the container cluster service start-stop control method according to the present invention, as shown in fig. 7, based on the first embodiment, the container cluster service start-stop control method according to the present invention is proposed, and in this embodiment, before the step S20, the container cluster service start-stop control method includes the following steps:
and step S01, the pod takes the state of the detection module as the state of the pod, and the completion of the start of the detection module indicates that the pod is in a running state.
It should be noted that, before the service detection module operates and detects, the pod uses the state of the detection module as its own state, and the detection module is started up to complete, that is, the pod is in a running state.
It can be understood that the detection module is deployed in the pod of each service, the service detection modules independently operate in a container mode, the pod takes the state of the service detection module as its own state, and the completion of the service detection module start indicates that the pod is in a running state.
In a specific implementation, taking a Kubernatespod management system as an example, when an application system needs to be deployed in Kubernates in a container form, each service of the application system is deployed separately, and each service is operated in one pod of a Kubernates cluster separately; developing an application program as a detection module, deploying with each service, starting in the same pod, taking the application program as a door-to-door process of the pod, and taking the process state of the application program as the state of the pod; developing an application program as a control module, wherein the application is deployed independently and needs to be started before all services of an application system are started, and reading a description file of the service starting sequence after the control module is started, wherein the file describes the starting sequence of each service in the application system; the control module needs to be declared as a Service in the pod, and the pod has a domain name; after the detection module is started, reading a declaration file of the service from the pod of the detection module, acquiring information such as a service name, a starting mode, a starting script, a stopping script and the like, reporting the service name to the control module, and reporting the information to the control module by the detection module through a domain name; after all the pod of the application system are started, the control module can acquire information of all the services of the application system, and a starting sequence list is arranged according to the service names and the description files of the starting sequence; the control module clearly sends a starting instruction to the detection module in each pod according to the starting sequence; and after receiving the starting instruction, the detection module starts the service which is in the same pod with the detection module according to the acquired starting mode and the acquired starting script.
According to the scheme, the service detection module is deployed in the pod of each service in the pod, the pod takes the state of the detection module as the state of the pod, and the detection module is started to be completed, namely the pod is in a running state, so that the service detection module can be independently operated in a container mode, and the speed and the efficiency of container cluster service start-stop control are improved.
Correspondingly, the invention further provides a container cluster service start-stop control device.
Referring to fig. 8, fig. 8 is a functional block diagram of a first embodiment of a container cluster service start-stop control device according to the present invention.
In a first embodiment of the container cluster service start-stop control device of the present invention, the container cluster service start-stop control device includes:
the service detection module 10 is arranged in the pod, and independently operates in a container mode and is used for scanning the service in the pod at fixed time to generate service state information;
the service control module 20 is disposed in the container cluster, and is configured to execute starting or stopping of a service according to a preset starting sequence or stopping sequence, and in the executing process, the detection module receives service state information at regular time to determine a service health state and issue a control instruction to the service detection module;
The service detection module 10 is further configured to start or stop a service in the same pod as the service detection module according to the control instruction.
The service detection module 10 is further configured to scan the service in the pod at regular time, and obtain an identifier reflecting whether the service is currently available according to a status interface provided by the service; and determining the service health state of each service according to the identification.
The service control module 20 is further configured to find a starting sequence corresponding to the service health status and the service information from a preset starting sequence file as a preset starting sequence, and obtain a preset stopping sequence according to a preset stopping sequence description file; the service control module is communicated with the service detection module in each pod at regular time, receives the service health state and obtains service information in the pod where the service control module is located; and the service control module issues a control instruction to the service detection module according to the preset starting sequence or the preset stopping sequence, and performs the starting and stopping process of the next service after the current starting and stopping service finishes the starting and stopping actions.
The service control module 20 is further configured to communicate with a service detection module in each pod at regular time, where the service detection module analyzes a service description file corresponding to each service to obtain service information in the pod where the service description file is located; and the service control module receives the service health state and the service information in each pod sent by the service detection module.
The service detection module 10 is further configured to, when the control instruction is a start instruction, start a service in the same pod with the control instruction according to the start instruction; and when the control instruction is a stop instruction, the service detection module stops the service which is in the same pod with the control instruction according to the stop instruction.
The service detection module 10 is further configured to process according to a preset timeout control policy when detecting that a current service starts timeout, where the preset timeout control policy includes restarting the current service, destroying a pod, restarting a pod, or skipping the current timeout service to start a next service; and when the service control module detects that the service health state is unhealthy, processing according to a preset abnormal control strategy, wherein the preset abnormal control strategy comprises not processing abnormal service, restarting the abnormal service or restarting the pod where the abnormal service is located.
The service detection module 10 is further configured to deploy a service detection module in a pod of each service in the pod, where the pod uses a state of the detection module as its own state, and the detection module is started to complete, that is, the pod is in a running state.
The steps of implementing each functional module of the container cluster service start-stop control device can refer to each embodiment of the container cluster service start-stop control method of the present invention, and are not repeated herein.
In addition, the embodiment of the invention also provides a storage medium, wherein the storage medium is stored with a container cluster service start-stop control program, and the container cluster service start-stop control program realizes the following operations when being executed by a processor:
setting a service control module in a container cluster, and setting a service detection module in a pod, wherein the service detection module independently operates in a container mode;
the service detection module scans the service in the pod at regular time to generate service state information;
the service control module receives the service state information to judge the service health state, and issues a control instruction to the service detection module according to a preset starting or stopping rule;
and the service detection module starts or stops the service which is in the same pod with the service detection module according to the control instruction.
Further, the container cluster service start-stop control program, when executed by the processor, further performs the following operations:
the service detection module scans the service in the pod at regular time, and obtains an identification reflecting whether the service is currently available according to a state interface provided by the service;
And determining the service health state of each service according to the identification.
Further, the container cluster service start-stop control program, when executed by the processor, further performs the following operations:
the service control module searches the starting sequence corresponding to the service health state and the service information from a preset starting sequence file to serve as a preset starting sequence, and obtains a preset stopping sequence according to a preset stopping sequence description file;
the service control module is communicated with the service detection module in each pod at regular time, receives the service health state and obtains service information in the pod where the service control module is located;
and the service control module issues a control instruction to the service detection module according to the preset starting sequence or the preset stopping sequence, and performs the starting and stopping process of the next service after the current starting and stopping service finishes the starting and stopping actions.
Further, the container cluster service start-stop control program, when executed by the processor, further performs the following operations:
the service control module is communicated with the service detection module in each pod at regular time, and the service detection module analyzes the service description file corresponding to each service to obtain service information in the pod where the service description file is located;
And the service control module receives the service health state and the service information in each pod sent by the service detection module.
Further, the container cluster service start-stop control program, when executed by the processor, further performs the following operations:
when the control instruction is a starting instruction, the service detection module starts the service in the same pod with the control instruction according to the starting instruction;
and when the control instruction is a stop instruction, the service detection module stops the service which is in the same pod with the control instruction according to the stop instruction.
Further, the container cluster service start-stop control program, when executed by the processor, further performs the following operations:
when the service control module detects that the current service starts overtime, processing according to a preset overtime control strategy, wherein the preset overtime control strategy comprises restarting the current service, destroying the pod, restarting the pod or skipping the current overtime service to start the next service;
and when the service control module detects that the service health state is unhealthy, processing according to a preset abnormal control strategy, wherein the preset abnormal control strategy comprises not processing abnormal service, restarting the abnormal service or restarting the pod where the abnormal service is located.
Further, the container cluster service start-stop control program, when executed by the processor, further performs the following operations:
the pod takes the state of the detection module as the state of the pod, and the completion of the start of the detection module indicates that the pod is in a running state.
According to the scheme, the service detection module scans the service in the pod at regular time to generate service state information; the service control module receives the service state information to judge the service health state, and issues a control instruction to the service detection module according to a preset starting or stopping rule; the service detection module starts or stops the service in the same pod with the service detection module according to the control instruction, so that the software system can be started and stopped in sequence after being deployed on the pod; more flexible service control functions can be realized through the design of the control module and the detection module; the state of the pod is represented by the state of the detection module, the detection module is started rapidly, the resource occupation is extremely small, the problem that the pod is in the filling state for a long time due to overlong service starting time is avoided, the influence on the conventional system transformation is small, the accuracy of judging whether the service is truly available is improved, meaningless consumption of the pod resource is avoided, and the speed and the efficiency of the start-stop control of the container cluster service are improved.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
The foregoing description is only of the preferred embodiments of the present invention, and is not intended to limit the scope of the invention, but rather is intended to cover any equivalents of the structures or equivalent processes disclosed herein or in the alternative, which may be employed directly or indirectly in other related arts.

Claims (9)

1. The container cluster service start-stop control method is characterized by comprising the following steps of:
Setting a service control module in a container cluster, and setting a service detection module in a pod, wherein the service detection module independently operates in a container mode;
the service detection module scans the service in the pod at regular time to generate service state information;
the service control module receives the service state information to judge the service health state, and issues a control instruction to the service detection module according to a preset starting or stopping rule;
the service detection module starts or stops the service in the same pod with the service detection module according to the control instruction;
the service control module receives the service state information to judge the service health state, and issues a control instruction to the service detection module according to a preset starting or stopping rule, and the method comprises the following steps:
the service control module searches the starting sequence corresponding to the service health state and the service information from a preset starting sequence file to serve as a preset starting sequence, and obtains a preset stopping sequence according to a preset stopping sequence description file;
the service control module is communicated with the service detection module in each pod at regular time, receives the service health state and obtains service information in the pod where the service control module is located;
And the service control module issues a control instruction to the service detection module according to the preset starting sequence or the preset stopping sequence, and performs the starting and stopping process of the next service after the current starting and stopping service finishes the starting and stopping actions.
2. The container cluster service start-stop control method of claim 1, wherein the service detection module scans services in the pod at regular time intervals to generate service status information, comprising:
the service detection module scans the service in the pod at regular time, and obtains an identification reflecting whether the service is currently available according to a state interface provided by the service;
and determining the service health state of each service according to the identification.
3. The container cluster service start-stop control method of claim 1, wherein the service control module periodically communicates with a service detection module in each pod, receives the service health status and obtains service information in the pod in which it is located, comprising:
the service control module is communicated with the service detection module in each pod at regular time, and the service detection module analyzes the service description file corresponding to each service to obtain service information in the pod where the service description file is located;
And the service control module receives the service health state and the service information in each pod sent by the service detection module.
4. The container cluster service start-stop control method of claim 1, wherein the service detection module starts or stops a service in the same pod as the service detection module according to the control instruction, comprising:
when the control instruction is a starting instruction, the service detection module starts the service in the same pod with the control instruction according to the starting instruction;
and when the control instruction is a stop instruction, the service detection module stops the service which is in the same pod with the control instruction according to the stop instruction.
5. The container cluster service start-stop control method according to any one of claims 1 to 4, wherein after the service detection module starts or stops a service in the same pod as it according to the control instruction, the container cluster service start-stop control method further comprises:
when the service control module detects that the current service starts overtime, processing according to a preset overtime control strategy, wherein the preset overtime control strategy comprises restarting the current service, destroying the pod, restarting the pod or skipping the current overtime service to start the next service;
And when the service control module detects that the service health state is unhealthy, processing according to a preset abnormal control strategy, wherein the preset abnormal control strategy comprises not processing abnormal service, restarting the abnormal service or restarting the pod where the abnormal service is located.
6. The container cluster service start-stop control method according to any one of claims 1-4, wherein the service detection module scans services in the pod at regular time, and before generating service status information, the container cluster service start-stop control method further comprises:
the pod takes the state of the detection module as the state of the pod, and the completion of the start of the detection module indicates that the pod is in a running state.
7. A container cluster service start-stop control device, characterized in that the container cluster service start-stop control device comprises:
the service detection module is arranged in the pod and independently operates in a container mode and is used for scanning the service in the pod at fixed time to generate service state information;
the service control module is arranged in the container cluster and used for executing the start or stop of the service according to a preset start sequence or stop sequence, and the service state information is received by the detection module at fixed time to judge the health state of the service and send a control instruction to the service detection module in the execution process;
The service detection module is also used for starting or stopping the service in the same pod with the service detection module according to the control instruction;
the service control module is further used for searching a starting sequence corresponding to the service health state and the service information from a preset starting sequence file as a preset starting sequence, and obtaining a preset stopping sequence according to a preset stopping sequence description file; the method comprises the steps of regularly communicating with a service detection module in each pod, receiving the service health state and obtaining service information in the pod where the service health state is located; and issuing a control instruction to the service detection module according to the preset starting sequence or the preset stopping sequence, and performing the starting and stopping process of the next service after the current starting and stopping service finishes the starting and stopping actions.
8. A container cluster service start-stop control apparatus, the container cluster service start-stop control apparatus comprising: a memory, a processor and a container cluster service start-stop control program stored on the memory and executable on the processor, the container cluster service start-stop control program configured to implement the steps of the container cluster service start-stop control method of any one of claims 1 to 6.
9. A storage medium, wherein a container cluster service start-stop control program is stored on the storage medium, and the container cluster service start-stop control program, when executed by a processor, implements the steps of the container cluster service start-stop control method according to any one of claims 1 to 6.
CN202210751234.4A 2022-06-28 2022-06-28 Container cluster service start-stop control method, device, equipment and storage medium Active CN115174644B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210751234.4A CN115174644B (en) 2022-06-28 2022-06-28 Container cluster service start-stop control method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210751234.4A CN115174644B (en) 2022-06-28 2022-06-28 Container cluster service start-stop control method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN115174644A CN115174644A (en) 2022-10-11
CN115174644B true CN115174644B (en) 2023-09-12

Family

ID=83489666

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210751234.4A Active CN115174644B (en) 2022-06-28 2022-06-28 Container cluster service start-stop control method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115174644B (en)

Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102609324A (en) * 2012-01-09 2012-07-25 华为技术有限公司 Method, device and system for restoring deadlock of virtual machine
CN104657150A (en) * 2015-03-13 2015-05-27 浪潮集团有限公司 Automatic operation and maintenance method under cluster environment
CN106227524A (en) * 2016-07-18 2016-12-14 北京妙医佳信息技术有限公司 A kind of PaaS platform framework for health control and its implementation
CN107395735A (en) * 2017-08-03 2017-11-24 成都精灵云科技有限公司 The delay capacity reducing dispatching method and system of a kind of container cluster
CN108737215A (en) * 2018-05-29 2018-11-02 郑州云海信息技术有限公司 A kind of method and apparatus of cloud data center Kubernetes clusters container health examination
CN109032806A (en) * 2018-07-30 2018-12-18 华为技术有限公司 The service scheduling method and device of container
CN110798375A (en) * 2019-09-29 2020-02-14 烽火通信科技股份有限公司 Monitoring method, system and terminal equipment for enhancing high availability of container cluster
CN111371696A (en) * 2020-03-24 2020-07-03 广西梯度科技有限公司 Method for realizing Pod network flow control in Kubernetes
CN111427944A (en) * 2020-03-27 2020-07-17 中核武汉核电运行技术股份有限公司 Micro-service architecture and method of nuclear power industry Internet platform
CN111522622A (en) * 2020-04-14 2020-08-11 上海仪电(集团)有限公司中央研究院 K8S quick starting method based on cloud platform
CN112486629A (en) * 2020-11-27 2021-03-12 成都新希望金融信息有限公司 Micro-service state detection method and device, electronic equipment and storage medium
CN113626044A (en) * 2021-08-13 2021-11-09 中国工商银行股份有限公司 Service management method and device
CN113918407A (en) * 2021-09-03 2022-01-11 北京天融信网络安全技术有限公司 Method and device for managing service process and readable storage medium
CN113965576A (en) * 2021-11-19 2022-01-21 湖南快乐阳光互动娱乐传媒有限公司 Container-based big data acquisition method and device, storage medium and equipment
CN114064208A (en) * 2021-11-10 2022-02-18 北京百度网讯科技有限公司 Method and device for detecting application service state, electronic equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11175939B2 (en) * 2019-05-09 2021-11-16 International Business Machines Corporation Dynamically changing containerized workload isolation in response to detection of a triggering factor
US20220091572A1 (en) * 2020-09-22 2022-03-24 Rockwell Automation Technologies, Inc. Integrating container orchestration systems with operational technology devices

Patent Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102609324A (en) * 2012-01-09 2012-07-25 华为技术有限公司 Method, device and system for restoring deadlock of virtual machine
CN104657150A (en) * 2015-03-13 2015-05-27 浪潮集团有限公司 Automatic operation and maintenance method under cluster environment
CN106227524A (en) * 2016-07-18 2016-12-14 北京妙医佳信息技术有限公司 A kind of PaaS platform framework for health control and its implementation
CN107395735A (en) * 2017-08-03 2017-11-24 成都精灵云科技有限公司 The delay capacity reducing dispatching method and system of a kind of container cluster
CN108737215A (en) * 2018-05-29 2018-11-02 郑州云海信息技术有限公司 A kind of method and apparatus of cloud data center Kubernetes clusters container health examination
CN109032806A (en) * 2018-07-30 2018-12-18 华为技术有限公司 The service scheduling method and device of container
CN110798375A (en) * 2019-09-29 2020-02-14 烽火通信科技股份有限公司 Monitoring method, system and terminal equipment for enhancing high availability of container cluster
CN111371696A (en) * 2020-03-24 2020-07-03 广西梯度科技有限公司 Method for realizing Pod network flow control in Kubernetes
CN111427944A (en) * 2020-03-27 2020-07-17 中核武汉核电运行技术股份有限公司 Micro-service architecture and method of nuclear power industry Internet platform
CN111522622A (en) * 2020-04-14 2020-08-11 上海仪电(集团)有限公司中央研究院 K8S quick starting method based on cloud platform
CN112486629A (en) * 2020-11-27 2021-03-12 成都新希望金融信息有限公司 Micro-service state detection method and device, electronic equipment and storage medium
CN113626044A (en) * 2021-08-13 2021-11-09 中国工商银行股份有限公司 Service management method and device
CN113918407A (en) * 2021-09-03 2022-01-11 北京天融信网络安全技术有限公司 Method and device for managing service process and readable storage medium
CN114064208A (en) * 2021-11-10 2022-02-18 北京百度网讯科技有限公司 Method and device for detecting application service state, electronic equipment and storage medium
CN113965576A (en) * 2021-11-19 2022-01-21 湖南快乐阳光互动娱乐传媒有限公司 Container-based big data acquisition method and device, storage medium and equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于作战任务优先级的容器云弹性伸缩系统;尚小东;张煜;郭成昊;;指挥信息系统与技术(03);全文 *

Also Published As

Publication number Publication date
CN115174644A (en) 2022-10-11

Similar Documents

Publication Publication Date Title
US7020797B2 (en) Automated software testing management system
US9274776B2 (en) Product, method, and apparatus for installing a second program based on a call from a first program
CN102289398A (en) Restart testing method
US20080184079A1 (en) Tracking down elusive intermittent failures
CN111324423B (en) Method and device for monitoring processes in container, storage medium and computer equipment
CN108763089B (en) Test method, device and system
CN107678948B (en) Test case generation method, terminal and storage medium
CN113254331A (en) Model test method, device, storage medium and program product
CN110650138A (en) Server management method, device, equipment and computer readable storage medium
CN103064705B (en) Computer system starting processing method and device
CN115174644B (en) Container cluster service start-stop control method, device, equipment and storage medium
CN110569140A (en) operation and maintenance method and device
CN111506388B (en) Container performance detection method, container management platform and computer storage medium
CN101706752B (en) Method and device for in-situ software error positioning
WO2014136228A1 (en) Programmable controller, programmable controller system, and execute error information creation method
US7363615B2 (en) Stack-based callbacks for diagnostic data generation
CN114791884A (en) Test environment construction method and device, storage medium and electronic equipment
US8667335B2 (en) Information processing apparatus and method for acquiring information for hung-up cause investigation
CN106161050B (en) Problem resource indicating device and problem resource indicating method
CN113010422A (en) Mirror image file testing method and device, electronic equipment and readable storage medium
CN110535717B (en) Container detection method and device
US10977146B2 (en) Application operation monitoring apparatus and application operation monitoring method
CN111581042B (en) Cluster deployment method, deployment platform and server to be deployed
CN113176913B (en) Processing method and device of JAVA agent, terminal equipment and storage medium
CN117707609B (en) Method and device for managing script tasks based on container arrangement management tool

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
GR01 Patent grant
GR01 Patent grant