A cluster log storage method and device

By allocating independent storage space for each container in the cloud platform cluster environment and mounting it to its deployment path, the problem of indistinguishability of multiple container logs in the same space is solved, realizing independent storage and convenient viewing of container logs is achieved .

CN113934564BActive Publication Date: 2024-11-15JUHAOKAN TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111128140.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-26
Publication Date
2024-11-15
Estimated Expiration
2041-09-26

AI Technical Summary

Technical Problem

In a cloud platform cluster environment, the logs of multiple containers are stored in the same storage space, making it difficult for operation and maintenance personnel to distinguish and view the logs of which container.

Method used

By allocating independent storage space for each container in the business node and mounting it to the deployment path of the container, the logs of each container are stored in its unique storage path.

Benefits of technology

The logs of each container are stored independently, which facilitates subsequent viewing and analysis by operation and maintenance personnel, and avoids resource waste and log loss caused by log storage on remote servers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113934564B_ABST
    Figure CN113934564B_ABST
Patent Text Reader

Abstract

The present application proposes a cluster log storage method and device to solve the problem that the cluster log storage method in the prior art causes the logs of multiple containers to be stored in the same space, which cannot be distinguished and is inconvenient for operation and maintenance personnel to view. The method includes: receiving a configuration file of a business service and an instance for providing the business service; the configuration file includes an instance template and a mirror file of the container; the instance template includes indication information for indicating that a control device is used to configure a storage path for at least one container, and the storage space indicated by the storage path belongs to the business node; sending a storage request to the control device; the storage request includes a target path allocated to at least one container; when determining that the mounting is completed, deploying at least one container in the business node according to the mirror file; mounting the target path of the first container to the deployment path of the first container in the business node, and the first container is any one of the at least one container.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a cluster log storage method and device. Background Art

[0002] In a cloud platform cluster environment, such as a container cloud cluster based on K8s, a large number of microservices are deployed. Each microservice can include multiple instances, and multiple instances run on one or more servers at the bottom. Each instance can be composed of multiple containers, and each container has an independent deployment path. In order to record the running status of the service and facilitate problem analysis when a failure occurs, the container generates logs when running the application and stores the generated logs. The current storage method of logs in the cluster is to write the container logs to a storage path that is different from the container deployment path in the server where the container is deployed. If multiple containers are deployed in the server, then these multiple containers will write logs to the above storage path, resulting in the inability to distinguish which specific container the log is, which is not convenient for operation and maintenance personnel to conduct subsequent viewing and analysis. Summary of the invention

[0003] The embodiments of the present application provide a cluster log storage method, device and system, which are used to solve the problem in the related art that the cluster log storage method makes the log inconvenient for operation and maintenance personnel to view.

[0004] In a first aspect, an embodiment of the present application provides a cluster log storage method, which is applied to a service node, and the method includes:

[0005] receiving a configuration file of a business service and an instance for providing the business service from a management node; the configuration file includes an instance template for creating the instance and an image file for creating at least one container included in the instance; the instance template includes indication information for indicating that a control device is used to configure storage paths for the at least one container respectively, and the storage space indicated by the storage path belongs to the business node;

[0006] Sending a storage request to the control device; the storage request includes a target path respectively allocated to the at least one container, and the storage request is used to request the control device to configure a storage path respectively for the at least one container, and to mount the configured storage path respectively to the corresponding target path;

[0007] When it is determined that the control device completes the mounting, deploying the at least one container in the service node according to the image file;

[0008] Mount a target path of a first container to a deployment path of the first container on the service node, where the first container is any one of the at least one container.

[0009] Based on the above solution, the service node can send a storage request to the control device according to the instruction information contained in the instance template, requesting the control device to allocate storage space for the multiple containers contained in the instance in the service node. The storage spaces of multiple containers are independent of each other, avoiding the problem of being unable to distinguish due to the logs of multiple containers being stored in one storage space, and facilitating the operation and maintenance personnel to view.

[0010] In a second aspect, an embodiment of the present application provides another cluster log storage method, which is applied to a control device, and the method includes:

[0011] Receiving a storage request from a service node, wherein the storage request includes a target path respectively allocated to the at least one container;

[0012] Allocate storage space for the at least one container in the service node according to the storage request; the storage space is used to store container logs;

[0013] Mounting a storage path of a first storage space allocated to a first container under a target path of the first container; the first container is any one of the at least one container;

[0014] The target path of the first container is used to mount to the deployment path of the first container deployed in the service node.

[0015] In a third aspect, an embodiment of the present application provides another cluster log storage method, which is applied to a management node, including:

[0016] Create an instance for providing business services according to the instance template in the configuration file;

[0017] Sending the instance and the configuration file to the service node;

[0018] Among them, the configuration file also includes a mirror file, and the instance template also includes indication information, the mirror file is used by the business node to create at least one container included in the instance, and the indication information is used to instruct the business node to request the control device to configure a storage path for the at least one container respectively, and the storage space indicated by the storage path belongs to the business node.

[0019] In a fourth aspect, an embodiment of the present application provides a storage system for cluster logs, including:

[0020] A management node, configured to create an instance for providing a business service according to an instance template in a configuration file; and send the instance and the configuration file to a business node;

[0021] The service node is used to receive the configuration file and the instance; the configuration file includes an instance template for creating the instance and an image file for creating at least one container included in the instance; the instance template includes indication information for indicating that a control device is used to configure a storage path for each of the at least one container, and the storage space indicated by the storage path belongs to the service node;

