Container deployment methods, devices, storage media, and electronic devices
By receiving user requests, determining the container type and quantity, and deploying containers on idle physical machines using preset tables and computer algorithms, the problem of low accuracy and efficiency in manual container deployment is solved, achieving efficient and accurate container deployment.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INDUSTRIAL AND COMMERCIAL BANK OF CHINA
- Filing Date
- 2023-03-27
- Publication Date
- 2026-06-30
AI Technical Summary
Existing technologies that manually deploy containers have low accuracy and efficiency, resulting in complex container deployment and a high risk of anomalies.
By receiving user application requests, the container type and quantity are determined, idle physical machines are identified based on the target data center information, and containers are deployed on these idle physical machines according to their type and quantity. The container deployment scheme is optimized using preset tables and computer algorithms.
It improves the accuracy and efficiency of container deployment, and reduces the complexity of manual operations and the occurrence of container anomalies.
Smart Images

Figure CN116302356B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of big data, and more specifically, to a container deployment method, apparatus, storage medium, and electronic device. Background Technology
[0002] Docker containers are an open-source application container engine that allows developers to package their applications and dependencies into a portable container and then deploy it to any popular Linux machine, effectively achieving virtualization. Containers are completely sandboxed, with no interfaces between them. They incur virtually no performance overhead and can easily run on machines and in data centers. Most importantly, they are independent of any language, framework, or system.
[0003] As the application of database containerization in enterprises gradually expands, a large number of container deployments are required. However, currently, building a database container requires manually selecting a specific host machine, i.e., a physical machine, for each database container.
[0004] The current designated deployment method requires consideration of the physical machine's location and performance, and then container deployment is based on the physical machine's performance and location. Since the selection of physical machines for container deployment currently requires manual selection, the process is very cumbersome. Furthermore, it requires consideration of the physical machine's remaining CPU, memory, and storage resources before allocation, making container deployment quite complex. The accuracy of manually determining the deployment plan is also low, easily leading to abnormal container deployments.
[0005] There is currently no effective solution to the problem of low accuracy and efficiency in manually deploying containers in related technologies. Summary of the Invention
[0006] This application provides a container deployment method, apparatus, storage medium, and electronic device to solve the problems of low accuracy and efficiency in manually deploying containers in related technologies.
[0007] According to one aspect of this application, a method for deploying containers is provided. The method includes: receiving an application request sent by a user, wherein the application request is for requesting the generation of containers; determining container information indicated by the application request, wherein the container information includes a container type and a container quantity; determining target data center information indicated by the application request, determining idle physical machines based on each physical machine information in the target data center information, obtaining M idle physical machines, wherein the target data center information includes multiple physical machine information; and deploying containers on the M idle physical machines according to the container type and the container quantity.
[0008] Optionally, determining the container information indicated by the application request includes: determining the business content indicated by the application request and inputting the business content into a preset table, obtaining the business level of the business content through the preset table, wherein the preset table includes the business content and the business level of each business content; obtaining a level classification table, and determining the container type corresponding to the business level and the number of containers corresponding to each type from the level classification table to obtain container information, wherein the level classification table includes the business level and the container information corresponding to each business level.
[0009] Optionally, the physical machine information includes remaining CPU capacity, remaining memory capacity, and remaining disk space. Determining an idle physical machine based on each physical machine information in the target data center information includes: obtaining the CPU usage of the container to be built generated by the application request indication, and dividing the remaining CPU capacity by the CPU usage to obtain a first quantity; obtaining the memory usage of the container to be built, and dividing the remaining memory capacity by the memory usage to obtain a second quantity; obtaining the disk usage of the container to be built, and dividing the remaining disk space by the disk usage to obtain a third quantity; determining whether the first quantity, the second quantity, and the third quantity are all greater than or equal to 1; if at least one of the first quantity, the second quantity, or the third quantity is less than 1, the physical machine is determined to be a fully loaded physical machine; if the first quantity, the second quantity, and the third quantity are all greater than or equal to 1, the physical machine is determined to be an idle physical machine.
[0010] Optionally, the container type includes a primary container and a standby container. Deploying containers in M idle physical machines according to the container type and the number of containers includes: obtaining a first quantity, a second quantity, and a third quantity in each idle physical machine to obtain an attribute dataset for each idle physical machine; obtaining the minimum data value in each attribute dataset to obtain a first data value set, and determining the maximum data value in the first data value set to obtain a second data value; determining the idle physical machine to which the second data value belongs as the first physical machine, and inputting the primary container information from the container information into the first physical machine to build the primary container through the first physical machine, wherein the first data value set consists of M primary data values; subtracting 1 from the number of containers to obtain a fourth quantity N, and randomly selecting N physical machines from the non-first physical machines in the M idle physical machines to obtain N second physical machines, wherein N is a positive integer greater than or equal to 1; inputting the standby container information from the container information into the N second physical machines, and building a standby container through each second physical machine to obtain N standby containers.
[0011] Optionally, after determining that the idle physical machine to which the second data value belongs is the first physical machine, the method further includes: determining whether a main container exists in the first physical machine; if a main container exists in the first physical machine, repeatedly executing the steps of deleting the second data value from the first data value set to obtain an updated first data value set, re-determining the maximum data value in the updated first data value set to obtain an updated second data value, and determining the first physical machine to which the updated second data value belongs, until there is no main container in the first physical machine to which the updated second data value belongs; if there is no main container in the first physical machine, executing the step of inputting the main container information from the container information into the first physical machine, and building the main container through the first physical machine.
[0012] Optionally, before randomly selecting N physical machines from the non-first physical machines among the M idle physical machines to obtain N second physical machines, the method further includes: determining whether the value of M is greater than or equal to the value of N; if the value of M is less than the value of N, obtaining the information of other data centers besides the target data center; obtaining any data center information from the other data center information to obtain the backup data center information, and building NM backup containers on the idle physical machines in the backup data center information.
[0013] Optionally, after determining the target data center information indicated by the application request, and determining the available physical machines based on each physical machine information in the target data center information to obtain M available physical machines, the method further includes: obtaining data center information of other data centers besides the target data center information to obtain X candidate data center information; determining the number of available physical machines in each candidate data center information to obtain X candidate values; determining whether there is a value greater than M among the X candidate values; if there is no value greater than M among the X candidate values, performing the step of deploying containers in the M available physical machines according to the container type and the number of containers; if there is a value greater than M among the X candidate values, determining the candidate data center information to which the largest candidate value among the X candidate values belongs, obtaining replacement data center information, and changing the target data center information to the replacement data center information.
[0014] According to another aspect of this application, a container deployment apparatus is provided. The apparatus includes: a receiving unit for receiving an application request sent by a user, wherein the application request requests the generation of a container; a first determining unit for determining container information indicated by the application request, wherein the container information includes a container type and a container quantity; a second determining unit for determining target data center information indicated by the application request, and determining idle physical machines based on each physical machine information in the target data center information to obtain M idle physical machines, wherein the target data center information includes multiple physical machine information; and a deployment unit for deploying containers on the M idle physical machines according to the container type and the container quantity.
[0015] According to another aspect of the present invention, a computer storage medium is also provided for storing a program, wherein the program, when running, controls the device where the computer storage medium is located to execute a container deployment method.
[0016] According to another aspect of the present invention, an electronic device is also provided, comprising one or more processors and a memory; the memory stores computer-readable instructions, and the processor is configured to execute the computer-readable instructions, wherein the computer-readable instructions, when executed, perform a container deployment method.
[0017] This application employs the following steps: receiving an application request sent by a user, wherein the application request requests the generation of containers; determining the container information indicated by the application request, wherein the container information includes container type and container quantity; determining the target data center information indicated by the application request, determining idle physical machines based on each physical machine information in the target data center information, resulting in M idle physical machines, wherein the target data center information includes multiple physical machine information; and deploying containers on the M idle physical machines according to the container type and container quantity. This solves the problems of low accuracy and efficiency in manual container deployment in related technologies. By determining the data center information, container type, and container quantity indicated by the application request, the method of container deployment on multiple physical machines in the data center is determined, and deployment is performed on multiple physical machines according to deployment rules based on container type and container quantity. By calculating the configuration relationship between each physical machine and the container, the container deployment scheme is determined, thereby improving the efficiency and accuracy of container deployment. Attached Figure Description
[0018] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0019] Figure 1 This is a schematic diagram of a container deployment system provided according to an embodiment of this application;
[0020] Figure 2 This is a flowchart of a container deployment method provided according to an embodiment of this application;
[0021] Figure 3 This is a schematic diagram of a container deployment apparatus provided according to an embodiment of this application;
[0022] Figure 4 This is a schematic diagram of an electronic device provided according to an embodiment of this application. Detailed Implementation
[0023] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0024] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0025] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0026] It should be noted that all information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are information and data authorized by the user or fully authorized by all parties. For example, this system has an interface with relevant users or organizations. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain the relevant information after receiving consent information from the aforementioned user or organization.
[0027] It should be noted that the container deployment methods, apparatus, storage media, and electronic devices defined in this disclosure can be used in the big data field, or in any field other than the big data field. The application fields of the container deployment methods, apparatus, storage media, and electronic devices defined in this disclosure are not limited.
[0028] In this embodiment, as Figure 1 As shown, the aforementioned container deployment system method is executed using an optional container deployment system as the execution subject. The container deployment system includes at least: an application request module 101, a service control module 102, a resource pool 103, and a container cluster 104.
[0029] The application request module 101 is responsible for where applications submit database container resource requests, including information such as architecture, number of shards, container CPU and memory specifications, and storage specifications. CPU (Central Processing Unit) is one such instance.
[0030] Service control module 102 is responsible for receiving application requests, determining the number of primary and backup containers based on the application's disaster recovery level, calculating the number of container nodes to be built in each data center based on the number of shards, obtaining the list of physical machine resources (remaining CPU, memory, network, storage) for the data centers to be deployed, filtering the application-specified architecture (x86 / arm), and after confirming the resources, first allocating the primary container for each shard, and then allocating the backup container for each shard.
[0031] Resource pool 103 is responsible for managing physical machine resources, including information such as CPU, memory, network, and disk storage.
[0032] Container cluster 104 is responsible for creating database containers and providing database services.
[0033] According to an embodiment of this application, a method for deploying containers is provided.
[0034] Figure 2 This is a flowchart of a container deployment method provided according to an embodiment of this application. For example... Figure 2 As shown, the method includes the following steps:
[0035] Step S201: Receive an application request sent by the user, wherein the application request is used to request the generation of a container.
[0036] Specifically, the application request may include the specifications of the container that the user wants to create, including information such as architecture, number of shards, container CPU and memory specifications, and storage specifications. The container generation and deployment plan is determined based on the container specifications and the importance level in the application request.
[0037] Step S202: Determine the container information indicated by the application request, wherein the container information includes the container type and the number of containers.
[0038] Specifically, after obtaining the importance level of an application request, the required number of containers and their deployment requirements can be determined based on the importance level. This allows the physical machines for container deployment to be determined according to the number of containers, deployment requirements, and container specifications. Container type includes the type of containers to be deployed under each importance level (e.g., only the primary container needs to be deployed, or both a primary and backup container need to be deployed), and the number of containers of each type (e.g., one primary container and three backup containers).
[0039] Step S203: Determine the target data center information indicated by the application request, and determine the available physical machines based on each physical machine information in the target data center information to obtain M available physical machines. The target data center information includes A physical machine information, and the value of A is greater than the value of M.
[0040] Specifically, after receiving an application request, the number of physical machines in the data center can be determined first, resulting in A physical machines. Based on the data center information indicated in the application request, the physical machine information in that data center can be determined, thereby determining whether a new container can be created in that data center. Therefore, each physical machine needs to be confirmed, and physical machines that can be deployed for containers are selected from the A physical machines, resulting in M idle physical machines. Furthermore, if container deployment cannot be performed in that data center, other data centers are selected for collaborative deployment, thus ensuring the normal execution of the application request and the normal use of the container.
[0041] Step S204: Deploy containers in M idle physical machines according to container type and container quantity.
[0042] Specifically, once the available physical machines are identified, containers can be deployed to them based on their type and quantity, thus completing the container deployment for the application request. For example, if there are 5 available physical machines in data center A, and one primary container and one backup container need to be deployed, the primary container can be deployed on any of the available physical machines, and the backup container can be deployed on any of the other 4 available physical machines, thus completing the container deployment.
[0043] The container deployment method provided in this application embodiment receives an application request sent by a user, wherein the application request requests the generation of containers; determines the container information indicated by the application request, wherein the container information includes container type and container quantity; determines the target data center information indicated by the application request, and determines idle physical machines based on each physical machine information in the target data center information, resulting in M idle physical machines, wherein the target data center information includes multiple physical machine information; and deploys containers on the M idle physical machines according to the container type and container quantity. This solves the problems of low accuracy and efficiency in manual container deployment in related technologies. By determining the data center information, container type, and container quantity indicated by the application request, the method of container deployment on multiple physical machines in the data center is determined, and deployment is performed on multiple physical machines according to deployment rules based on container type and container quantity. By calculating the configuration relationship between each physical machine and the container, the container deployment scheme is determined, thereby improving the efficiency and accuracy of container deployment.
[0044] Optionally, in the container deployment method provided in this application embodiment, determining the container information indicated by the application request includes: determining the business content indicated by the application request, inputting the business content into a preset table, obtaining the business level of the business content through the preset table, wherein the preset table includes the business content and the business level of each business content; obtaining a level classification table, and determining the container type corresponding to the business level and the number of containers corresponding to each type from the level classification table to obtain container information, wherein the level classification table includes the business level and the container information corresponding to each business level.
[0045] Specifically, Table 1 is a comparison table of optional business levels and container information. As shown in Table 1, after obtaining the business content, the business level, i.e. the importance level, of the business content can be determined according to the preset table. Then, the container type and the number of containers under each type can be determined according to the business level, thereby ensuring that the container deployment scheme can meet the application of the business content.
[0046] Table 1
[0047] Business Level Number of main containers Number of spare containers 1 1 1 2 1 1 3 1 2 4 1 3 5 1 4
[0048] Optionally, in the container deployment method provided in this application embodiment, the physical machine information includes remaining CPU capacity, remaining memory capacity, and remaining disk space. Determining an idle physical machine based on each physical machine information in the target data center information includes: obtaining the CPU usage of the container to be built generated by the application request indication, and dividing the remaining CPU capacity by the CPU usage to obtain a first quantity; obtaining the memory usage of the container to be built, and dividing the remaining memory capacity by the memory usage to obtain a second quantity; obtaining the disk usage of the container to be built, and dividing the remaining disk space by the disk usage to obtain a third quantity; determining whether the first quantity, the second quantity, and the third quantity are all greater than or equal to 1; if at least one of the first quantity, the second quantity, or the third quantity is less than 1, determining the physical machine as a fully loaded physical machine; if the first quantity, the second quantity, and the third quantity are all greater than or equal to 1, determining the physical machine as an idle physical machine.
[0049] Specifically, after obtaining the number and type of containers, the specifications of the containers can be obtained, including: CPU usage, memory usage, and disk usage for each container. At this point, it is necessary to determine the remaining CPU capacity, remaining memory capacity, and remaining disk space of each physical machine in the target data center in its current state. The remaining CPU capacity is then divided by the CPU usage to obtain the first quantity, the remaining memory capacity is divided by the memory usage to obtain the second quantity, and the remaining disk space is divided by the disk usage to obtain the third quantity. By calculating the relationship between the remaining system configuration of the containers and the physical machines, it can be determined whether the physical machines can install the containers.
[0050] Furthermore, if the first, second, and third quantities are all greater than or equal to 1, indicating that a container can be deployed in the physical machine, then the physical machine is considered an idle physical machine.
[0051] Optionally, in the container deployment method provided in this application embodiment, the container type includes a main container and a standby container. Deploying containers in M idle physical machines according to the container type and the number of containers includes: obtaining a first quantity, a second quantity, and a third quantity in each idle physical machine to obtain an attribute dataset for each idle physical machine; obtaining the minimum data value in each attribute dataset to obtain a first data value set, and determining the maximum data value in the first data value set to obtain a second data value; determining the idle physical machine to which the second data value belongs as the first physical machine, and inputting the main container information from the container information into the first physical machine to build the main container through the first physical machine, wherein the first data value set consists of M first data values; subtracting 1 from the number of containers to obtain a fourth quantity N, and randomly selecting N physical machines from the non-first physical machines in the M idle physical machines to obtain N second physical machines, wherein N is a positive integer greater than or equal to 1; inputting the standby container information from the container information into the N second physical machines, and building a standby container through each second physical machine to obtain N standby containers.
[0052] Specifically, after obtaining the first, second, and third quantities of each idle physical machine, it is necessary to determine the minimum value among the first, second, and third quantities to obtain the maximum number of containers that can be deployed in each idle physical machine. Then, the physical machine with the largest maximum number of containers is determined from the M idle physical machines, and the main container is deployed in that physical machine to ensure that the probability of the main container malfunctioning is minimized.
[0053] Furthermore, after the main container is deployed, it is necessary to determine the physical machines for deploying the N backup containers corresponding to the main container. At this time, it is necessary to determine the first physical machine from the M idle physical machines, that is, the physical machine for deploying the main container of the application request, and randomly select N physical machines from the M-1 idle physical machines other than the first physical machine, that is, the fourth number of idle physical machines. One backup container is deployed on each of the selected idle physical machines, thereby completing the deployment of the container on multiple physical machines in the target data center.
[0054] For example, if an application request requires the deployment of one main container and two backup containers, and there are five idle physical machines in the target data center, and the main container is deployed on the second idle physical machine, then the two backup containers need to be deployed on any two of the other four idle physical machines besides the second idle physical machine to complete the container deployment.
[0055] Optionally, in the container deployment method provided in this application embodiment, after determining that the idle physical machine to which the second data value belongs is the first physical machine, the method further includes: determining whether there is a main container in the first physical machine; if there is a main container in the first physical machine, repeatedly executing the steps of deleting the second data value from the first data value set to obtain an updated first data value set, re-determining the maximum data value in the updated first data value set to obtain an updated second data value, and determining the first physical machine to which the updated second data value belongs, until there is no main container in the first physical machine to which the updated second data value belongs; if there is no main container in the first physical machine, executing the step of inputting the main container information from the container information into the first physical machine, and building the main container through the first physical machine.
[0056] Specifically, when determining the first physical machine, it is necessary to determine whether there is already a main container that other applications request to deploy on the first physical machine. If the main container has already been deployed on the first physical machine, the main container requested by this application cannot be deployed on the first physical machine. In this case, the physical machine needs to be removed from the M idle physical machines, and the first physical machine needs to be re-determined from the remaining M-1 idle physical machines, so as to ensure that only one main container is deployed on each physical machine.
[0057] Optionally, in the container deployment method provided in this application embodiment, before randomly selecting N physical machines from the non-first physical machines among M idle physical machines to obtain N second physical machines, the method further includes: determining whether the value of M is greater than the value of N; if the value of M is less than or equal to the value of N, obtaining the information of other data centers besides the target data center; obtaining any data center information from the other data center information to obtain backup data center information, and building NM backup containers on the idle physical machines in the backup data center information.
[0058] Specifically, after determining the fourth number N of backup containers, it is necessary to determine whether there are enough idle physical machines based on the total number of idle physical machines in the target data center. At this time, the number M of idle physical machines needs to be compared with the fourth number N. If M is greater than or equal to N, it means that the idle physical machines in the target data center can perform this container deployment operation, and deployment is carried out. If M is less than N, it means that the number of idle physical machines in the target data center is less than the number of containers to be deployed. In this case, all idle physical machines in the target data center need to deploy containers, and containers that cannot be deployed in the target data center also need to be deployed in other data centers to ensure the normal deployment operation of containers.
[0059] Optionally, in the container deployment method provided in this application embodiment, after determining the target data center information indicated by the application request, determining the idle physical machines based on each physical machine information in the target data center information, and obtaining M idle physical machines, the method further includes: obtaining data center information of other data centers besides the target data center information, and obtaining X candidate data center information; determining the number of idle physical machines in each candidate data center information, and obtaining X candidate values; determining whether there is a value greater than M among the X candidate values; if there is no value greater than M among the X candidate values, performing the step of deploying containers in the M idle physical machines according to the container type and the number of containers; if there is a value greater than M among the X candidate values, determining the candidate data center information to which the largest candidate value among the X candidate values belongs, obtaining replacement data center information, and changing the target data center information to the replacement data center information.
[0060] Specifically, after determining the target data center, the information of other data centers can also be determined. This allows us to determine whether there are data centers that are more suitable for creating containers than the target data center.
[0061] Once the remaining data centers are available, the number of available physical machines in each data center can be determined, and the data center information corresponding to the maximum number of available machines can be identified. If this data center is the target data center, subsequent operations can be performed. If this data center is not the target data center but another data center, the data center corresponding to the maximum number of available machines can be identified as the target data center, thereby improving the effectiveness of container deployment.
[0062] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0063] This application also provides a container deployment apparatus. It should be noted that the container deployment apparatus of this application can be used to execute the container deployment method provided in this application. The container deployment apparatus provided in this application will be described below.
[0064] Figure 3 This is a schematic diagram of a container deployment apparatus provided according to an embodiment of this application. Figure 3 As shown, the device includes: a receiving unit 31, a first determining unit 32, a second determining unit 33, and a deployment unit 34.
[0065] The receiving unit 31 is used to receive application requests sent by users, wherein the application requests are used to request the generation of containers.
[0066] The first determining unit 32 is used to determine the container information indicated by the application request, wherein the container information includes the container type and the number of containers.
[0067] The second determining unit 33 is used to determine the target data center information indicated by the application request, and to determine the available physical machines based on each physical machine information in the target data center information, thereby obtaining M available physical machines, wherein the target data center information includes multiple physical machine information.
[0068] Deployment unit 34 is used to deploy containers in M idle physical machines according to the container type and the number of containers.
[0069] The container deployment apparatus provided in this application embodiment receives an application request sent by a user through a receiving unit 31, wherein the application request is used to request the generation of containers; a first determining unit 32 determines the container information indicated by the application request, wherein the container information includes container type and container quantity; a second determining unit 33 determines the target data center information indicated by the application request, and determines idle physical machines based on each physical machine information in the target data center information, resulting in M idle physical machines, wherein the target data center information includes multiple physical machine information; a deployment unit 34 deploys containers in the M idle physical machines according to the container type and container quantity. This solves the problems of low accuracy and efficiency in manual container deployment in related technologies. By determining the data center information, container type, and container quantity indicated by the application request, the method of container deployment in multiple physical machines in the data center is determined, and deployment is performed in multiple physical machines according to deployment rules based on the container type and container quantity. By calculating the configuration relationship between each physical machine and the container, the container deployment scheme is determined, thereby improving the efficiency and accuracy of container deployment.
[0070] Optionally, in the container deployment apparatus provided in this application embodiment, the first determining unit 32 includes: a first determining module, configured to determine the service content indicated by the application request, input the service content into a preset table, and obtain the service level of the service content through the preset table, wherein the preset table includes the service content and the service level of each service content; and a first obtaining module, configured to obtain a level classification table, and determine the container type corresponding to the service level and the number of containers corresponding to each type from the level classification table to obtain container information, wherein the level classification table includes the service level and the container information corresponding to each service level.
[0071] Optionally, in the container deployment apparatus provided in this application embodiment, the physical machine information includes remaining CPU capacity, remaining memory capacity, and remaining disk space. The second determining unit 33 includes: a first calculation module, used to obtain the CPU usage of the container to be built generated by the application request instruction, and divide the remaining CPU capacity by the CPU usage to obtain a first quantity; a second calculation module, used to obtain the memory usage of the container to be built, and divide the remaining memory capacity by the memory usage to obtain a second quantity; a third calculation module, used to obtain the disk usage of the container to be built, and divide the remaining disk space by the disk usage to obtain a third quantity; a judging module, used to judge whether the first quantity, the second quantity, and the third quantity are all greater than or equal to 1; a second determining module, used to determine that the physical machine is a fully loaded physical machine when at least one of the first quantity, the second quantity, or the third quantity is less than 1; and a third determining module, used to determine that the physical machine is an idle physical machine when the first quantity, the second quantity, and the third quantity are all greater than or equal to 1.
[0072] Optionally, in the container deployment apparatus provided in this application embodiment, the container type includes a main container and a standby container. The deployment unit 34 includes: a second acquisition module, used to acquire a first quantity, a second quantity, and a third quantity in each idle physical machine to obtain an attribute dataset for each idle physical machine; a third acquisition module, used to acquire the minimum data value in each attribute dataset to obtain a first data value set, and determine the maximum data value in the first data value set to obtain a second data value; a fourth determination module, used to determine that the idle physical machine to which the second data value belongs is the first physical machine, and input the main container information in the container information into the first physical machine to build the main container through the first physical machine, wherein the first data value set consists of M first data values; a selection module, used to subtract 1 from the container quantity to obtain a fourth quantity N, and randomly select N physical machines from the non-first physical machines in the M idle physical machines to obtain N second physical machines, wherein N is a positive integer greater than or equal to 1; and an input module, used to input the standby container information in the container information into the N second physical machines, and build a standby container through each second physical machine to obtain N standby containers.
[0073] Optionally, in the container deployment apparatus provided in this application embodiment, the apparatus further includes: a first determining unit, configured to determine whether a main container exists in a first physical machine; a first executing unit, configured to, when a main container exists in the first physical machine, repeatedly execute the steps of deleting a second data value from a first data value set to obtain an updated first data value set, re-determining the maximum data value in the updated first data value set to obtain an updated second data value, and determining the first physical machine to which the updated second data value belongs, until a main container does not exist in the first physical machine to which the updated second data value belongs; and a second executing unit, configured to, when a main container does not exist in the first physical machine, execute the step of inputting the main container information from the container information into the first physical machine and building a main container through the first physical machine.
[0074] Optionally, in the container deployment device provided in the embodiments of this application, the device further includes: a second judgment unit, used to judge whether the value of M is greater than or equal to the value of N; a calculation unit, used to obtain the remaining data center information other than the target data center information when the value of M is less than the value of N; and a first acquisition unit, used to acquire any data center information from the remaining data center information to obtain the backup data center information, and to build NM backup containers on the idle physical machines in the backup data center information.
[0075] Optionally, in the container deployment apparatus provided in this application embodiment, the apparatus further includes: a second acquisition unit, configured to acquire data center information of other data centers besides the target data center information, to obtain X candidate data center information; a fourth determination unit, configured to determine the number of idle physical machines in each candidate data center information, to obtain X candidate values; a third judgment unit, configured to determine whether there is a value greater than M among the X candidate values; a third execution unit, configured to execute the step of deploying containers in M idle physical machines according to container type and container quantity if there is no value greater than M among the X candidate values; and a fifth determination unit, configured to determine the candidate data center information to which the largest candidate value among the X candidate values belongs if there is a value greater than M among the X candidate values, to obtain replacement data center information, and to change the target data center information to the replacement data center information.
[0076] The container deployment device includes a processor and a memory. The receiving unit 31, the first determining unit 32, the second determining unit 33, the deployment unit 34, etc. are all stored in the memory as program units. The processor executes the program units stored in the memory to realize the corresponding functions.
[0077] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured; adjusting kernel parameters addresses the low accuracy and efficiency issues associated with manually deploying containers in related technologies.
[0078] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0079] This invention provides a computer-readable storage medium storing a program that, when executed by a processor, implements a method for deploying a container.
[0080] This invention provides a processor for running a program, wherein the program executes a deployment method for the container during runtime.
[0081] like Figure 4 As shown, this embodiment of the invention provides an electronic device 40, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs the following steps: receiving an application request sent by a user, wherein the application request is used to request the generation of a container; determining container information indicated by the application request, wherein the container information includes a container type and a container quantity; determining target data center information indicated by the application request, determining idle physical machines based on each physical machine information in the target data center information, obtaining M idle physical machines, wherein the target data center information includes multiple physical machine information; and deploying containers on the M idle physical machines according to the container type and the container quantity. The device in this document can be a server, PC, PAD, mobile phone, etc.
[0082] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program having the following method steps: receiving an application request sent by a user, wherein the application request is used to request the generation of a container; determining container information indicated by the application request, wherein the container information includes a container type and a container quantity; determining target data center information indicated by the application request, determining idle physical machines based on each physical machine information in the target data center information, obtaining M idle physical machines, wherein the target data center information includes multiple physical machine information; and deploying containers in the M idle physical machines according to the container type and the container quantity.
[0083] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0084] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0085] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0086] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0087] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0088] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0089] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0090] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0091] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for deploying a container, characterized in that, include: Receive an application request sent by a user, wherein the application request is used to request the generation of a container; Determine the container information indicated by the application request, wherein the container information includes container type and container quantity, and the container type includes primary container and standby container; Determine the target data center information indicated by the application request, and determine the available physical machines based on each physical machine information in the target data center information to obtain M available physical machines, where M is greater than or equal to 1; Deploying containers in the M idle physical machines according to the container type and the container quantity includes: obtaining a first quantity, a second quantity, and a third quantity in each idle physical machine to obtain an attribute dataset for each idle physical machine; obtaining the minimum data value in each attribute dataset to obtain a first data value set, and determining the maximum data value in the first data value set to obtain a second data value, wherein the first data value set consists of M first data values; determining the idle physical machine to which the second data value belongs as the first physical machine, and inputting the main container information from the container information into the first physical machine to build the main container through the first physical machine; subtracting 1 from the container quantity to obtain a fourth quantity N, and randomly selecting N physical machines from the non-first physical machines in the M idle physical machines to obtain N second physical machines, wherein N is a positive integer greater than or equal to 1; inputting the spare container information from the container information into the N second physical machines, and building a spare container through each second physical machine to obtain N spare containers.
2. The method according to claim 1, characterized in that, The container information indicated by the application request includes: The service content indicated by the application request is determined, and the service content is entered into a preset table. The service level of the service content is obtained through the preset table, wherein the preset table includes the service content and the service level of each service content. Obtain a classification table, and determine the container type corresponding to the business level and the number of containers corresponding to each type from the classification table to obtain the container information. The classification table includes the business level and the container information corresponding to each business level.
3. The method according to claim 1, characterized in that, The physical machine information includes remaining CPU capacity, remaining memory capacity, and remaining disk space. The available physical machines are determined based on each piece of physical machine information in the target data center information, including: Obtain the CPU usage of the container to be built generated by the application request instruction, and divide the remaining CPU capacity by the CPU usage to obtain a first quantity; Obtain the memory usage of the container to be built, and divide the remaining memory capacity by the memory usage to obtain the second quantity; Obtain the disk usage of the container to be built, and divide the remaining disk amount by the disk usage to obtain the third quantity; Determine whether the first quantity, the second quantity, and the third quantity are all greater than or equal to 1; If at least one of the first quantity, the second quantity, or the third quantity is less than 1, the physical machine is determined to be a fully loaded physical machine. If the first quantity, the second quantity, and the third quantity are all greater than or equal to 1, the physical machine is determined to be the idle physical machine.
4. The method according to claim 1, characterized in that, After determining that the idle physical machine to which the second data value belongs is the first physical machine, the method further includes: Determine whether a main container exists in the first physical machine; If the main container exists in the first physical machine, the steps of deleting the second data value from the first data value set, obtaining an updated first data value set, re-determining the maximum data value in the updated first data value set, obtaining an updated second data value, and determining the first physical machine to which the updated second data value belongs are repeated until the main container does not exist in the first physical machine to which the updated second data value belongs. If the main container does not exist in the first physical machine, the step of inputting the main container information from the container information into the first physical machine and building the main container through the first physical machine is executed.
5. The method according to claim 1, characterized in that, Before randomly selecting N physical machines from the non-first physical machines among the M idle physical machines to obtain N second physical machines, the method further includes: Determine if the value of M is greater than or equal to the value of N; If the value of M is less than the value of N, obtain the information of other computer rooms besides the target computer room information; Obtain any data center information from the remaining data center information to obtain backup data center information, and build NM backup containers on the idle physical machines in the backup data center information.
6. The method according to claim 1, characterized in that, After determining the target data center information indicated by the application request, and determining the available physical machines based on each physical machine information in the target data center information to obtain M available physical machines, the method further includes: Obtain the data center information of the remaining data centers besides the target data center information to obtain X candidate data center information; Determine the number of available physical machines for each candidate data center to obtain X candidate values; Determine whether there is a value greater than M among the X candidate values; If none of the X candidate values is greater than M, then the step of deploying containers in the M idle physical machines according to the container type and the number of containers is performed. If there is a value greater than M among the X candidate values, determine the candidate data center information to which the largest candidate value among the X candidate values belongs, obtain the replacement data center information, and change the target data center information to the replacement data center information.
7. A container deployment apparatus, characterized in that, include: A receiving unit is used to receive an application request sent by a user, wherein the application request is used to request the generation of a container; The first determining unit is used to determine the container information indicated by the application request, wherein the container information includes container type and container quantity, and the container type includes main container and standby container; The second determining unit is used to determine the target data center information indicated by the application request, and to determine the available physical machines based on each physical machine information in the target data center information, thereby obtaining M available physical machines. A deployment unit is configured to deploy containers in the M idle physical machines according to the container type and the number of containers; The deployment unit includes: a second acquisition module, used to acquire a first quantity, a second quantity, and a third quantity in each idle physical machine to obtain an attribute dataset for each idle physical machine; a third acquisition module, used to acquire the minimum data value in each attribute dataset to obtain a first data value set, and determine the maximum data value in the first data value set to obtain a second data value, wherein the first data value set consists of M first data values; a fourth determination module, used to determine that the idle physical machine to which the second data value belongs is a first physical machine, and input the main container information from the container information into the first physical machine to build a main container through the first physical machine; a selection module, used to subtract 1 from the container quantity to obtain a fourth quantity N, and randomly select N physical machines from the non-first physical machines among the M idle physical machines to obtain N second physical machines, wherein N is a positive integer greater than or equal to 1; and an input module, used to input the spare container information from the container information into the N second physical machines, and build a spare container through each second physical machine to obtain N spare containers.
8. A computer storage medium, characterized in that, The computer storage medium is used to store a program, wherein the program, when running, controls the device where the computer storage medium is located to execute the container deployment method according to any one of claims 1 to 6.
9. An electronic device, characterized in that, It includes one or more processors and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the container deployment method according to any one of claims 1 to 6.