Container group protection method and device in container cluster
By monitoring and rejecting inconsistent interruption instructions, the problem of unstable Pod replica numbers in the Kubernetes cluster is solved, container group protection is implemented in active interruption scenarios, and project stability and SLA are ensured.
Patent Information
- Application Number
- CN202110499084.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-08
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2041-05-08
AI Technical Summary
In a Kubernetes cluster, existing technology cannot effectively ensure that the number of Pod copies remains at the expected value at any time, resulting in possible project interruption or SLA degradation in active interruption scenarios.
By monitoring the running status of each container group in the container cluster, determining the cluster status value based on the running status and the expected status, and rejecting interrupt instructions when the status is inconsistent with the expected status, the container group protection is achieved.
It effectively prevents a large number of Pods from being unavailable in active interruption scenarios, maintains the stability of the project, avoids project interruption and SLA degradation, and improves user experience.
Smart Images

Figure CN113297031B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and more particularly to a container group protection method in a container cluster. The present invention also relates to a container group protection device in a container cluster, a computing device, and a computer-readable storage medium. Background Art
[0002] With the development of computer technology, the concept of cloud native has also become popular. Docker (a container technology in Linux) and Kubernetes (an orchestration management system for container groups, referred to as k88s) have been widely used in the cloud computing platforms of major companies.
[0003] A container group (Pod) is the smallest unit managed in a Kubernetes cluster. It is a combination of one or more containers. In a Kubernetes cluster, in order to ensure the high availability of Pods, powerful workloads are often used to define and manage the number of application Pod copies. However, workloads can only help the number of application Pod copies reach the expected value as quickly as possible, and cannot guarantee that the number of available Pod copies at any time remains at the expected value. For example, in voluntary disruption scenarios (active disruption scenarios), there are still cases of project interruption or SLA (service level agreement) degradation. Therefore, a convenient and practical protection method is needed to solve the problem of large-scale unavailability of Pods in voluntary disruption scenarios, which in turn causes project interruption or SLA degradation. Summary of the invention
[0004] In view of this, an embodiment of the present specification provides a container group protection method in a container cluster. The present specification also relates to a container group protection device in a container cluster, a computing device, and a computer-readable storage medium to solve the technical defects existing in the prior art.
[0005] According to a first aspect of an embodiment of this specification, a method for protecting a container group in a container cluster is provided, including:
[0006] Monitor the running status of each container group in the container cluster;
[0007] Determine a cluster state value of the container cluster based on the running state of each container group and the expected state of the container cluster;
[0008] receiving an interrupt instruction for a first target container group;
[0009] When the cluster state value is inconsistent with the expected state, the interrupt instruction is rejected.
[0010] According to a second aspect of an embodiment of this specification, a container group protection device in a container cluster is provided, including:
[0011] A monitoring module is configured to monitor the running status of each container group in the container cluster;
[0012] A determination module is configured to determine a cluster state value of the container cluster based on the running state of each container group and the expected state of the container cluster;
[0013] An interruption instruction receiving module is configured to receive an interruption instruction for the first target container group;
[0014] The rejection module is configured to reject the interrupt instruction when the cluster state value is inconsistent with the expected state.
[0015] According to a third aspect of an embodiment of this specification, a computing device is provided, including:
[0016] Memory and processor;
[0017] The memory is used to store computer instructions, and the processor is used to execute the computer instructions:
[0018] Monitor the running status of each container group in the container cluster;
[0019] Determine a cluster state value of the container cluster based on the running state of each container group and the expected state of the container cluster;
[0020] receiving an interrupt instruction for a first target container group;
[0021] When the cluster state value is inconsistent with the expected state, the interrupt instruction is rejected.
[0022] According to a fourth aspect of an embodiment of this specification, a computer-readable storage medium is provided, which stores computer instructions, and when the computer instructions are executed by a processor, the steps of the container group protection method in any of the container clusters are implemented.
[0023] The container group protection method in the container cluster provided in this specification monitors the running status of each container group in the container cluster; determines the cluster status value of the container cluster based on the running status of each container group and the expected status of the container cluster; receives an interruption instruction for the first target container group; and rejects the interruption instruction when the cluster status value is inconsistent with the expected status. An embodiment of this specification realizes the conversion of various situations in the active interruption scenario into interruption instructions for Pods, has high versatility, can effectively prevent the impact of project interruption caused by a large number of Pods being unavailable in the active interruption scenario, and maintains the stability of the project. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 It is a flowchart of a container group protection method in a container cluster provided by an embodiment of this specification;
[0025] Figure 2 It is a schematic diagram of the architecture of a container group protection method in a container cluster provided in the second embodiment of this specification;
[0026] Figure 3 It is a processing flow chart of a container group protection method in a container cluster provided in the second embodiment of this specification;
[0027] Figure 4 It is a structural schematic diagram of a container group protection device in a container cluster provided by an embodiment of this specification;
[0028] Figure 5 It is a structural block diagram of a computing device provided in an embodiment of this specification. DETAILED DESCRIPTION
[0029] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.
[0030] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0031] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0032] First, the terms involved in one or more embodiments of this specification are explained.
[0033] Kubernetes: K88s for short, an open source container orchestration engine that supports automated deployment, large-scale scalability, and application container management.
[0034] Pod: A container group is an abstraction of an application in Kubernetes. It is the smallest schedulable unit and consists of a group of closely related containers that are scheduled to the same node.
[0035] Workload: The controller for application management in Kubernetes, which provides powerful replica management and grayscale release capabilities.
[0036] Voluntary disruption: refers to a scenario in which some operations triggered by users or cluster administrators cause some application pods to become unavailable, which in turn causes project disruption or SLA degradation.
[0037] Pod Disruption Budget: PDB for short, is used to limit the maximum number of unavailable pod replicas or the minimum number of available pod replicas that should remain available in the event of voluntary disruption, so as to ensure high availability of the application. PDB Object only defines the user's application expected state, and it is DisruptionContoller that actually maintains this expected state. When it listens to the add / update / delete events of pod / pdb, it calculates and updates pdb ojectPodDisruptionBudgetStatus. The most important elements of Pod Disruption Budget Status are DisruptedPods and PodDisruptionsAllowed.
[0038] DisruptedPods: records the pods that have been processed by pod eviction subresouces but have not been discovered and processed by the Disruption Contoller.
[0039] PodDisruptionsAllowed: Indicates the number of pods that are currently allowed to be disrupted.
[0040] Disruption Contoller: Calculates the value of PodDisruptionsAllowed based on the pod status and the number of DisruptedPods, and updates the pdb object status.
[0041] In this specification, a container group protection method in a container cluster is provided. This specification also relates to a container group protection device in a container cluster, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.
[0042] In Kubernetes clusters, powerful workloads (such as deployment, statefulset, etc.) are often used to define and manage applications to ensure high availability of applications. It can not only manage the number of pod copies of an application, but also provide rich grayscale capabilities such as MaxUnavailable and Partition. However, what is unsatisfactory is that workloads can only help the number of application pod copies reach the expected value as quickly as possible, and cannot guarantee that the number of available pod copies at any time remains at the expected value. In voluntary disruption scenarios, there are still cases of project interruption or SLA degradation.
[0043] The Kubernetes EvictionREST interface is responsible for handling the logic of pod eviction resources. When a pod is triggered to be evicted in certain scenarios, EvictionREST checks the PDB PodDisruptionsAllowed value corresponding to the pod to determine whether the current eviction action is allowed.
[0044] When PodDisruptionsAllowed <= 0, it indicates that the current evict action is prohibited and the pod is not allowed to be evicted.
[0045] When PodDisruptionsAllowed>0, it indicates that the pod is allowed to be evicted. PodDisruptionsAllowed is reduced by one, and the pod eviction subresources are added to PodDisruptionsAllowed, and finally the pod deletion operation is triggered.
[0046] From the principle of the above solution, we can see that the Kubernetes PDB solution can only protect against the scenario where pods are evicted, but it cannot protect applications against scenarios such as pod cascade deletion caused by deleting application workloads, and a large number of pods becoming unavailable due to application upgrades.
[0047] Based on this, this application customizes the PodUnavailableBudget (hereinafter referred to as PUB) protection mechanism to provide a container group protection method in a container cluster.
[0048] Figure 1A flowchart of a container group protection method in a container cluster provided according to an embodiment of this specification is shown, which specifically includes the following steps:
[0049] Step 102: Monitor the running status of each container group in the container cluster.
[0050] Among them, in this application, the container cluster is a Kubernetes cluster, and the container cluster directly manages the container group (Pod). Pod is the smallest basic unit in the container cluster and is the abstraction of the application by the container cluster. At least one application can be run in the Pod. Usually, a Pod runs one or more containers. In this application, the running status of each container group is monitored, that is, whether each Pod is available is monitored.
[0051] Multiple Pods are managed in a container cluster, and one or more containers run in each Pod. Containers are a lightweight virtualization technology that provides isolation functions similar to virtual machines. Container clusters use layered union file system technology to manage images, greatly simplifying the environment operation and maintenance process. Containers can be used as cloud hosts or as microservices.
[0052] When the container is used as a cloud host, it can be used as a container cloud host for business systems. It can be started, run, shut down, and restarted like a normal host. Websites can be built on the container cloud host, cloud hard disks, cloud databases, deployment services, etc. can be provided. For example, it can be used as a cloud host for e-commerce and ticketing website businesses.
[0053] Containers can also be used as microservices. Containers provide a complete set of platform-independent standardized technologies to deploy various services, such as audio and video processing, training and application of artificial intelligence models, e-commerce services, upper-level business services, etc.
[0054] Based on this, the container group protection method in the container cluster provided by the present application can be applied to a variety of application scenarios in practical applications, such as e-commerce, telecommunications, audio and video processing, artificial intelligence, online ticketing, data statistics, real-time monitoring, etc. The API Server in the container cluster provides a business interface for the upper-layer business and interacts with the upper-layer business. The data of the upper-layer business is transmitted to the container cluster through the API Server of the container cluster, and is processed by the corresponding container group, and the processing results are returned to the upper-layer business.
[0055] In another specific implementation provided by the present application, monitoring the running status of each container group in the container cluster includes:
[0056] receiving a creation instruction for a third target container group;
[0057] In response to the creation instruction, create the third target container group in the container cluster, and create a corresponding target container group protection object for the third target container group;
[0058] When it is detected that the target container group protection object is created successfully, a container group list and an expected state of the container cluster are obtained, and a running state of each container group in the container group list is monitored.
[0059] In actual applications, whenever a new Pod is created, the container cluster will receive the creation instruction for the new Pod, and the container cluster will also create a corresponding container group protection object (PUB Object) for the newly created Pod. When the PUB control unit monitors the PUB Object creation event, it can obtain the Pod list in the container cluster and the expected status defined by PUB through the selector in the container cluster. At the same time, it monitors the running status of each Pod in the container cluster.
[0060] Step 104: Determine a cluster state value of the container cluster based on the running state of each container group and the expected state of the container cluster.
[0061] The cluster status value refers to the UnavailableAllowed value in PUB, that is, the number of Pods that are currently allowed to be interrupted in the container cluster. For example, if 10 Pods are allowed to be interrupted in the container cluster, the cluster status value is 10.
[0062] The expected state of a container cluster refers to some constraints (object specifications) that the container cluster must meet during operation, such as the maximum unavailability rate and minimum running value of Pods in the container cluster.
[0063] Specifically, the expected state includes a maximum unavailability rate; and determining the cluster state value of the container cluster based on the running state of each container group and the expected state of the container cluster includes:
[0064] A cluster state value of the container cluster is determined based on the running state of each container group and the maximum unavailability rate.
[0065] The expected state of the container cluster includes the maximum unavailable rate (MaxUnavailable), that is, the maximum proportion of Pod interruptions allowed in the current container cluster, for example, MaxUnavailable = 20%. UnavailableAllowed of the container cluster can be determined based on the running state and maximum unavailable rate of each container group.
[0066] In practical applications, the running state includes available or unavailable; and determining the cluster state value of the container cluster based on the running state of each container group and the maximum unavailability rate includes:
[0067] Counting the number of container groups in the container cluster, and determining a maximum unavailability value according to the number of container groups and the maximum unavailability rate;
[0068] Counting the number of unavailable container groups in the container cluster whose running status is unavailable;
[0069] The cluster state value is determined according to the maximum unavailable value and the unavailable container group value.
[0070] First, the total number of Pods registered in the container cluster is counted, and then the maximum unavailable value can be determined based on the total number of Pods and the above maximum unavailable rate. For example, if there are 100 Pods in the container cluster and the maximum unavailable rate is 20%, the maximum unavailable value can be determined to be 20. In practical applications, the desired state can directly include the maximum unavailable value, for example, MaxUnavailable = 20, that is, only 20 Pods are allowed to be interrupted in the container cluster at most.
[0071] There are usually only two running states of a Pod, available or unavailable. The running state of a Pod can be monitored by monitoring Pod parameters or other means. Taking monitoring Pod parameters as an example, when the Status parameter of the Pod is monitored as Running and the Ready parameter of the Pod is true, the running state of the Pod can be determined to be available. In other cases, the running state of the Pod is determined to be unavailable. Count the number of container groups with an unavailable running state in the current container cluster, that is, the unavailable container group value. After determining the maximum unavailable value and the unavailable container group value, the cluster state value of the container cluster can be determined. For example, the maximum unavailable value is 20, and there are 5 container groups with an unavailable running state in the container cluster, that is, the unavailable container group value is 5. Based on this, it can be determined that UnavailableAllowed = 20-5 = 15.
[0072] Step 106: Receive an interrupt instruction for the first target container group.
[0073] The first target container group specifically refers to the Pod corresponding to the interruption instruction. The interruption instruction in this application not only includes expelling the Pod, but also includes modifying the Pod and deleting the Pod. Specifically, receiving the interruption instruction for the first target container group includes:
[0074] receiving a modification instruction for metadata and / or configuration files of a first target container group;
[0075] receiving a deletion instruction for the first target container group; or
[0076] An eviction instruction for a first target container group is received.
[0077] Pod metadata is used to describe the Pod's attribute information, such as the Pod name, the Pod's IP address, the namespace where the Pod is located, the name of the Pod's running node, the CPU and memory limits that the Pod can use, and so on.
[0078] The Pod configuration file (Spec definition) is a file that describes the Pod library version, including the source file location, required files, application build settings, common element names, versions, description information, and more.
[0079] After modifying the metadata and / or Spec definition of a Pod, you need to restart the Pod for the modified information to take effect. However, restarting the Pod will cause the application service in the Pod to be interrupted. Therefore, when receiving modification instructions for the Pod metadata and / or configuration files, it can be considered that an interruption instruction for the Pod has been received.
[0080] In actual applications, the interruption instruction for the Pod also includes the deletion instruction for the Pod, that is, assigning a value to the DeleletionTimestamp parameter of the Pod. After the DeleletionTimestamp parameter of a Pod is assigned a value, the Pod is considered to be deleted. Therefore, when a deletion instruction for the Pod is received, it can be considered that an interruption instruction for the Pod has been received.
[0081] In actual applications, the interruption instruction for Pod also includes the Pod eviction instruction (pod evictionsubresources). In the container cluster, the Pod eviction mechanism is divided into active eviction and passive eviction. When the node resources of the container cluster are scarce, in order to ensure the stability of the node, the Kubelet in the container cluster triggers Pod eviction and recycles the Pods that are temporarily unused on the node to release node resources. Kubelet eviction is also called passive eviction. When a node needs to be maintained or deleted, the Pod deployed on the node needs to be manually and actively expelled so as not to affect the continuity of the project. In the container cluster, when the Pod eviction instruction is received, it can be considered that the interruption instruction for the Pod has been received.
[0082] There are many scenarios of voluntary disruption of Pods. In this application, many scenarios of voluntary disruption of Pods are converted into issues of Pod resource modification. As long as modification, deletion, or expulsion instructions for Pods in the container cluster are monitored, it can be considered a voluntary disruption scenario, which has high versatility.
[0083] In practical applications, after receiving the interrupt instruction for the first target container group, the method further includes:
[0084] Determining whether the cluster status value meets the expected status;
[0085] If yes, determining that the cluster state value is consistent with the expected state;
[0086] If not, it is determined that the cluster state value is inconsistent with the expected state.
[0087] In actual applications, after receiving the interrupt instruction for the target Pod, the interrupt instruction is intercepted by Pub Webhook technology. Hook technology (also known as hook function) is that before the system executes the interrupt instruction, the hook program first captures the instruction, and the hook function first obtains control. The hook function can process (change) the instruction and can also forcibly end the transmission of the instruction.
[0088] After intercepting the interrupt instruction through Webhook technology, it is necessary to determine whether the cluster status value of the container cluster at this time meets the expected state of the container cluster. Specifically, the expected state includes the minimum running value; determining whether the cluster status value meets the expected state specifically includes:
[0089] Determine whether the cluster status value is greater than 0, and determine whether the cluster status value is greater than the minimum operation value;
[0090] When the cluster state value is greater than 0 and the cluster state value is greater than the minimum operation value, determining that the cluster state value is consistent with the expected state;
[0091] When the cluster state value is less than or equal to 0 or the cluster state value is less than or equal to the minimum operation value, it is determined that the cluster state value is inconsistent with the expected state.
[0092] First, determine whether the cluster status value of the container cluster is greater than 0. If the cluster status is greater than 0, it means that the container cluster can still interrupt Pods at this time. If the cluster status is less than or equal to 0, it means that the container cluster can no longer interrupt Pods at this time. If the Pods are interrupted again, it will cause project interruption or SLA degradation.
[0093] It is also necessary to determine whether the cluster state value of the container cluster is greater than the minimum operating value (MinAvailable) in the expected state. The minimum operating value specifically refers to the minimum number of Pods required to ensure the normal operation of the project. For example, the Etcd storage system is deployed in the container cluster. Currently, there are 5 copies of Etcd. Based on the implementation principle of Etcd, it is necessary to ensure that the number of copies of Etcd is greater than 3 before the Etcd storage system can be used normally. At this time, MinAvailable=3 in the PUB expected state corresponding to Etcd is defined, that is, when at least 3 Pods need to operate normally, the normal use of the Etcd system can be guaranteed. When the administrator is scaling down the service, the number of available Pods is mistakenly set to 2. After the control manager monitors the changes in the configured parameters, it starts to scale down one by one. When the first Pod is deleted, it is determined that the state value of the container cluster is greater than MinAvailable at this time, and then the cluster state value is determined to be greater than the minimum operating value; when the third Pod is deleted, the cluster state value is determined to be equal to the minimum operating value.
[0094] Only when the cluster state value is greater than 0 and the cluster state value is greater than the minimum running value in the expected state, can it be determined that the cluster state value is consistent with the expected state. When the cluster state value is less than or equal to 0 and / or the cluster state value is less than or equal to the minimum running value in the expected state, it is determined that the cluster state value is inconsistent with the expected state.
[0095] Step 108: If the cluster state value is inconsistent with the expected state, reject the interrupt instruction.
[0096] If it is determined through judgment that the cluster status value of the container cluster is inconsistent with the expected status, it means that the current interruption instruction will cause project interruption or SLA degradation, affecting the normal use of the project. At this time, the interruption instruction needs to be rejected. Since the Pub Webhook technology is used to intercept the interruption instruction in the above steps, if the cluster status value is inconsistent with the expected status, the interruption instruction can be directly rejected. It should be noted that after rejecting the interruption instruction, it is possible to judge again whether the cluster status value meets the expected status after a preset period of time.
[0097] In another specific embodiment provided in the present application, the method further comprises:
[0098] receiving an operation instruction for a second target container group;
[0099] In response to the running instruction, running the second target container group;
[0100] When the running state of the second target container group is changed to running, the cluster state value is updated according to the running change state value corresponding to the running instruction.
[0101] In actual applications, the cluster status value of the container cluster is not static. The cluster status value will change dynamically according to the running status of the Pod in the container cluster. For example, when the second target Pod receives a running instruction in an unavailable state, the second target Pod is started in the container cluster. After the second target Pod runs successfully, it is necessary to obtain the running change status value corresponding to the running instruction. Usually, the running change status value is set to +1, that is, the cluster status value is added by 1, that is, the number of Pods allowed to be interrupted in the container cluster will increase by one. If the interrupt instruction for the first target Pod was rejected before, and the running instruction for the second target Pod happened to be received, the cluster status value of the container cluster may have met the expected state at this time, then another specific implementation method provided by the present application can be executed, and the method also includes:
[0102] When the cluster state value is consistent with the expected state, the interrupt instruction is executed, and the cluster state value is updated according to the interrupt change state value corresponding to the interrupt instruction.
[0103] When the cluster status value is consistent with the expected status, it means that the interruption instruction will not affect the project of the container cluster, that is, the interruption instruction is allowed. After the interruption instruction is executed, it is necessary to promptly update the cluster status value of the container cluster according to the interruption change status value corresponding to the interruption instruction. Normally, in this application, the interruption change status value can be set to -1, that is, after the interruption instruction is executed, the cluster status value can be set to -1 to indicate that the number of Pods allowed to be interrupted in the container cluster will be reduced by one.
[0104] The container group protection method in the container cluster provided in this specification monitors the running status of each container group in the container cluster; determines the cluster status value of the container cluster based on the running status of each container group and the expected status of the container cluster; receives an interruption instruction for the first target container group; and rejects the interruption instruction when the cluster status value is inconsistent with the expected status. An embodiment of this specification realizes the conversion of various situations in the active interruption scenario into interruption instructions for Pods, has high versatility, can effectively protect the impact of project interruption caused by a large number of Pods being unavailable in the active interruption scenario, and maintains the stability of the project.
[0105] Secondly, through Webhook technology, without intruding into the relevant project system, comprehensive protection of the project system can be achieved to avoid project interruptions caused by active interruption scenarios, further maintain the stability of the project and improve the user experience.
[0106] The following combination Figure 2 With attached Figure 3 , further describes the container group protection method in the container cluster. Figure 2 A schematic diagram of the architecture of a container group protection method in a container cluster provided in the second embodiment of this specification is shown.
[0107] As attached Figure 2 As shown in the figure, the control unit of the container group protection mechanism Pod Unavailable Budget (hereinafter referred to as PUB) monitors the running status of each Pod in the container cluster API Server. The container cluster status value (UnavailableAllowed) is calculated based on the Pod running status and the expected status of PUB, and the cluster status value is saved to the API Server.
[0108] Voluntary disruption scenarios are triggered by users or container cluster administrators, such as deleting workloads, upgrading workloads, scaling down workloads, upgrading Pods in place, and draining nodes. This in turn triggers Pod resource modifications, which include: a) modifying Pod metadata&spec; b) deleting Pods; and c) evicting Pods.
[0109] The API Server intercepts the modification instruction through the Admission Webhook and asks the PUB Webhook whether the modification is allowed. The PUB Webhook decides whether the modification instruction is allowed based on the cluster status value and expected status saved in the API Server.
[0110] If the modification instruction is allowed, the corresponding operation is performed. If the modification instruction is not allowed, you can try again after a period of time.
[0111] Attached Figure 3 A processing flow chart of a container group protection method in a container cluster provided in the second embodiment of this specification is shown, which specifically includes the following steps:
[0112] Step 302: Create a corresponding PubObject for each Pod in the container cluster.
[0113] Step 304: When a PubObject creation event is monitored, obtain a Pod list and an expected state of the container cluster, wherein the expected state includes a maximum unavailability rate and a minimum running value.
[0114] Step 306: Count the number of container groups in the container cluster, and determine a maximum unavailability value according to the number of container groups and the maximum unavailability rate.
[0115] Step 308: Count the number of unavailable container groups in the container cluster whose running status is unavailable, and determine the cluster status value according to the maximum unavailable value and the unavailable container group value.
[0116] Step 310: Receive an interrupt instruction for the first target container group.
[0117] Step 312: Determine whether the cluster state value satisfies the expected state. If yes, execute step 314; if no, execute step 316.
[0118] Step 314: Execute the interrupt instruction, and update the cluster state value according to the interrupt change state value corresponding to the interrupt instruction.
[0119] Step 316: Reject the interrupt instruction.
[0120] The container group protection method in the container cluster provided in this specification monitors the running status of each container group in the container cluster; determines the cluster status value of the container cluster based on the running status of each container group and the expected status of the container cluster; receives an interruption instruction for the first target container group; and rejects the interruption instruction when the cluster status value is inconsistent with the expected status. An embodiment of this specification realizes the conversion of various situations in the active interruption scenario into interruption instructions for Pods, has high versatility, can effectively protect the impact of project interruption caused by a large number of Pods being unavailable in the active interruption scenario, and maintains the stability of the project.
[0121] Secondly, through Webhook technology, without intruding into the relevant project system, comprehensive protection of the project system can be achieved to avoid project interruptions caused by active interruption scenarios, further maintain the stability of the project and improve the user experience.
[0122] Corresponding to the above method embodiment, this specification also provides an embodiment of a container group protection device in a container cluster. Figure 4 FIG. 1 shows a schematic diagram of the structure of a container group protection device in a container cluster provided by an embodiment of the present specification. Figure 4 As shown, the device comprises:
[0123] A monitoring module 402 is configured to monitor the running status of each container group in the container cluster;
[0124] A determination module 404 is configured to determine a cluster state value of the container cluster based on the running state of each container group and the expected state of the container cluster;
[0125] The interruption instruction receiving module 406 is configured to receive an interruption instruction for the first target container group;
[0126] The rejection module 408 is configured to reject the interrupt instruction if the cluster state value is inconsistent with the expected state.
[0127] Optionally, the device further comprises:
[0128] The execution module is configured to execute the interrupt instruction when the cluster state value is consistent with the expected state, and update the cluster state value according to the interrupt change state value corresponding to the interrupt instruction.
[0129] Optionally, the device further comprises:
[0130] The judgment module is configured to judge whether the cluster state value satisfies the expected state; if so, determine that the cluster state value is consistent with the expected state; if not, determine that the cluster state value is inconsistent with the expected state.
[0131] Optionally, the desired state includes a minimum operating value;
[0132] The judging module is further configured to:
[0133] Determine whether the cluster status value is greater than 0, and determine whether the cluster status value is greater than the minimum operation value;
[0134] When the cluster state value is greater than 0 and the cluster state value is greater than the minimum operation value, determining that the cluster state value is consistent with the expected state;
[0135] When the cluster state value is less than or equal to 0 or the cluster state value is less than or equal to the minimum operation value, it is determined that the cluster state value is inconsistent with the expected state.
[0136] Optionally, the device further comprises:
[0137] An operation instruction receiving module is configured to receive an operation instruction for a second target container group;
[0138] an operating module, configured to operate the second target container group in response to the operating instruction;
[0139] The updating module is configured to update the cluster state value according to the running change state value corresponding to the running instruction when the running state of the second target container group is changed to running.
[0140] Optionally, the desired state includes a maximum unavailability rate;
[0141] The determining module 404 is further configured to:
[0142] A cluster state value of the container cluster is determined based on the running state of each container group and the maximum unavailability rate.
[0143] Optionally, the operating status includes available or unavailable;
[0144] The determining module 404 is further configured to:
[0145] Counting the number of container groups in the container cluster, and determining a maximum unavailability value according to the number of container groups and the maximum unavailability rate;
[0146] Counting the number of unavailable container groups in the container cluster whose running status is unavailable;
[0147] The cluster state value is determined according to the maximum unavailable value and the unavailable container group value.
[0148] Optionally, the monitoring module 402 is further configured to:
[0149] receiving a creation instruction for a third target container group;
[0150] In response to the creation instruction, create the third target container group in the container cluster, and create a corresponding target container group protection object for the third target container group;
[0151] When it is detected that the target container group protection object is created successfully, a container group list and an expected state of the container cluster are obtained, and a running state of each container group in the container group list is monitored.
[0152] Optionally, the interrupt instruction receiving module 406 is further configured to:
[0153] receiving a modification instruction for metadata and / or configuration files of a first target container group;
[0154] receiving a deletion instruction for the first target container group; or
[0155] An eviction instruction for a first target container group is received.
[0156] The container group protection device in the container cluster provided in this specification monitors the running status of each container group in the container cluster; determines the cluster status value of the container cluster based on the running status of each container group and the expected status of the container cluster; receives an interruption instruction for the first target container group; and rejects the interruption instruction when the cluster status value is inconsistent with the expected status. An embodiment of this specification realizes the conversion of various situations in the active interruption scenario into interruption instructions for Pods, has high versatility, can effectively protect against the impact of project interruption caused by a large number of Pods being unavailable in the active interruption scenario, and maintains the stability of the project.
[0157] Secondly, through Webhook technology, without intruding into the relevant project system, comprehensive protection of the project system can be achieved to avoid project interruptions caused by active interruption scenarios, further maintain the stability of the project and improve the user experience.
[0158] The above is a schematic scheme of a container group protection device in a container cluster of this embodiment. It should be noted that the technical scheme of the container group protection device in the container cluster and the technical scheme of the container group protection method in the container cluster mentioned above belong to the same concept, and the details of the technical scheme of the container group protection device in the container cluster that are not described in detail can be referred to the description of the technical scheme of the container group protection method in the container cluster mentioned above.
[0159] Figure 5 The structure block diagram of a computing device 500 provided according to an embodiment of the present specification is shown. The components of the computing device 500 include but are not limited to a memory 510 and a processor 520. The processor 520 is connected to the memory 510 via a bus 530, and the database 550 is used to store data.
[0160] The computing device 500 also includes an access device 540 that enables the computing device 500 to communicate via one or more networks 560. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 540 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0161] In one embodiment of the present specification, the above components of the computing device 500 and Figure 5Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 5 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0162] The computing device 500 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 500 may also be a mobile or stationary server.
[0163] The processor 520 is used to execute the following computer instructions:
[0164] Monitor the running status of each container group in the container cluster;
[0165] Determine a cluster state value of the container cluster based on the running state of each container group and the expected state of the container cluster;
[0166] receiving an interrupt instruction for a first target container group;
[0167] When the cluster state value is inconsistent with the expected state, the interrupt instruction is rejected.
[0168] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the container group protection method in the above container cluster belong to the same concept. For details not described in detail in the technical scheme of the computing device, please refer to the description of the technical scheme of the container group protection method in the above container cluster.
[0169] An embodiment of the present specification further provides a computer-readable storage medium storing computer instructions, which are used when executed by a processor to:
[0170] Monitor the running status of each container group in the container cluster;
[0171] Determine a cluster state value of the container cluster based on the running state of each container group and the expected state of the container cluster;
[0172] receiving an interrupt instruction for a first target container group;
[0173] When the cluster state value is inconsistent with the expected state, the interrupt instruction is rejected.
[0174] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the container group protection method in the above-mentioned container cluster belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the container group protection method in the above-mentioned container cluster.
[0175] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0176] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0177] It should be noted that, for the convenience of description, the aforementioned method embodiments are all described as a series of action combinations, but those skilled in the art should be aware that this specification is not limited by the order of the actions described, because according to this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this specification.
[0178] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0179] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is limited only by the claims and their full scope and equivalents.
Claims
1. A container group protection method in a container cluster, comprising: Monitor the running status of each container group in the container cluster; Determine a cluster state value of the container cluster based on the running state of each container group and the expected state of the container cluster, wherein the expected state is a constraint condition that the container cluster must satisfy during operation, and the cluster state value is the number of container groups currently allowed to be interrupted; receiving an interruption instruction for the first target container group, wherein the interruption instruction is a command that, when receiving multiple instructions in an active interruption scenario for the container group, intercepts the instruction through a hook function to obtain control of the instruction, and converts the instruction into one of an eviction, modification, and deletion instruction through the hook function; In a case where the cluster state value is inconsistent with the expected state, the interrupt instruction is rejected, wherein the rejecting of the interrupt instruction includes: ending the interrupt instruction through the hook function.
2. The container group protection method in the container cluster according to claim 1, the method further comprising: When the cluster state value is consistent with the expected state, the interrupt instruction is executed, and the cluster state value is updated according to the interrupt change state value corresponding to the interrupt instruction.
3. The container group protection method in the container cluster according to claim 2, after receiving the interruption instruction for the first target container group, the method further comprises: Determining whether the cluster status value meets the expected status; If yes, determining that the cluster state value is consistent with the expected state; If not, it is determined that the cluster state value is inconsistent with the expected state.
4. The container group protection method in a container cluster according to claim 3, wherein the desired state includes a minimum running value; Determining whether the cluster state value satisfies the expected state includes: Determine whether the cluster status value is greater than 0, and determine whether the cluster status value is greater than the minimum operation value; When the cluster state value is greater than 0 and the cluster state value is greater than the minimum operation value, determining that the cluster state value is consistent with the expected state; When the cluster state value is less than or equal to 0 or the cluster state value is less than or equal to the minimum operation value, it is determined that the cluster state value is inconsistent with the expected state.
5. The container group protection method in the container cluster according to claim 1, the method further comprising: receiving an operation instruction for a second target container group; In response to the running instruction, running the second target container group; When the running state of the second target container group is changed to running, the cluster state value is updated according to the running change state value corresponding to the running instruction.
6. The container group protection method in a container cluster according to claim 1, wherein the desired state includes a maximum unavailability rate; The determining the cluster state value of the container cluster based on the running state of each container group and the expected state of the container cluster includes: A cluster state value of the container cluster is determined based on the running state of each container group and the maximum unavailability rate.
7. The container group protection method in the container cluster according to claim 6, wherein the running state includes available or unavailable; The determining the cluster state value of the container cluster based on the running state of each container group and the maximum unavailability rate includes: Counting the number of container groups in the container cluster, and determining a maximum unavailability value according to the number of container groups and the maximum unavailability rate; Counting the number of unavailable container groups in the container cluster whose running status is unavailable; The cluster state value is determined according to the maximum unavailable value and the unavailable container group value.
8. The container group protection method in a container cluster according to any one of claims 1 to 7, monitoring the running status of each container group in the container cluster, comprising: receiving a creation instruction for a third target container group; In response to the creation instruction, create the third target container group in the container cluster, and create a corresponding target container group protection object for the third target container group; When it is detected that the target container group protection object is successfully created, a container group list and an expected state of the container cluster are obtained, and a running state of each container group in the container group list is monitored.
9. The container group protection method in the container cluster according to claim 1, receiving an interruption instruction for the first target container group, comprising: receiving a modification instruction for metadata and / or configuration files of a first target container group; receiving a deletion instruction for a first target container group; or An eviction instruction for a first target container group is received.
10. A container group protection device in a container cluster, comprising: A monitoring module is configured to monitor the running status of each container group in the container cluster; A determination module is configured to determine a cluster state value of the container cluster based on the running state of each container group and the expected state of the container cluster, wherein the expected state is a constraint condition to be satisfied by the container cluster during operation, and the cluster state value is the number of container groups currently allowed to be interrupted; an interruption instruction receiving module, configured to receive an interruption instruction for the first target container group, wherein the interruption instruction is a command to intercept the instruction through a hook function to obtain control of the instruction when receiving multiple instructions in an active interruption scenario for the container group, and to convert the instruction into one of an eviction, modification and deletion instruction through the hook function; The rejection module is configured to reject the interrupt instruction when the cluster state value is inconsistent with the expected state, wherein the rejection of the interrupt instruction includes: ending the interrupt instruction through the hook function.
11. A computing device comprising: Memory and processor; The memory is used to store computer instructions, and the processor is used to execute the computer instructions to implement the steps of the container group protection method in the container cluster described in any one of claims 1 to 9.
12. A computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the container group protection method in a container cluster as described in any one of claims 1 to 9.
13. A computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the container group protection method in a container cluster as described in any one of claims 1 to 9.