[0022] The service node is further used to send a storage request to the control device; the storage request includes a target path respectively allocated to the at least one container, and the storage request is used to request the control device to configure a storage path for the at least one container respectively, and mount the configured storage path to the corresponding target path respectively;

[0023] The control device is used to receive the storage request; allocate storage space for the at least one container in the service node according to the storage request; the storage space is used to store container logs;

[0024] The control device is further used to mount a storage path of a first storage space allocated to a first container under a target path of the first container; the first container is any one of the at least one container;

[0025] The business node is further used to deploy the at least one container in the business node according to the image file when it is determined that the control device has completed the mounting; and mount the target path of the first container to the deployment path of the first container in the business node.

[0026] In a fifth aspect, an embodiment of the present application provides a storage device for a cluster log, including:

[0027] a transceiver unit, configured to receive a configuration file of a business service and an instance for providing the business service from a management node; the configuration file includes an instance template for creating the instance and an image file for creating at least one container included in the instance; the instance template includes indication information for indicating that a control device is used to configure storage paths for the at least one container, respectively, and the storage space indicated by the storage path belongs to the business node;

[0028] The transceiver unit is further used to send a storage request to the control device; the storage request includes a target path respectively allocated to the at least one container, and the storage request is used to request the control device to configure a storage path for the at least one container respectively, and mount the configured storage path to the corresponding target path respectively;

[0029] a processing unit, configured to deploy the at least one container in the service node according to the image file when it is determined that the control device has completed the mounting;

[0030] The processing unit is further configured to mount a target path of a first container to a deployment path of the first container on the service node, where the first container is any one of the at least one container.

[0031] In a sixth aspect, an embodiment of the present application provides another storage device for cluster logs, including:

[0032] A transceiver unit, configured to receive a storage request from a service node, wherein the storage request includes a target path respectively allocated to the at least one container;

[0033] a processing unit, configured to allocate storage space for each of the at least one container in the service node according to the storage request; the storage space is used to store container logs;

[0034] The processing unit is further used to mount the storage path of the first storage space allocated to the first container under the target path of the first container; the first container is any one of the at least one container; the target path of the first container is used to mount to the deployment path of the first container deployed in the business node.

[0035] In a seventh aspect, an embodiment of the present application provides another storage device for cluster logs, including:

[0036] A processing unit, used to create an instance for providing business services according to an instance template in a configuration file;

[0037] A transceiver unit, configured to send the instance and the configuration file to a service node;

[0038] Among them, the configuration file also includes a mirror file, and the instance template also includes indication information, the mirror file is used by the business node to create at least one container included in the instance, and the indication information is used to instruct the business node to request the control device to configure a storage path for the at least one container respectively, and the storage space indicated by the storage path belongs to the business node.

[0039] In an eighth aspect, an embodiment of the present application provides another storage device for cluster logs, including a memory and a processor;

[0040] A memory for storing program instructions;

[0041] The processor is used to call the program instructions stored in the memory and execute the method in any implementation of the first aspect to the third aspect according to the obtained program.

[0042] In a ninth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions. When the computer instructions are executed on a computer, the computer executes the above method.

[0043] In addition, the technical effects brought about by any implementation method of the third to ninth aspects can refer to the technical effects brought about by different implementation methods of the first to second aspects, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0045] Figure 1 A schematic diagram of the architecture of a cluster log storage system provided in an embodiment of the present application;

[0046] Figure 2 A schematic diagram of a cluster log storage method provided in an embodiment of the present application;

[0047] Figure 3 A schematic diagram of a method for managing nodes to create instances and containers provided in an embodiment of the present application;

[0048] Figure 4 A schematic diagram of a process flow of a cluster log storage method for creating a new business service scenario provided in an embodiment of the present application;

[0049] Figure 5 A schematic diagram of a method for storing cluster logs in a scenario of deleting a business service provided in an embodiment of the present application;

[0050] Figure 6 A schematic diagram of a device for implementing a cluster log storage method provided in an embodiment of the present application;

[0051] Figure 7 A schematic diagram of another device for implementing a cluster log storage method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0052] In order to make the purpose, implementation mode and advantages of the present application clearer, the exemplary implementation mode of the present application will be clearly and completely described below in conjunction with the drawings in the exemplary embodiments of the present application. Obviously, the described exemplary embodiments are only part of the embodiments of the present application, not all of the embodiments.

[0053] Based on the exemplary embodiments described in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the claims attached to this application. In addition, although the disclosure in this application is introduced according to one or several exemplary examples, it should be understood that each aspect of the disclosure can also constitute a complete implementation method separately.

[0054] It should be noted that the brief description of terms in this application is only for the convenience of understanding the embodiments described below, and is not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their common and usual meanings.

[0055] In the prior art, there are three ways to store logs in a cluster: one is that the container directly writes the generated logs to the container's deployment path. The second is that the container mounts other storage paths on the host machine, and the container writes the logs to the storage space corresponding to the mounted storage path. The third is that the container mounts a remote storage server, and the container writes the logs to the mounted remote storage server.

[0056] Among them, the first storage method mentioned above writes the logs to the deployment path of the container. The storage space under the deployment path of the container is limited and cannot store a large number of logs. In addition, when the container is deleted, the logs stored in its deployment path will also be deleted synchronously. The second storage method mentioned above writes the logs to other storage spaces of the host machine of the container. Since there may be multiple containers deployed on the host machine, multiple containers will write logs to the storage space and cannot be distinguished. Therefore, both of the above methods will cause the problem that operation and maintenance personnel cannot view and analyze logs. The third storage method mentioned above writes the logs to a remote storage server. Using this method to store logs consumes network bandwidth, resulting in a waste of resources.

[0057] The embodiment of the present application provides a method, device and system for storing cluster logs. By adding a control device for allocating log storage space to the existing cluster system, and using the control device to allocate separate storage space for storing logs to multiple containers in the cluster, the logs of each container can be stored independently, which is convenient for subsequent viewing by operation and maintenance personnel. It should be noted that the logs of the cluster involved in this application can be the logs of each container running in the cluster. For the convenience of description, the logs of the storage container are used as an example for introduction.

[0058] Figure 1 The schematic diagram of the architecture of a cluster log storage system provided by the present application is shown. It should be understood that the embodiments of the present application are not limited to Figure 1 In the system shown, in addition, Figure 1The device in the structure can be hardware, software divided by function, or a combination of the two. Figure 1 As shown, the storage system of the cluster log provided by the present application includes a management node, a service node and a control device, and also includes a first instance and a second instance included in the service node. The first instance includes at least one container, and the second instance also includes at least one container.

[0059] First, the functions of the management node include: managing and maintaining at least one instance contained in the system, task allocation in the system (i.e., completing the deployment of tasks according to the remaining resources of the business node to achieve load balancing of each business node in the system), providing a service interface (API Server), and saving the configuration information and load changes of each node in the system, etc. The functions of the management node proposed in this application can be implemented by a server or a server cluster, and this application does not make specific restrictions on this. Optionally, the management node can also include multiple components to implement the above functions, such as:

[0060] (1) Application Programming Interface Server: Optionally, the application programming interface server can be an API server, which will be introduced later using the API server as an example. It is responsible for providing RESTful interface services to the outside world. Other components in the management node can implement their own functions through the API server. For example, the API server can be used to monitor the load of each business node, or to delete, add, or view instances or containers, or to monitor whether there are business services to be deployed.

[0061] (2) State storage (ETCD): A database that uses key-value pairs to store data. It is used to save the status information of all network configurations and resource objects in the system (for example, the remaining resources of a certain business node), that is, to save the status of the entire system.

[0062] (3) Scheduler: It is used to monitor the newly created instance replica information and select the most suitable business node for the newly created instance to be deployed through the resource scheduling algorithm. After the deployment is successful, the instance information will be bound to the information of the business node where it is deployed and stored in ETCD.

[0063] (4) Controller Manager: Responsible for managing the controllers that perform various functions in the management node. The controller is responsible for maintaining the state of the system, such as fault detection, automatic expansion, or rolling upgrades. For example, the controller can create a new business service based on the configuration file deployed by the operation and maintenance personnel to implement the upgrade of the business service. After creating a new business service, the controller can create an instance for running the business service based on the new business service and the instance template.

[0064] Secondly, the business node is used to provide a running environment for multiple instances (or multiple containers). Its main functions include: starting and stopping instances, and forwarding received requests to a specific instance. It should be noted that the functions of the business node can also be implemented by a server or a server cluster. Optionally, the business node can also include components for implementing the above functions, such as:

[0065] (1) Agent (also called agent component, such as kubelet): responsible for monitoring and managing the life cycle of each instance that has been assigned to the business node, and is also used to implement operations such as starting, deleting, or stopping the instance. For example, when monitoring that a new business service and instance are deployed to the business node, the agent can deploy multiple containers corresponding to the new business service to the instance to start the instance.

[0066] (2) Request forwarding component (kube-proxy): responsible for forwarding received requests to a specific instance.

[0067] Furthermore, the first instance (or the second instance) is the smallest operating unit in the system, and an instance may include one container or multiple containers, and is used to receive a service request from a terminal and implement a corresponding service function.

[0068] The control device provided in the embodiment of the present application can be used to allocate storage space for logs to multiple containers to be deployed in the business node. The control device can be a hardware processor connected to the business node server, or it can be a hardware plug-in inserted in the business node server, or it can be directly integrated into the business node server, or it can be software installed on the business node server. The present application does not specifically limit the form of the control device. The business node can obtain the identification of the control device, such as the name of the control device. Taking the control device as a plug-in inserted in the business node as an example, when the control device is inserted in the business node, it can register its own identification with the business node. Alternatively, the business node can obtain the identification of the plug-in inserted in itself in a predefined manner.

[0069] It should be noted that Figure 1 As an example only, the present application does not specifically limit the number of management nodes, business nodes, control devices, instances, and containers included in the business service update system.

[0070] The cluster log storage method provided in the embodiment of the present application can be executed by a cluster log storage system. As an example, the architecture of the cluster log storage system can be seen in the above Figure 1 In the introduction, for the convenience of description, the storage system of the cluster log is referred to as the storage system, and the storage system may include a management node, a business node, and a control device. In some embodiments, when there is a new business service that needs to be deployed to the storage system, the storage system may first obtain a configuration file of the business service to be deployed (optionally, the operation and maintenance personnel may deploy the configuration file to the storage system). As an example, the configuration file may include an instance template for creating an instance for providing business services and an image file of a container included in the instance. Further, an instance is created according to the instance template, and the created instance and the configuration file are sent to the business node of the instance to be deployed. Optionally, the storage system may determine that a control device in the storage system needs to be used to allocate storage space for the container according to the indication information included in the instance template. The business node of the instance to be deployed sends a storage request to the control device before creating the container, requesting the control device to allocate storage space for the container to store logs. Further, the control device allocates storage space for the container in the business node, and mounts the path of the storage space to the deployment path of the container. After the mounting is completed, the business node creates a container according to the image file and deploys the created container to the instance, and runs the instance to provide business services, thereby completing the deployment of the business service.

[0071] Next, the storage system of the cluster log proposed in this application is further introduced in combination with each node and device included in the storage system. First, you can refer to Figure 2 , is a flow chart of a log storage method in a cluster provided in an embodiment of the present application, specifically including:

[0072] 201. The management node creates an instance for providing business services according to the instance template in the configuration file.

[0073] Optionally, the configuration file may be a configuration file of a business service to be deployed in the cluster. In some possible cases, when a new business service needs to be deployed in the cluster, or when a business service in the cluster needs to be updated, the operation and maintenance personnel will deploy a configuration file for creating a new business service to the management node.

[0074] As an example, the configuration file may include an instance template for creating an instance that provides a business service and an image file for creating multiple containers included in the instance. Optionally, if a business service corresponds to multiple instances, the configuration file of the business service may also include the number of instances to be created. For ease of description, the following description will take the business service corresponding to one instance as an example.

[0075] Optionally, the instance template may also include indication information for indicating that the control device is used to configure storage paths for multiple containers included in the instance, and may also include the type of storage space indicated by the storage paths configured for the multiple containers, such as whether the storage space belongs to a business node or a server of another storage type.

[0076] 202. The management node sends a configuration file and an instance to the service node.

[0077] Optionally, after completing the creation of the instance, the management node may send a creation instruction to the business node, and carry the configuration file and the instance in the creation instruction. The creation instruction may be used to instruct the business node to create multiple containers included in the instance according to the image file included in the configuration file.

[0078] 203. The service node receives the configuration file and the instance, and sends a storage request to the control device.

[0079] The storage request is used to request to allocate storage space for storing container logs to multiple containers respectively, and the storage space belongs to the service node.

[0080] Optionally, after receiving the configuration file and the instance, the business node may not create the multiple containers included in the instance first, but may determine, based on the instruction information in the instance template, that the multiple containers included in the instance need to have storage space allocated to them by the control device, and then may send a storage request to the control device to request storage space for storing container logs for the multiple containers to be created.

[0081] As an example, the storage request may also include a target path allocated by the business node to each container, which is used to control the device to mount the storage path of the storage space allocated for the container to the target path corresponding to the container. When creating a container, the business node will create a storage space for the container to run. For example, a namespace or control group or other technology can be used to allocate an independent space for each container to run the container. For ease of description, the space will be referred to as the deployment space of the container, and the path of the deployment space will be referred to as the deployment path. Since the business node has not created a container when sending a storage request, it has not created a deployment space for the container. Therefore, the business node can first allocate a target path to each container. The target path is used to mount to the deployment path of the container after the container deployment is completed.

[0082] 204. The control device receives the storage request and allocates storage space to the multiple containers in the service node.

[0083] Optionally, after receiving the storage request, the control device may allocate a separate storage space for each container according to the multiple containers to be created and the target path of each container included in the storage request. The storage space allocated by the control device is the storage space in the service node. For example, the control device may allocate storage space for the container from the memory of the service node.

[0084] 205 , the control device mounts the storage path of the storage space allocated to the container to the target path of the container.

[0085] As an example, the control device can set the correspondence between the target path of the container and the storage path of the storage space so that the storage path is mounted under the target path of the container. For example, the storage path is " / 123 / ac / 456" and the target path of the container is " / 32 / ac / xx". After setting the correspondence between the storage path and the target path of the container, the storage path can be mounted under the target path of the container. That is, the path " / 123 / ac / 456" exists in the path " / 32 / ac / xx". When accessing the path " / 32 / ac / xx", the path " / 123 / ac / 456" can be accessed.

[0086] Optionally, after completing the mounting, the control device may also send mounting completion information to the service node.

[0087] 206. When the service node determines that the control device has completed mounting, the service node creates a container.

[0088] As an optional manner, the service node may determine that the mounting is completed upon receiving the mounting completion information from the control device, and may create multiple containers according to the image file received from the management node.

[0089] 207, the service node mounts the target path of any container to the deployment path of the container.

[0090] Among them, the introduction of the deployment path of the container can refer to the above step 203. When creating a container, the business node can allocate space for the container to run, and the path of the space is the deployment path. As an example, the process of mounting the path is introduced by taking the first container among multiple containers as an example: when the business node applies for storage space for the first container to the control device, the target path of the first container can be allocated to the first container. Then the control device can mount the storage path of the storage space allocated for the first container to the target path of the first container. Further, when the business node creates the first container, the deployment path of the first container can be allocated to the first container. After creating the first container, the business node can mount the target path of the first container to the deployment path of the first container. Thus, the storage path of the first container allocated by the control device is mounted under the target path of the first container, and the target path of the first container is mounted under the deployment path of the first container, so that access to the deployment path of the first container can be achieved, that is, access to the storage path of the first container can be achieved.

[0091] Optionally, after the business node creates the container and completes the mounting, the container can be run to provide business services. During the operation of the container, the process running in the container can store the generated container logs in the storage space indicated by the storage path according to the mounted storage path.

[0092] Based on the above solution, the control device can allocate a storage space for storing logs to each container, and the storage space corresponding to each container is independent, which solves the problem in the prior art that the logs of multiple containers are stored in the same storage space and cannot be distinguished. In addition, the storage space allocated by the control device is the storage space in the business node, which solves the problem of bandwidth resource waste caused by using a remote log server to store logs in the prior art, and also solves the problem in the prior art that the logs may be lost when the container is deleted because the logs are stored in the container.

[0093] In some embodiments, after obtaining the configuration file of the business service (which may be received from the client or other server, or deployed by the operation and maintenance personnel), the management node may create an instance for providing the business service according to the instance template included in the configuration file. Further, the management node may determine which business node or business nodes to deploy the multiple created instances to according to the load conditions of multiple business nodes in the cluster, and after determining the business node (taking determining a business node as an example), the instance and the configuration file may be sent to the determined business node, instructing the business node to create multiple containers included in the instance.

[0094] As an example, the instance template may further include instruction information for instructing the control device to allocate storage space for storing logs to multiple containers included in the instance. For example, the instance template may include:

[0095] volumes:

[0096] -name:example-log-1 (a storage volume)

[0097] flexVolume (a storage plugin in the cluster):

[0098] driver: the identifier of the control device (for example, it can be the name of the control device, indicating that the control device is used to allocate storage space for the container included in the instance)

[0099] -name:example-log-2 (another storage volume)

[0100] csi (another storage plugin in the cluster):

[0101] driver: Identification of the control device

[0102] Optionally, the instance template may also include the type of storage space allocated to the container (i.e., whether the storage space belongs to the service node or to an external storage device, such as a remote storage server). For example, the instance template may include:

[0103] containers:

[0104] -name:example-container-1 (a container)

[0105] volumeMounts (mount storage volumes):

[0106] -name:example-log-1 (the name of the storage volume corresponding to a data item in the container)

[0107] mountPath: / var / log / example-path (the storage path where the data is written)

[0108] -name:example-log-2 (the name of the storage volume corresponding to another data in the container)

[0109] mountPath: / var / log / path-2 (the storage path where the data is written)

[0110] As an example, this application exemplarily provides a method for creating an instance and a container. For details, please refer to Figure 3 Taking the created business service corresponding to an instance as an example (hereinafter referred to as instance A), the process of creating instances and containers is introduced in combination with various components in the management node and business node, including:

[0111] 301. The API server receives a configuration file for creating a business service.

[0112] Optionally, the API server can convert the received configuration file into a file format readable by the server, such as a file in protobuf format. Optionally, the API server can also write the configuration file into ETCD after converting the file format. Optionally, if the received configuration file is a file in protobuf format, the file format conversion does not need to be performed.

[0113] As an example, the configuration file may include: an image file for creating multiple containers corresponding to the business service and an instance template for creating an instance A for running the business service. For details, please refer to the introduction of the configuration file in the above embodiment, which will not be described in detail here.

[0114] 302, the controller obtains the instance template of instance A and creates instance A.

[0115] Optionally, the controller may detect in real time whether there is an instance to be created in the API server. When detecting that there is an instance A to be created, the controller obtains the instance template of instance A in the API server and creates instance A.

[0116] Optionally, the controller can store the created instance A in etcd.

[0117] 303. Scheduler determines to deploy instance A to service node A.

[0118] Optionally, the Scheduler can detect in real time whether there is an instance to be created in the API server. When it is detected that there is an instance A to be created, it can first determine whether instance A is associated with a business node. If not, it can determine to deploy instance A to business node A based on the load conditions of each business node in the cluster.

[0119] Optionally, after associating instance A with service node A, Scheduler may store the association relationship between instance A and service node A in ETCD.

[0120] It should be noted that there is no order relationship between the above-mentioned step 302 and step 303. Step 302 can be performed first, or step 303 can be performed first. This application does not limit this.

[0121] 304. The kubelet of business node A deploys instance A to business node A and creates multiple containers included in instance A.

[0122] In some embodiments, the kubelet of business node A can determine the association between instance A and business node A from ETCD through the API server, that is, determine that instance A needs to be deployed to business node A. The kubelet of the business node can obtain instance A from ETCD, deploy instance A to business node A, and obtain the configuration file from ETCD to create multiple containers included in instance A.

[0123] In some other embodiments, when the API server determines that instance A needs to be deployed to business node A, it may send the image files of instance A and multiple containers included in instance A to the kubelet of business node A.

[0124] The above introduces the process of creating instances and containers using a specific example.

[0125] Optionally, after receiving the instance and configuration file from the management node, the service node may not create multiple containers included in the instance first, but may first request independent storage space for storing logs for each of the multiple instances to be created. In some embodiments, the service node may generate a storage request for each container to be created, and the storage request may also include the size of the requested storage space. Optionally, after receiving the storage request, the control device may allocate storage space for the container according to the size of the storage space included in the request.

[0126] In some embodiments, after allocating storage space for the container, the control device can configure the storage space to be writable so that the application running in the container can write the log of the container into the storage space. Furthermore, after the business node determines that the control device has allocated storage space for the multiple containers to be created, respectively, it can create a container according to the received image file of the container, and can also deploy the created multiple containers in multiple instances. It should be noted that the containers included in each instance are the same. After the business node completes the deployment of containers in each instance, it can run the instance to provide business services.

[0127] Below, in order to further understand the solution of the present application, the cluster log storage method proposed in the present application will be introduced in combination with specific scenarios.

[0128] Scenario 1: Creating a new business service.

[0129] As an example, scenarios where a new business service needs to be created in a cluster include: when a business service in the cluster needs to be upgraded, a new upgraded business service needs to be created. When a new business service needs to be deployed in the cluster, a business service to be deployed also needs to be created.

[0130] The management node can receive a configuration file of a new business service deployed by the operation and maintenance personnel. The configuration file may include an instance template for creating an instance and an image file of a container to be created. For details, please refer to the introduction in the above embodiment, which will not be described in detail here. Further, the management node can create an instance according to the instance template in the configuration file, and determine which business node to deploy the created instance to according to the load of the business node, and send the created instance to the business node. The management node can also send a creation instruction for indicating the creation of a container to the determined business node. The creation instruction can also carry an instance and a configuration file. The business node can first send a storage request to the control device according to the creation instruction, and request a storage space for storing logs for the container to be created. The business node can start creating a container according to the image file of the container after determining that the control device has completed the allocation of storage space for the container to be created, and deploy the container in the instance. Then, the business node can run the instance to provide a new business service. Optionally, after creating the container and deploying the container in the instance, the business node can further report the status of the instance to the management node, that is, whether the instance is successfully started.

[0131] As an example, the process of creating a business service in the following scenario is introduced by combining the components of the management node and the business node. For the sake of ease of description, the business service to be deployed is referred to as business service A. Figure 4 , which is a specific flow chart of the scenario provided in the embodiment of the present application, including:

[0132] 401: The API server receives a configuration file for creating business service A.

[0133] Optionally, after receiving the configuration file of business service A, the API server can convert the file format. For details, please refer to the above Figure 3 The introduction of step 301 will not be repeated here.

[0134] 402, the controller monitors the API server, determines that business service A needs to be deployed, and creates an instance for providing business service A.

[0135] Optionally, when the controller determines that there is a business service A to be deployed in the API server, it can obtain an instance template that provides an instance of business service A and create an instance. Figure 3 The description of step 302 is not repeated here.

[0136] 403: The kubelet of the business node monitors the API server, determines that business service A needs to be deployed, and obtains the instance and configuration file.

[0137] For details, please refer to the above Figure 3 The relevant introduction of step 304 in will not be described in detail here.

[0138] 404. The kubelet of the service node sends a storage request to the control device.

[0139] Optionally, after obtaining the instance and the configuration file, the business node may not create the multiple containers included in the instance first, but may first request the control device for storage space for multiple containers to store logs. Optionally, the content included in the storage request can refer to the introduction in the above embodiment, for example, the storage request may include the target paths allocated by the kubelet of the business node to the multiple containers to be created.

[0140] 405 , the control device receives the storage request, allocates storage space for the container to be created in the service node, and mounts the storage path of the storage space to the target path.

[0141] Optionally, the control device may allocate storage space for the multiple containers to be created according to the size of the requested storage space included in the storage request. It should be noted that the multiple storage spaces corresponding to the multiple containers are independent of each other. As an optional method, the control device may also mount the storage path of the allocated storage space to the target path of the container to be created, as shown in the above Figure 2 Related introduction of step 205 in . Optionally, after the mounting is completed, the control device may also send a mounting completion message to the kubelet of the service node.

[0142] 406. When the kubelet of the service node determines that the mounting is complete, it creates a container and mounts the target path of the container to the deployment path of the container.

[0143] For details, please refer to the above Figure 2 The relevant introduction of steps 206 and 207 in the above will not be described in detail here. Optionally, after the service node creates the container, the container can be deployed to the instance, and the instance can be run to provide the service A.

[0144] 407: The kubelet of the service node sends the instance status to the API server.

[0145] Scenario 2: Deleting a business service.

[0146] Deleting a business service means deleting multiple instances and multiple containers corresponding to the business service. As an example, in scenario 2, the business service to be deleted corresponds to an instance, and the instance includes multiple containers.

[0147] In some embodiments, the management node may receive instruction information issued by the operation and maintenance personnel, indicating the deletion of a certain business service in the cluster. Then the management node may issue a deletion instruction to the business node providing the business service to be deleted, instructing the business node to delete the instance corresponding to the business service to be deleted and the multiple containers included in the instance. After receiving the deletion instruction, the business node may first determine that the deployment paths of the multiple containers to be deleted are respectively mounted with multiple storage paths, and the business node may send an uninstallation request to the control device, requesting to uninstall the multiple storage paths mounted under the multiple container paths. After receiving the uninstallation request, the control device may uninstall the storage paths mounted under the target paths of the multiple containers, that is, to remove the association between the target paths and the storage paths. Optionally, after the control device completes the uninstallation, it may also send an uninstallation completion message to the business node. The business node may delete the instance to be deleted after receiving the uninstallation completion message. Optionally, the control device may also delete the data in the corresponding multiple storage spaces after completing the set duration of the uninstallation. Therefore, the operation and maintenance personnel can view the logs of the deleted multiple containers from the above multiple storage spaces within the set duration. After the set time is reached, the control device will delete the logs in multiple storage spaces for subsequent use.

[0148] As an example, see Figure 5 , which is a specific flow chart of scenario 2 provided in the embodiment of the present application, including:

[0149] 501. The management node sends a deletion instruction for instructing a business service to be deleted to a business node.

[0150] 502. The service node receives the deletion instruction and sends an uninstallation request to the control device.

[0151] As an optional method, after receiving the deletion instruction, the service node can first stop the various processes running in the container to be deleted, and then uninstall the target path mounted under the deployment path of the container. After the uninstallation is completed, the multiple containers to be deleted can be deleted. Furthermore, the service node can also send an uninstall request to the control device, requesting the control device to uninstall the storage path mounted under the target path of the container.

[0152] 503, the control device receives the uninstallation request, and uninstalls the storage paths mounted under the target paths of the multiple containers to be deleted.

[0153] Optionally, after the control device completes the uninstallation, it may also send uninstallation completion information to the service node.

[0154] 504. When the service node determines that the uninstallation of the control device is complete, the instance to be deleted is deleted.

[0155] Optionally, the service node may determine that the control device has been completely uninstalled according to the uninstallation completion information received from the control device, and start deleting the instance to be deleted.

[0156] 505. The service node sends the instance status to the management node.

[0157] Optionally, the state of the instance in scenario 2 is used to indicate whether the instance is deleted.

[0158] In some embodiments, the operations performed by the above-mentioned business node may also be performed by the kubelet of the business node.

[0159] Based on the same concept as the above method, see Figure 6 , the embodiment of the present application provides a device 600 for implementing a cluster log storage method. The device 600 can perform each step in the above method, and in order to avoid repetition, it will not be described in detail here. The device 600 includes a transceiver unit 601 and a processing unit 602.

[0160] In one possible scenario:

[0161] The transceiver unit 601 is used to receive a configuration file of a business service and an instance for providing the business service from a management node; the configuration file includes an instance template for creating the instance and an image file for creating at least one container included in the instance; the instance template includes indication information for indicating that a control device is used to configure a storage path for each of the at least one container, and the storage space indicated by the storage path belongs to the business node;

[0162] The transceiver unit 601 is further used to send a storage request to the control device; the storage request includes a target path respectively allocated to the at least one container, and the storage request is used to request the control device to configure a storage path for the at least one container respectively, and mount the configured storage path to the corresponding target path respectively;

[0163] A processing unit 602 is configured to deploy the at least one container in the service node according to the image file when it is determined that the control device completes the mounting;

[0164] The processing unit 602 is further configured to mount a target path of a first container to a deployment path of the first container on the service node, where the first container is any one of the at least one container.

[0165] In some embodiments, the storage request also includes the size of the requested storage space.

[0166] In some embodiments, the transceiver unit 601 is further used to receive a deletion instruction from a management node; the deletion instruction is used to instruct to delete the instance;

[0167] The transceiver unit 601 is further used to send an unloading request to the control device; the unloading request is used to request to unload the storage path mounted under the target path corresponding to each of the at least one container;

[0168] The processing unit 602 is further configured to delete the instance when it is determined that the control device has completed uninstallation.

[0169] In another possible scenario:

[0170] The transceiver unit 601 is configured to receive a storage request from a service node, wherein the storage request includes a target path allocated to each of the at least one container;

[0171] A processing unit 602 is configured to allocate storage space for each of the at least one container in the service node according to the storage request; the storage space is used to store container logs;

[0172] The processing unit 602 is further used to mount the storage path of the first storage space allocated to the first container under the target path of the first container; the first container is any one of the at least one container; the target path of the first container is used to mount to the deployment path of the first container deployed in the business node.

[0173] In some embodiments, after mounting the storage path of the first storage space to the target path of the first container, the processing unit 602 is further configured to:

[0174] The state of the first storage space is configured as a writable state.

[0175] In some embodiments, the storage request also includes the size of the requested storage space.

[0176] In some embodiments, the transceiver unit 601 is further used to receive an uninstallation request from the service node; the uninstallation request is used to indicate uninstallation of the storage path mounted under the target path corresponding to each of the at least one container;

[0177] The processing unit 602 is further configured to unmount the storage paths mounted under the target paths respectively corresponding to the at least one container according to the unmounting request;

[0178] The processing unit 602 is further configured to delete the logs in the storage space indicated by the storage path corresponding to the at least one container after a set time period has been reached.

[0179] In another possible scenario:

[0180] Processing unit 602, used to create an instance for providing business services according to the instance template in the configuration file;

[0181] The transceiver unit 601 is used to send the instance and the configuration file to the service node;

[0182] Among them, the configuration file also includes a mirror file, and the instance template also includes indication information, the mirror file is used by the business node to create at least one container included in the instance, and the indication information is used to instruct the business node to request the control device to configure a storage path for the at least one container respectively, and the storage space indicated by the storage path belongs to the business node.

[0183] In some embodiments, the processing unit 602 is further configured to:

[0184] When it is determined that the business service needs to be deleted, the transceiver unit 601 is instructed to send a deletion instruction to the business node; the deletion instruction is used to instruct to delete the instance.

[0185] The present application embodiment also provides another device 700 for implementing a cluster log storage method, see Figure 7 As shown, the device 700 includes a memory 701 and a processor 702. Optionally, the device 700 may further include a communication interface 703. The device 700 may communicate with other devices through the communication interface 703, such as sending and receiving instructions or requests, etc. The communication interface 703 may be used to implement the above Figure 6 The memory 701 is used to store program instructions. The processor 702 is used to call the program instructions stored in the memory 701 and execute any method proposed in the above embodiment according to the obtained program. For example, the processor 702 can be used to implement the above Figure 6 The functions implemented by the processing unit in.

[0186] The specific connection medium between the memory 701, the processor 702 and the communication interface 703 is not limited in the embodiment of the present application, such as a bus. The bus can be divided into an address bus, a data bus, a control bus, etc.

[0187] In the embodiments of the present application, the processor may be a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, and may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.

[0188] In the embodiment of the present application, the memory may be a non-volatile memory, such as a hard disk drive (HDD) or a solid-state drive (SSD), etc., or a volatile memory (volatile memory), such as a random-access memory (RAM). The memory may also be any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory in the embodiment of the present application may also be a circuit or any other device that can implement a storage function, for storing program instructions and / or data.

[0189] An embodiment of the present application also provides a computer-readable storage medium, including a program code. When the program code is executed on a computer, the program code is used to enable the computer to execute the steps of the method provided in the embodiment of the present application.

[0190] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0191] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0192] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0193] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A method for storing cluster logs, characterized in that: Applied to a service node, the method comprises: receiving a configuration file of a business service and an instance for providing the business service from a management node; the configuration file includes an instance template for creating the instance and an image file for creating at least one container included in the instance; the instance template includes indication information for indicating that a control device is used to configure storage paths for the at least one container, respectively, and the storage space indicated by the storage path belongs to the business node; the storage space corresponding to the storage path is used to store container logs; Sending a storage request to the control device; the storage request includes a target path respectively allocated to the at least one container, and the storage request is used to request the control device to configure a storage path respectively for the at least one container, and to mount the configured storage path respectively to the corresponding target path; When it is determined that the control device completes the mounting, deploying the at least one container in the service node according to the image file; Mounting a target path of a first container to a deployment path of the first container on the service node, where the first container is any one of the at least one container; Among them, the storage spaces of multiple containers are independent of each other.

2. The method according to claim 1, characterized in that The storage request also includes the size of the requested storage space.

3. The method according to claim 1 or 2, characterized in that The method further comprises: receiving a deletion instruction from a management node; the deletion instruction is used to instruct to delete the instance; Sending an unloading request to the control device; the unloading request is used to request unloading of the storage path mounted under the target path corresponding to each of the at least one container; When it is determined that the control device has completed the uninstallation, the instance is deleted.

4. A method for storing cluster logs, characterized in that: Applied to a control device, the method comprises: Receiving a storage request from a service node, wherein the storage request includes a target path allocated to at least one container; According to the storage request, storage space is allocated to the at least one container in the service node; the storage space corresponding to the storage path is used to store container logs; Mounting a storage path corresponding to a first storage space allocated to a first container under a target path of the first container; the first container is any one of the at least one container; the target path of the first container is used to mount to a deployment path of the first container deployed in the service node; Among them, the storage spaces of multiple containers are independent of each other.

5. The method according to claim 4, characterized in that The method further comprises: Receiving an uninstallation request from the service node; the uninstallation request is used to instruct to uninstall the storage path mounted under the target path corresponding to each of the at least one container; Unmounting the storage paths mounted under the target paths respectively corresponding to the at least one container according to the unmounting request; After the set time period is reached, the logs in the storage space indicated by the storage path corresponding to the at least one container are deleted.

6. The method according to claim 5, characterized in that After mounting the storage path of the first storage space to the target path of the first container, the method further includes: The state of the first storage space is configured as a writable state.

7. A cluster log control device, characterized in that: include: A transceiver unit, configured to receive a configuration file of a business service and an instance for providing the business service from a management node; the configuration file includes an instance template for creating the instance and an image file for creating at least one container included in the instance; The instance template includes instruction information for instructing the use of a control device to configure storage paths for the at least one container respectively, the storage space indicated by the storage path belongs to the device; the storage space corresponding to the storage path is used to store container logs; The transceiver unit is further used to send a storage request to the control device; the storage request includes a target path respectively allocated to the at least one container, and the storage request is used to request the control device to configure a storage path for the at least one container respectively, and mount the configured storage path to the corresponding target path respectively; a processing unit, configured to deploy the at least one container in the service node according to the image file when it is determined that the control device has completed the mounting; The processing unit is further used to mount the target path of the first container to the deployment path of the first container in the service node, where the first container is any one of the at least one container; wherein the storage spaces of the multiple containers are independent of each other.

8. A cluster log control device, characterized in that: include: A transceiver unit, configured to receive a storage request from a service node, wherein the storage request includes a target path respectively allocated to at least one container; a processing unit, configured to allocate storage space for each of the at least one container in the service node according to the storage request; The storage space corresponding to the storage path is used to store container logs; The processing unit is further used to mount a storage path corresponding to a first storage space allocated to a first container under a target path of the first container; the first container is any one of the at least one container; the target path of the first container is used to mount to a deployment path of the first container deployed in the service node; Among them, the storage spaces of multiple containers are independent of each other.