WO2022057317A1 - Computing resource allocation method and related device - Google Patents

Computing resource allocation method and related device Download PDF

Info

Publication number
WO2022057317A1
WO2022057317A1 PCT/CN2021/097603 CN2021097603W WO2022057317A1 WO 2022057317 A1 WO2022057317 A1 WO 2022057317A1 CN 2021097603 W CN2021097603 W CN 2021097603W WO 2022057317 A1 WO2022057317 A1 WO 2022057317A1
Authority
WO
WIPO (PCT)
Prior art keywords
virtual machine
computing resource
configuration file
hot
container
Prior art date
Application number
PCT/CN2021/097603
Other languages
French (fr)
Chinese (zh)
Inventor
姜智成
Original Assignee
北京金山云网络技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京金山云网络技术有限公司 filed Critical 北京金山云网络技术有限公司
Publication of WO2022057317A1 publication Critical patent/WO2022057317A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5061Partitioning or combining of resources
    • G06F9/5072Grid computing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45575Starting, stopping, suspending or resuming virtual machine instances
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45583Memory management, e.g. access or allocation

Definitions

  • the present application relates to the field of computer technologies, and in particular, to a computing resource allocation method and related equipment.
  • k8s kubernetes
  • kata a cluster system based on kubernetes
  • multiple containers are deployed in virtual machines as computing nodes.
  • sufficient computing resources such as computing resources such as CPU and memory
  • the virtual machine can meet the computing resource requirements of the containers deployed thereon.
  • the embodiments of the present application provide a computing resource allocation method and related devices, which can realize computing resource allocation of a virtual machine.
  • An embodiment of the present application provides a computing resource allocation method, including: starting a virtual machine; obtaining a first configuration file provided by a user; when it is determined that the first configuration file includes computing resource requirements of a virtual machine, according to the first configuration file The computing resource requirements of the virtual machine in the virtual machine are determined, and the computing resources to be hot-plugged of the virtual machine are determined; and the computing resources to be hot-plugged are hot-plugged into the virtual machine.
  • the determining the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file includes: parsing the first configuration file to obtain the virtual machine computing resource requirements; determining the computing resources to be hot-plugged for the virtual machine according to the computing resource requirements of the virtual machine.
  • the determining the computing resources to be hot-plugged for the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file includes: acquiring a second configuration file, where the second configuration file includes: The basic resource requirements of the virtual machine; when it is determined that the basic resource requirements meet the preset conditions, according to the basic resource requirements and the computing resource requirements of the virtual machine in the first configuration file, determine the waiting time of the virtual machine.
  • Hot-plug computing resources when it is determined that the basic resource requirements do not meet the preset conditions, determine the computing resources to be hot-plugged for the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file.
  • the determining the computing resources to be hot-plugged of the virtual machine according to the basic resource requirements and the computing resource requirements of the virtual machine in the first configuration file includes: according to the basic resource requirements and the computing resources of the virtual machine. Allocate resources according to a preset standard, and obtain a resource difference; determine the computing resources to be hot-plugged for the virtual machine according to the resource difference and the computing resource requirements of the virtual machine in the first configuration file.
  • the method further includes: when it is determined that the first configuration file does not include the computing resource requirements of the virtual machine, and it is determined that the first configuration file includes the computing resource requirements of the container, according to the first configuration file The computing resource requirements of the container in the virtual machine are determined, and the computing resources to be hot-plugged of the virtual machine are determined.
  • the first configuration file when N containers are deployed on the virtual machine, and the first configuration file includes the container computing resource requirements of the first container to the container computing resource requirements of the Nth container, the The container computing resource requirements in the first configuration file, and determining the virtual machine's to-be-hot-plugged computing resources, including: according to the container computing resource requirements of the first container to the Nth container. The sum of the container computing resource requirements of the container to obtain the computing resources to be hot-plugged of the virtual machine.
  • the method further includes: starting a container deployed on the virtual machine, and corresponding to the container according to the container computing resource requirement. to configure the container control group.
  • the embodiment of the present application further provides a computing resource allocation device, including: a startup unit, set to start a virtual machine; a first acquisition unit, set to acquire a first configuration file provided by a user; a first determination unit, set to determine When the first configuration file includes the computing resource requirements of the virtual machine, according to the computing resource requirements of the virtual machine in the first configuration file, determine the computing resources of the virtual machine to be hot-plugged; the hot-plug unit is set to The computing resource to be hot-plugged is hot-plugged into the virtual machine.
  • a computing resource allocation device including: a startup unit, set to start a virtual machine; a first acquisition unit, set to acquire a first configuration file provided by a user; a first determination unit, set to determine When the first configuration file includes the computing resource requirements of the virtual machine, according to the computing resource requirements of the virtual machine in the first configuration file, determine the computing resources of the virtual machine to be hot-plugged; the hot-plug unit is set to The computing resource to be hot-plugged is hot-plugged into the virtual machine.
  • An embodiment of the present application further provides a device, the device includes a processor and a memory: the memory is used to store a computer program; the processor is used to execute the computing resource allocation method provided by the embodiment of the present application according to the computer program any of the embodiments.
  • the embodiments of the present application further provide a computer-readable storage medium, where the computer-readable storage medium is used to store a computer program, and the computer program is used to execute any one of the computing resource allocation methods provided by the embodiments of the present application Way.
  • the embodiments of the present application have at least the following advantages:
  • a virtual machine is started, and a first configuration file provided by a user is obtained; when it is determined that the first configuration file includes the computing resource requirements of the virtual machine, the The computing resource requirements of the virtual machine, determine the computing resources to be hot-plugged of the virtual machine, and then hot-plug the computing resources to be hot-plugged into the virtual machine, so that the hot-plugged virtual machine can have sufficient computing resources to meet the needs of the virtual machine.
  • the computing resource requirements of the deployed container because the computing resource requirements of the virtual machine in the first configuration file are set by the user according to the actual computing resource requirements of the virtual machine, the computing resources to be hot-plugged determined based on the computing resource requirements of the virtual machine can meet the requirements of the virtual machine. Actual computing resource requirements, so that the hot-plugged virtual machine can provide sufficient computing resources for the containers deployed on it.
  • FIG. 1 is a flowchart of a computing resource allocation method provided by an embodiment of the present application
  • FIG. 2 is a schematic diagram of an application scenario using a computing resource allocation method provided by an embodiment of the present application
  • FIG. 3 is a schematic structural diagram of an apparatus for allocating computing resources provided by an embodiment of the present application.
  • FIG. 4 is a schematic structural diagram of a device provided by an embodiment of the present application.
  • Kubernetes (referred to as k8s) is a container-based cluster management platform, and a kubernetes cluster can include a master node (Master Node) and multiple computing nodes (Work Node) that communicate with the master node respectively. Among them, the master node can be used to manage and control multiple computing nodes.
  • a computing node is a workload node, and each computing node can be deployed with at least one container group (Pod), and each pod group can encapsulate one or more containers (Containers) for carrying software programs.
  • Pod container group
  • Containers containers
  • a Pod is the basic unit of operation of Kubernetes and the smallest unit of deployment that can be created, debugged, and managed.
  • multiple containers (Containers) located in the same Pod can share network resources (eg, IP addresses). For example, when the first Pod includes 3 containers, and the first Pod has a first IP address, the 3 containers located on the first Pod share the first IP address.
  • kata is an open source container project that aims to unify the security benefits of virtual machines with the speed and manageability of containers.
  • kata is obtained by merging two existing open source projects, Intel Clear Containers and Hyper runV, so that kata solves the security and isolation problems of traditional container shared kernels.
  • kata-runtime is a component of kata, and kata-runtime is used to process all commands specified by the OCI runtime specification and start a kata-shim instance when an OCI (Oracle Call Interface) compatible container is running.
  • OCI Organic Call Interface
  • kata-shim is also a component in kata, and kata-shim is used to monitor the container process.
  • Yaml (Yet another markup language, still a markup language) is a language dedicated to writing configuration files.
  • Yaml is particularly suitable for expressing or editing data structures, various configuration files, dumping debug content, document outlines, and more.
  • Yaml is more suitable for expressing hierarchical data structures and for expressing related data. It should be noted that the configuration files written using Yaml are all files with the suffix of .yml.
  • the inventor found that the user can pre-specify the container computing resource requirements (that is, the container computing resource peak) of each container in the virtual machine, so that the virtual machine can be installed on the virtual machine in the future.
  • the sum of the container computing resource requirements of all the deployed containers is determined as the virtual machine computing resource requirement of the virtual machine.
  • the virtual machine computing resource requirement determined by the sum of the container computing resource requirements of all the containers deployed on the virtual machine is much higher than the actual value of the virtual machine computing resource of the virtual machine, which is easy to cause waste of computing resources.
  • the container computing resource requirement of container 1 is 2C4G
  • the container computing resource requirement of container 2 is 2C4G
  • the container computing resource requirement of container 1 can be 2C4G
  • the container computing resource requirement of container 2 The sum of the container computing resource requirement 2C4G is 4C8G, which is determined as the virtual machine computing resource requirement of the virtual machine.
  • the actual computing resources consumed by container 1 and container 2 cannot reach the maximum computing resources at the same time, and the peak value of the actual computing resources of the virtual machine is 3C6G, then the actual peak computing resources of the virtual machine 3C6G is lower than the above calculation
  • the computing resource requirement of the obtained virtual machine is 4C8G, so that there is always at least 1C2G of computing resources in the virtual machine in an idle state, which leads to a waste of computing resources.
  • an embodiment of the present application provides a computing resource allocation method.
  • the method includes: after starting a virtual machine, obtaining a first configuration file provided by a user; after determining that the first configuration file includes virtual machine computing resources When required, first determine the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file, and then hot-plug the computing resources to be hot-plugged into the virtual machine, so that the hot-plugged computing resources are hot-plugged.
  • a virtual machine can have sufficient computing resources to meet the computing resource requirements of the containers deployed on it.
  • the computing resources to be hot-plugged determined based on the computing resource requirements of the virtual machine can be used without wasting computer resources.
  • the virtual machine can meet the actual computing resource requirements of the virtual machine on the premise of resources, so that the hot-plugged virtual machine can provide sufficient computing resources for the containers deployed on it without wasting computer resources, thus avoiding the waste of computing resources.
  • FIG. 1 is a flowchart of a computing resource allocation method provided by an embodiment of the present application.
  • the computing resource allocation method provided by the embodiment of the present application includes S101-S106:
  • a virtual machine refers to a computing node in k8s, and at least one container group Pod can be deployed on the virtual machine. Among them, a Pod can encapsulate at least one container. It can be seen that multiple containers can be deployed on a virtual machine. For example, N containers can be deployed on a virtual machine, and N is a positive integer.
  • a preset standard allocation resource can be allocated to the virtual machine in advance, so that the virtual machine can use the preset standard to allocate resources Complete boot.
  • the preset standard allocation resources refer to the minimum computer resources required in the running process of the virtual machine.
  • the preset standard allocation resource can be preset.
  • the first configuration file records the computing resource requirements specified by the user for the virtual machine (eg, computing resource requirements of the virtual machine, computing resource requirements of the container, etc.).
  • the first configuration file may be the yaml configuration file entered by the user in k8s.
  • the first configuration file may include virtual machine computing resource requirements and/or container computing resource requirements.
  • the computing resource demand of the virtual machine refers to the peak computing resource demanded by the virtual machine during the running process of the virtual machine.
  • the computing resource demand of a container refers to the peak computing resource demanded by the container during the running process of the container.
  • the first configuration file usually definitely includes the computing resource requirements of the container, so this embodiment of the present application will use the first configuration file to include the computing resource requirements of the virtual machine and the computing resources of the container, or the first configuration file
  • the configuration file includes container computing resource requirements as an example.
  • computing resources may include a memory and a central processing unit (central processing unit, CPU).
  • CPU central processing unit
  • the user when the user wants to directly specify the peak value of computing resources of the virtual machine corresponding to the Pod, the user can write the peak value of computing resources of the virtual machine as the computing resource requirement of the virtual machine into the first configuration file, So that the computing resource peak value of the virtual machine can be subsequently known based on the computing resource requirements of the virtual machine existing in the first configuration file.
  • the user when the user wants to directly specify the computing resource peak value of each container deployed in the virtual machine, the user can write the computing resource peak value of each container as the container computing resource requirement of the container into the first configuration file, so that subsequent The peak value of computing resources of each container deployed in the virtual machine can be known based on the computing resource requirements of the containers existing in the first configuration file.
  • S101 and S102 may be executed sequentially (as shown in FIG. 1 ), or S102 and S101 may be executed sequentially, or S101 and S102 may be executed simultaneously.
  • S103 Determine whether the first configuration file includes the computing resource requirements of the virtual machine; if yes, execute S104; if not, execute S105.
  • the computing resources that should be allocated to the virtual machine can be determined directly according to the computing resource requirements of the virtual machine existing in the first configuration file; if not included, it can be determined that the user has only specified the computing resources of each container deployed in the virtual machine. Therefore, in order to ensure that the computer resources allocated to the virtual machine can meet the computing resource overhead of all the containers deployed on it, the sum of the container computing resources of all the containers deployed on it can be determined as the virtual machine computing resources of the virtual machine. resource requirements.
  • the embodiment of the present application also provides an implementation of S103, which is specifically: firstly parse the first configuration file to obtain the parsing result; and then determine whether there is a virtual machine computing resource requirement of the virtual machine in the parsing result , if it exists, it is determined that the first configuration file includes the computing resource requirement of the virtual machine; if it does not exist, it is determined that the first configuration file does not include the computing resource requirement of the virtual machine.
  • the parsing result refers to a result obtained by performing parameter parsing on the first configuration file, and the parsing result may include computing resource requirements of a virtual machine and/or computing resource requirements of a container. It should be noted that the embodiment of the present application does not limit the parsing process of the first configuration file.
  • the first configuration file may be obtained by parsing by k8s.
  • S104 Determine the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file.
  • the computing resources to be hot-plugged refer to computing resources that need to be hot-plugged into the virtual machine after the virtual machine is started, so that the hot-plugged virtual machine can meet the computing resource overhead of starting and running all the containers deployed on it.
  • the embodiment of the present application also provides an implementation of S104, which specifically includes: analyzing the first configuration file to obtain computing resource requirements of the virtual machine; and determining computing resources to be hot-plugged for the virtual machine according to the computing resource requirements of the virtual machine.
  • the computing resource requirements of the virtual machine can be obtained by parsing the first configuration file, and then the computing resource requirements of the virtual machine obtained by the analysis can be used to determine the computing resource requirements of the virtual machine. Computing resources to be hot-plugged.
  • the embodiment of the present application does not limit the implementation process of determining the computing resource to be hot-plugged based on the computing resource requirement of the virtual machine, which specifically includes: directly determining the computing resource requirement of the virtual machine as the computing resource to be hot-plugged of the virtual machine.
  • the operation and maintenance personnel that is, the technician who maintains the running process of the virtual machine
  • the virtual machine basic computing resource overhead of the virtual machine in addition to the user specifying the virtual machine computing resource overhead of the virtual machine, the operation and maintenance personnel (that is, the technician who maintains the running process of the virtual machine) will also specify the virtual machine basic computing resource overhead of the virtual machine. Therefore, in order to satisfy the computing resource requirements of the user and the operation and maintenance personnel for the virtual machine at the same time, the computing resource to be hot-plugged of the virtual machine can be determined by referring to the computing resource overhead specified by the two at the same time.
  • S104 which specifically includes S1041-S1044:
  • the second configuration file refers to a parameter configuration file provided by the operation and maintenance personnel for maintaining the running process of the virtual machine, and the second configuration file may include basic resource requirements of the virtual machine.
  • the basic resource requirement of the virtual machine refers to the computing resource overhead necessary for maintaining the running process of the virtual machine.
  • S1042 Determine that the basic resource requirement of the virtual machine meets the preset condition; if yes, execute S1043; if not, execute S1044.
  • the preset condition is used to represent a condition that needs to be satisfied by reference to the basic resource requirements of the virtual machine when determining the computing resource to be hot-plugged, and the preset condition is preset.
  • the basic resource requirements specified by the operation and maintenance personnel for the virtual machine should not exceed the preset standard allocation resources (that is, the computing resources actually required when the virtual machine is started), so that after the virtual machine is started, the virtual machine It can continue to use the released preset standard allocation resources to offset the basic resource requirements of the virtual machine, so in this case, it is not necessary to consider the impact of the basic resource requirements of the virtual machine on hot-plug computing resources; however, in some special cases , the basic resource requirements specified by the operation and maintenance personnel for the virtual machine will exceed the preset standard allocation resources, so that after the virtual machine is started, the virtual machine cannot use the released preset standard allocation resources to completely offset the basic resource requirements of the virtual machine. Therefore, in this case, the influence of the basic resource requirements of virtual machines on hot-plug computing resources should be considered.
  • a preset condition may be set in advance such that the basic resource requirements of the virtual machine are higher than the preset standard to allocate resources, so that the above two conditions can be determined based on the preset conditions. a situation.
  • the computing resources to be hot-plugged of the virtual machine are jointly determined according to the computing resource requirements of the virtual machine; if it is not higher than that, it can be determined that the preset standard allocation resources released after the virtual machine is started can meet the basic resource requirements of the virtual machine, so in order to save computing resources resources, the computing resources to be hot-plugged of the virtual machine may be determined only by considering the computing resource requirements of the virtual machine specified by the user.
  • S1043 Determine the computing resources to be hot-plugged of the virtual machine according to the basic resource requirements and the computing resource requirements of the virtual machine in the first configuration file.
  • the computing resources to be hot-plugged of the virtual machine may be determined according to the unoffset part of the basic resource requirements and the computing resource requirements of the virtual machine specified by the user.
  • the embodiment of the present application provides an implementation of S1043, which specifically includes: allocating resources according to basic resource requirements and preset standards, and obtaining a resource difference; calculating according to the resource difference and the virtual machine in the first configuration file Resource requirements, determine the computing resources to be hot-plugged for the virtual machine.
  • the resource difference is used to represent the unoffset part of the basic resource requirements specified by the operation and maintenance personnel.
  • the difference between the basic resource requirements and the preset standard allocation resources can be calculated to obtain the resource difference;
  • the resource difference and the computing resource requirements of the virtual machine specified by the user are summed to determine the computing resources to be hot-plugged for the virtual machine, so that the sum of the computing resources to be hot-plugged and the resources allocated by the preset standard can jointly satisfy the operation and maintenance personnel.
  • the specified basic resource requirements and the user-specified computing resource requirements of the virtual machine, so that the virtual machine after the hot-plug is completed can meet the computing resource requirements of the operation and maintenance personnel and the user for the virtual machine at the same time.
  • S1044 Determine the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file.
  • the sum of resources and preset standard allocation resources can be no less than the sum of the virtual machine computing resource requirements specified by the user and the basic resource requirements specified by the operation and maintenance personnel, so that the virtual machine after the hot swap can meet the requirements of the operation and maintenance personnel at the same time. and the user's computing resource requirements for the virtual machine; if it is not higher than that, the computing resources to be hot-plugged for the virtual machine can be determined directly according to the computing resource requirements of the virtual machine specified by the user.
  • the sum of the standard allocation resources can be no less than the sum of the computing resource requirements of the virtual machine specified by the user and the basic resource requirements specified by the operation and maintenance personnel, so that the virtual machine after the hot-plug can meet the requirements of the operation and maintenance personnel and users at the same time.
  • the computing resource requirements of the virtual machine can be no less than the sum of the virtual machine computing resource requirements specified by the user and the basic resource requirements specified by the operation and maintenance personnel, so that the virtual machine after the hot-plug can meet the requirements of the operation and maintenance personnel and users at the
  • the virtual machine computing resource requirements of the virtual machine can be directly determined as the hot-plug computing of the virtual machine.
  • resources which are specifically: when the computing resource requirements of the virtual machine include memory requirements and CPU requirements, the memory requirements of the virtual machine can be directly determined as the memory to be hot-plugged of the virtual machine, and the CPU requirements of the virtual machine can be directly determined as The CPU to be hot-plugged for this virtual machine.
  • the computing resources to be hot-plugged determined based on the computing resource requirements of the virtual machine can be used without wasting computer resources. Therefore, the hot-plugged virtual machine can provide sufficient computing resources for the containers deployed on it without wasting computer resources, thus avoiding the waste of computing resources.
  • S105 Determine the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the container in the first configuration file.
  • the embodiment of the present application also provides an implementation of S105, which specifically includes: analyzing the first configuration file to obtain the computing resource requirements of the container; and determining the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the container.
  • the container computing resource requirements of each container deployed on the virtual machine can be obtained by parsing the first configuration file, and then the container computing resource requirements of each container deployed on the virtual machine can be obtained by using the first configuration file.
  • the container computing resource requirements of each container of the virtual machine are determined, and the computing resources to be hot-plugged of the virtual machine are determined.
  • the embodiment of the present application does not limit the implementation process of determining the computing resources to be hot-plugged based on the container computing resource requirements.
  • the resource demand reaches the container computing resource demand of the Nth container
  • the computing resources to be hot-plugged of the virtual machine are obtained according to the sum of the container computing resource demand of the first container to the container computing resource demand of the Nth container.
  • the container computing resource requirements of the first container can be calculated from the container computing resource requirements of the first container to the container computing resource requirements of the Nth container. Adding the sum to obtain the computing resources to be hot-plugged of the virtual machine, which is specifically: determining the sum of the computing resource requirements of the container from the first container to the computing resource requirements of the N-th container as the computing resources to be hot-plugged of the virtual machine resource.
  • S105 which specifically includes S1051-S1054:
  • S1052 Determine that the basic resource requirement of the virtual machine meets the preset condition; if yes, execute S1053; if not, execute S1054.
  • S1053 Determine the computing resources to be hot-plugged of the virtual machine according to the basic resource requirements and the container computing resource requirements in the first configuration file.
  • S1054 Determine the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the container in the first configuration file.
  • S1051 to S1054 are respectively similar to the relevant contents of S1041 to S1044 above, and it is only necessary to replace the “computing resource requirement of virtual machine” in S1041 to S1044 above with “computing resource requirement of container”. .
  • the computing resources to be hot-plugged of the virtual machine can be determined according to the computing resource requirements of the container specified by the user, the basic resource requirements specified by the operation and maintenance personnel, and the operation of allocating resources according to the preset standard, so that the computing resources to be hot-plugged are different from the computing resources to be hot-plugged.
  • the sum of the resources allocated by the preset standard can be no less than the sum of the container computing resource requirements specified by the user and the basic resource requirements specified by the operation and maintenance personnel, so that the virtual machine after the hot-plug can meet the requirements of the operation and maintenance personnel and users at the same time.
  • the computing resource requirements of the virtual machine if not higher, the computing resources to be hot-plugged of the virtual machine can be determined directly according to the computing resource requirements of the container specified by the user, which can also make the computing resources to be hot-plugged and the preset standard allocation resources
  • the sum of the container computing resource requirements specified by the user and the basic resource requirements specified by the operation and maintenance personnel can be no less than the sum of the computing resource requirements of the container specified by the user and the basic resource requirements specified by the operation and maintenance personnel, so that the virtual machine after the hot swap can meet the computing resources of the operation and maintenance personnel and the user. need.
  • the virtual machine can be directly used.
  • the sum of the container computing resource requirements of all containers deployed on the virtual machine is used to determine the computing resources to be hot-plugged for the virtual machine, so that the determined computing resources to be hot-plugged can meet the maximum computing resource overhead of all containers on the virtual machine.
  • S106 Hot-plug the computing resources to be hot-plugged of the virtual machine to the virtual machine.
  • the obtained computing resources to be hot-plugged can be directly hot-plugged into the virtual machine, so that the virtual machine can meet the requirements of all containers deployed on it. Computational resource overhead during operation.
  • the embodiment of the present application also provides a possible implementation of the computing resource allocation method.
  • the computer resource allocation method includes S107 in addition to all or part of the steps in S101-S106:
  • S107 Start the container deployed on the virtual machine, and configure a container control group corresponding to the container according to the container computing resource requirements.
  • the container control group is used to limit the allocation of container computing resources of all containers deployed on the virtual machine.
  • the first configuration file provided by the user is obtained; when it is determined that the first configuration file includes the computing resource requirements of the virtual machine, the first configuration file is determined according to the first configuration file
  • the computing resource requirements of the virtual machine determine the computing resources to be hot-plugged of the virtual machine, and then hot-plug the computing resources to be hot-plugged into the virtual machine, so that the hot-plugged virtual machine can have sufficient computing resources to meet the needs of the virtual machine.
  • the computing resource requirements of the deployed container is
  • the computing resources to be hot-plugged determined based on the computing resource requirements of the virtual machine can be used without wasting the computer.
  • the virtual machine can meet the actual computing resource requirements of the virtual machine on the premise of resources, so that the hot-plugged virtual machine can provide sufficient computing resources for the containers deployed on it without wasting computer resources, thus avoiding the waste of computing resources.
  • this figure is a schematic diagram of an application scenario of using the computing resource allocation method provided by the embodiment of the present application.
  • the computing resource allocation method provided in the embodiment of the present application and applied to the application scenario shown in FIG. 2 includes the following steps:
  • Step 1 k8s parses the first configuration file provided by the user to obtain the specified computing resource requirements.
  • k8s is used to manage and control the cluster.
  • the first configuration file may be a yaml configuration file.
  • the yaml configuration file can include memory configuration items and CPU configuration items. Among them, the memory configuration item is used to pass the user-specified virtual machine memory limit information to kata; the CPU configuration item is used to pass the user-specified virtual machine CPU limit information to kata.
  • the specified computing resource requirements are used to characterize user-specified computer resource constraints, and the specified computing resource requirements may include virtual machine computing resource requirements and/or container computing resource requirements.
  • Step 2 After kata-runtime obtains the specified computing resource requirement, it is judged whether the specified computing resource requirement includes the virtual machine computing resource requirement of the virtual machine; if so, step 3 is performed; if not, step 4 is performed. Among them, kata-runtime is used to manage and control the virtual machine.
  • Step 3 Allocate resources according to virtual machine computing resource requirements, basic resource requirements, and preset standards of the virtual machine, and determine computing resources to be hot-plugged for the virtual machine.
  • Step 4 Hot-plug the computing resources to be hot-plugged to the virtual machine.
  • Step 5 Start the container deployed on the virtual machine, and configure the container control group corresponding to the container according to the container computing resource requirements.
  • the user can specify the computing resource requirements of the virtual machine and the computing resource of the container in the first configuration file in advance, so that the user can subsequently determine the need to hot-plug to the virtual machine based on the computing resource requirements of the virtual machine.
  • the computing resources CPU and/or memory
  • configure the container control group based on the container computing resource requirements of each container deployed on the virtual machine, so that the container control group can control all the containers deployed on the virtual machine. Control restrictions.
  • the embodiments of the present application further provide a computing resource allocation device, which will be explained and described below with reference to the accompanying drawings.
  • this figure is a schematic structural diagram of a computing resource allocation apparatus provided by an embodiment of the present application.
  • the computing resource allocation apparatus 300 provided by the embodiment of the present application includes:
  • a startup unit 301 configured to start a virtual machine
  • the first obtaining unit 302 is configured to obtain the first configuration file provided by the user
  • the first determining unit 303 is configured to, when determining that the first configuration file includes the computing resource requirements of the virtual machine, determine the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file ;
  • the hot-plug unit 304 is configured to hot-plug the computing resource to be hot-plugged into the virtual machine.
  • the first determining unit 303 is specifically configured to: parse the first configuration file to obtain computing resource requirements of the virtual machine; determine the computing resource requirements of the virtual machine according to the computing resource requirements of the virtual machine The computing resources to be hot-plugged for the virtual machine.
  • the first determining unit 303 includes:
  • a first obtaining subunit configured to obtain a second configuration file, where the second configuration file includes basic resource requirements of the virtual machine
  • a first determining subunit configured to determine the standby-heating of the virtual machine according to the basic resource requirements and the computing resource requirements of the virtual machine in the first configuration file when it is determined that the basic resource requirements meet a preset condition Insert computing resources;
  • the second determination subunit is configured to determine the computing resource to be hot-plugged of the virtual machine according to the computing resource requirement of the virtual machine in the first configuration file when it is determined that the basic resource requirement does not meet the preset condition.
  • the first determining subunit is specifically configured to: allocate resources according to the basic resource requirements and preset criteria, and obtain a resource difference value; according to the resource difference value and the first The computing resource requirements of the virtual machine in the configuration file determine the computing resources to be hot-plugged for the virtual machine.
  • the computing resource allocation apparatus 300 further includes:
  • a second determining unit configured to, when it is determined that the first configuration file does not include the computing resource requirements of the virtual machine, and that the first configuration file includes the computing resource requirements of the container, according to the computing resources of the container in the first configuration file requirements, and determine the computing resources to be hot-plugged for the virtual machine.
  • the second determining unit is specifically set to: when N containers are deployed on the virtual machine, and the first configuration file includes the container computing resource requirements of the first container to When the container computing resource requirements of the Nth container are used, the computing resources to be hot-plugged of the virtual machine are obtained according to the sum of the container computing resource requirements of the first container to the container computing resource requirements of the Nth container.
  • the computing resource allocation apparatus 300 further includes:
  • the configuration unit is configured to start the container deployed on the virtual machine, and configure the container control group corresponding to the container according to the computing resource requirements of the container.
  • the virtual machine is started, and the first configuration file provided by the user is obtained; when it is determined that the first configuration file includes the computing resource requirements of the virtual machine, the According to the computing resource requirements of the virtual machine in the first configuration file, determine the computing resources to be hot-plugged for the virtual machine, and then hot-plug the computing resources to be hot-plugged into the virtual machine, so that the hot-plugged virtual machine can have Sufficient computing resources to meet the computing resource requirements of the containers deployed on it.
  • the computing resources to be hot-plugged determined based on the computing resource requirements of the virtual machine can meet the requirements of the virtual machine. Actual computing resource requirements, so that the hot-plugged virtual machine can provide sufficient computing resources for the containers deployed on it.
  • the embodiment of the present application further provides a device, which is explained and described below with reference to the accompanying drawings.
  • FIG. 4 this figure is a schematic structural diagram of a device provided by an embodiment of the present application.
  • the device 400 provided by this embodiment of the present application includes: a processor 401 and a memory 402;
  • the memory 402 is used to store computer programs
  • the processor 401 is configured to execute any implementation manner of the computing resource allocation method provided by the above method embodiments according to the computer program. That is, the processor 401 is configured to perform the following steps:
  • the first configuration file includes the computing resource requirements of the virtual machine
  • the determining of the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file includes:
  • the computing resources to be hot-plugged of the virtual machine are determined.
  • the determining of the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file includes:
  • the second configuration file includes basic resource requirements of the virtual machine
  • the computing resource to be hot-plugged of the virtual machine is determined according to the basic resource requirement and the computing resource requirement of the virtual machine in the first configuration file;
  • the computing resource to be hot-plugged of the virtual machine is determined according to the computing resource requirement of the virtual machine in the first configuration file.
  • the determining of the computing resources to be hot-plugged for the virtual machine according to the basic resource requirements and the computing resource requirements of the virtual machine in the first configuration file includes:
  • the computing resources to be hot-plugged for the virtual machine are determined.
  • the method further includes:
  • the virtual machine is determined according to the computing resource requirement of the container in the first configuration file The computing resources to be hot-plugged.
  • the first configuration file when N containers are deployed on the virtual machine, and the first configuration file includes the container computing resource requirements of the first container to the container computing resource requirements of the Nth container, the The container computing resource requirements in the first configuration file determine the computing resources to be hot-plugged for the virtual machine, including:
  • the computing resources to be hot-plugged of the virtual machine are obtained.
  • the method further includes:
  • a container deployed on the virtual machine is started, and a container control group corresponding to the container is configured according to the computing resource requirements of the container.
  • the embodiments of the present application further provide a computer-readable storage medium.
  • the embodiments of the present application provide a computer-readable storage medium, where the computer-readable storage medium is used to store a computer program, and the computer program is used to execute any implementation manner of the computing resource allocation method provided by the above method embodiments. That is, the computer program is used to perform the following steps:
  • the first configuration file includes the computing resource requirements of the virtual machine
  • the determining of the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file includes:
  • the computing resources to be hot-plugged of the virtual machine are determined.
  • the determining of the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file includes:
  • the second configuration file includes basic resource requirements of the virtual machine
  • the computing resource to be hot-plugged of the virtual machine is determined according to the basic resource requirement and the computing resource requirement of the virtual machine in the first configuration file;
  • the computing resource to be hot-plugged of the virtual machine is determined according to the computing resource requirement of the virtual machine in the first configuration file.
  • the determining of the computing resources to be hot-plugged for the virtual machine according to the basic resource requirements and the computing resource requirements of the virtual machine in the first configuration file includes:
  • the computing resources to be hot-plugged for the virtual machine are determined.
  • the method further includes:
  • the virtual machine is determined according to the computing resource requirement of the container in the first configuration file The computing resources to be hot-plugged.
  • the first configuration file when N containers are deployed on the virtual machine, and the first configuration file includes the container computing resource requirements of the first container to the container computing resource requirements of the Nth container, the The container computing resource requirements in the first configuration file determine the computing resources to be hot-plugged for the virtual machine, including:
  • the computing resources to be hot-plugged of the virtual machine are obtained.
  • the method further includes:
  • a container deployed on the virtual machine is started, and a container control group corresponding to the container is configured according to the computing resource requirements of the container.
  • At least one (item) refers to one or more, and "a plurality” refers to two or more.
  • “And/or” is used to describe the relationship between related objects, indicating that there can be three kinds of relationships, for example, “A and/or B” can mean: only A, only B, and both A and B exist , where A and B can be singular or plural.
  • the character “/” generally indicates that the related objects are an “or” relationship.
  • At least one item(s) below” or similar expressions thereof refer to any combination of these items, including any combination of single item(s) or plural items(s).
  • At least one (a) of a, b or c can mean: a, b, c, "a and b", “a and c", “b and c", or "a and b and c" ", where a, b, c can be single or multiple.
  • the virtual machine start the virtual machine, and obtain the first configuration file provided by the user; when it is determined that the first configuration file includes the computing resource requirements of the virtual machine, according to the first configuration
  • the computing resource requirements of the virtual machine in the file determine the computing resources to be hot-plugged for the virtual machine, and then hot-plug the computing resources to be hot-plugged into the virtual machine, so that the hot-plugged virtual machine can have sufficient computing resources to Satisfy the computing resource requirements of the containers deployed on it.
  • the computing resources to be hot-plugged determined based on the computing resource requirements of the virtual machine can meet the requirements of the virtual machine. Actual computing resource requirements, so that the hot-plugged virtual machine can provide sufficient computing resources for the containers deployed on it.

Abstract

Disclosed are a computing resource allocation method and a related device. The method comprises: starting a virtual machine, and obtaining a first configuration file provided by a user; and when determining that the first configuration file comprises a virtual machine computing resource requirement, first determining, according to the virtual machine computing resource requirement in the first configuration file, a computing resource to be hot-plugged of the virtual machine, and then hot-plugging the computing resource to be hot-plugged into the virtual machine, so that the hot-plugged virtual machine can have sufficient computing resources to meet computing resource requirements of containers deployed on the virtual machine. In addition, since the virtual machine computing resource requirement in the first configuration file is set by the user according to an actual computing resource requirement of the virtual machine, the computing resource to be hot-plugged determined on the basis of the virtual machine computing resource requirement can meet the actual computing resource requirement of the virtual machine, such that the hot-plugged virtual machine can provide sufficient computing resources for the containers deployed on the virtual machine.

Description

一种计算资源分配方法及相关设备A computing resource allocation method and related equipment
本公开要求于2020年09月18日提交中国专利局、申请号为202010989061.0、发明名称为“一种计算资源分配方法及相关设备”的中国专利申请的优先权,其全部内容通过引用结合在本公开中。This disclosure claims the priority of the Chinese patent application with the application number 202010989061.0 and the invention titled "A Computing Resource Allocation Method and Related Equipment" filed with the China Patent Office on September 18, 2020, the entire contents of which are incorporated herein by reference Public.
技术领域technical field
本申请涉及计算机技术领域,尤其涉及一种计算资源分配方法及相关设备。The present application relates to the field of computer technologies, and in particular, to a computing resource allocation method and related equipment.
背景技术Background technique
在基于kubernetes(简称为k8s)和kata的集群系统中,作为计算节点的虚拟机中部署了多个容器。另外,在该虚拟机启动之后,需要为该虚拟机分配充足的计算资源(如CPU和内存等计算资源),以使虚拟机能够满足其上部署的容器的计算资源需求。In a cluster system based on kubernetes (referred to as k8s) and kata, multiple containers are deployed in virtual machines as computing nodes. In addition, after the virtual machine is started, sufficient computing resources (such as computing resources such as CPU and memory) need to be allocated to the virtual machine, so that the virtual machine can meet the computing resource requirements of the containers deployed thereon.
然而,如何对虚拟机进行计算资源分配仍是一个亟待解决的技术问题。However, how to allocate computing resources to virtual machines is still an urgent technical problem to be solved.
发明内容SUMMARY OF THE INVENTION
为了解决相关技术中存在的以上技术问题,本申请实施例提供一种计算资源分配方法及相关设备,能够实现虚拟机的计算资源分配。In order to solve the above technical problems existing in the related art, the embodiments of the present application provide a computing resource allocation method and related devices, which can realize computing resource allocation of a virtual machine.
为了实现上述目的,本申请实施例提供的技术方案如下:In order to achieve the above purpose, the technical solutions provided in the embodiments of the present application are as follows:
本申请实施例提供一种计算资源分配方法,包括:启动虚拟机;获取用户提供的第一配置文件;在确定所述第一配置文件包括虚拟机计算资源需求时,根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源;将所述待热插计算资源热插至所述虚拟机。An embodiment of the present application provides a computing resource allocation method, including: starting a virtual machine; obtaining a first configuration file provided by a user; when it is determined that the first configuration file includes computing resource requirements of a virtual machine, according to the first configuration file The computing resource requirements of the virtual machine in the virtual machine are determined, and the computing resources to be hot-plugged of the virtual machine are determined; and the computing resources to be hot-plugged are hot-plugged into the virtual machine.
在一实施方式中,所述根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源,包括:对所述第一配置文件进行解析,得到虚拟机计算资源需求;根据所述虚拟机计算资源需求,确定所述虚拟机的待热插计算资源。In one embodiment, the determining the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file includes: parsing the first configuration file to obtain the virtual machine computing resource requirements; determining the computing resources to be hot-plugged for the virtual machine according to the computing resource requirements of the virtual machine.
在一实施方式中,所述根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源,包括:获取第二配置文件,所述第二配置 文件包括所述虚拟机的基础资源需求;在确定所述基础资源需求满足预设条件时,根据所述基础资源需求和所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源;在确定所述基础资源需求不满足预设条件时,根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源。In one embodiment, the determining the computing resources to be hot-plugged for the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file includes: acquiring a second configuration file, where the second configuration file includes: The basic resource requirements of the virtual machine; when it is determined that the basic resource requirements meet the preset conditions, according to the basic resource requirements and the computing resource requirements of the virtual machine in the first configuration file, determine the waiting time of the virtual machine. Hot-plug computing resources; when it is determined that the basic resource requirements do not meet the preset conditions, determine the computing resources to be hot-plugged for the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file.
在一实施方式中,所述根据所述基础资源需求和所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源,包括:根据所述基础资源需求和预设标准分配资源,得到资源差值;根据所述资源差值和所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源。In one embodiment, the determining the computing resources to be hot-plugged of the virtual machine according to the basic resource requirements and the computing resource requirements of the virtual machine in the first configuration file includes: according to the basic resource requirements and the computing resources of the virtual machine. Allocate resources according to a preset standard, and obtain a resource difference; determine the computing resources to be hot-plugged for the virtual machine according to the resource difference and the computing resource requirements of the virtual machine in the first configuration file.
在一实施方式中,所述方法还包括:在确定所述第一配置文件不包括虚拟机计算资源需求,且确定所述第一配置文件包括容器计算资源需求时,根据所述第一配置文件中的容器计算资源需求,确定所述虚拟机的待热插计算资源。In one embodiment, the method further includes: when it is determined that the first configuration file does not include the computing resource requirements of the virtual machine, and it is determined that the first configuration file includes the computing resource requirements of the container, according to the first configuration file The computing resource requirements of the container in the virtual machine are determined, and the computing resources to be hot-plugged of the virtual machine are determined.
在一实施方式中,当所述虚拟机上部署有N个容器,且所述第一配置文件包括第1个容器的容器计算资源需求至第N个容器的容器计算资源需求时,所述根据所述第一配置文件中的容器计算资源需求,确定所述虚拟机的待热插计算资源,包括:根据第1个容器的容器计算资源需求至第N个容器的容器计算资源需求的加和,得到所述虚拟机的待热插计算资源。In one embodiment, when N containers are deployed on the virtual machine, and the first configuration file includes the container computing resource requirements of the first container to the container computing resource requirements of the Nth container, the The container computing resource requirements in the first configuration file, and determining the virtual machine's to-be-hot-plugged computing resources, including: according to the container computing resource requirements of the first container to the Nth container. The sum of the container computing resource requirements of the container to obtain the computing resources to be hot-plugged of the virtual machine.
在一实施方式中,当所述第一配置文件还包括容器计算资源需求时,所述方法还包括:启动所述虚拟机上部署的容器,并根据所述容器计算资源需求对所述容器对应的容器控制组进行配置。In an embodiment, when the first configuration file further includes container computing resource requirements, the method further includes: starting a container deployed on the virtual machine, and corresponding to the container according to the container computing resource requirement. to configure the container control group.
本申请实施例还提供了一种计算资源分配装置,包括:启动单元,设置为启动虚拟机;第一获取单元,设置为获取用户提供的第一配置文件;第一确定单元,设置为在确定所述第一配置文件包括虚拟机计算资源需求时,根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源;热插单元,设置为将所述待热插计算资源热插至所述虚拟机。The embodiment of the present application further provides a computing resource allocation device, including: a startup unit, set to start a virtual machine; a first acquisition unit, set to acquire a first configuration file provided by a user; a first determination unit, set to determine When the first configuration file includes the computing resource requirements of the virtual machine, according to the computing resource requirements of the virtual machine in the first configuration file, determine the computing resources of the virtual machine to be hot-plugged; the hot-plug unit is set to The computing resource to be hot-plugged is hot-plugged into the virtual machine.
本申请实施例还提供了一种设备,所述设备包括处理器以及存储器:所述存储器用于存储计算机程序;所述处理器用于根据所述计算机程序执行本申请实施例提供的计算资源分配方法中的任一实施方式。An embodiment of the present application further provides a device, the device includes a processor and a memory: the memory is used to store a computer program; the processor is used to execute the computing resource allocation method provided by the embodiment of the present application according to the computer program any of the embodiments.
本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质用于存储计算机程序,所述计算机程序用于执行本申请实施例提供的计算资 源分配方法中的任一实施方式。The embodiments of the present application further provide a computer-readable storage medium, where the computer-readable storage medium is used to store a computer program, and the computer program is used to execute any one of the computing resource allocation methods provided by the embodiments of the present application Way.
与相关技术相比,本申请实施例至少具有以下优点:Compared with the related art, the embodiments of the present application have at least the following advantages:
本申请实施例提供的计算资源分配方法中,启动虚拟机,并获取用户提供的第一配置文件;在确定该第一配置文件包括虚拟机计算资源需求时,先根据该第一配置文件中的虚拟机计算资源需求,确定该虚拟机的待热插计算资源,再将该待热插计算资源热插至该虚拟机,以使得热插后的虚拟机能够拥有充足的计算资源来满足其上部署的容器的计算资源需求。另外,因第一配置文件中的虚拟机计算资源需求是由用户根据该虚拟机的实际计算资源需求设定的,使得基于该虚拟机计算资源需求确定的待热插计算资源能够满足虚拟机的实际计算资源需求,从而使得热插后的虚拟机能够为其上部署的容器提供充足的计算资源。In the computing resource allocation method provided by the embodiment of the present application, a virtual machine is started, and a first configuration file provided by a user is obtained; when it is determined that the first configuration file includes the computing resource requirements of the virtual machine, the The computing resource requirements of the virtual machine, determine the computing resources to be hot-plugged of the virtual machine, and then hot-plug the computing resources to be hot-plugged into the virtual machine, so that the hot-plugged virtual machine can have sufficient computing resources to meet the needs of the virtual machine. The computing resource requirements of the deployed container. In addition, because the computing resource requirements of the virtual machine in the first configuration file are set by the user according to the actual computing resource requirements of the virtual machine, the computing resources to be hot-plugged determined based on the computing resource requirements of the virtual machine can meet the requirements of the virtual machine. Actual computing resource requirements, so that the hot-plugged virtual machine can provide sufficient computing resources for the containers deployed on it.
附图说明Description of drawings
为了更清楚地说明本申请实施例或相关技术中的技术方案,下面将对实施例或相关技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其它的附图。In order to illustrate the technical solutions in the embodiments of the present application or related technologies more clearly, the following briefly introduces the accompanying drawings that are used in the description of the embodiments or related technologies. Obviously, the drawings in the following description are only the For some embodiments described in the application, for those of ordinary skill in the art, other drawings can also be obtained based on these drawings without any creative effort.
图1为本申请实施例提供的一种计算资源分配方法的流程图;FIG. 1 is a flowchart of a computing resource allocation method provided by an embodiment of the present application;
图2为本申请实施例提供的使用计算资源分配方法的应用场景示意图;FIG. 2 is a schematic diagram of an application scenario using a computing resource allocation method provided by an embodiment of the present application;
图3为本申请实施例提供的一种计算资源分配装置的结构示意图;FIG. 3 is a schematic structural diagram of an apparatus for allocating computing resources provided by an embodiment of the present application;
图4为本申请实施例提供的设备结构示意图。FIG. 4 is a schematic structural diagram of a device provided by an embodiment of the present application.
具体实施方式detailed description
为了便于理解本申请实施例的技术方案,下面对本申请实施例涉及的一些技术名词进行说明。In order to facilitate the understanding of the technical solutions of the embodiments of the present application, some technical terms involved in the embodiments of the present application are described below.
kubernetes(简称为k8s)是一种基于容器的集群管理平台,而且kubernetes集群可以包括主节点(Master Node)、以及分别与主节点通信连接的多个计算 节点(Work Node)。其中,主节点可以用于管理和控制多个计算节点。计算节点是一种工作负载节点,而且每个计算节点中可以部署有至少一个容器组(Pod),每个容器组中可以封装有一个或多个用于承载软件程序的容器(Container)。Kubernetes (referred to as k8s) is a container-based cluster management platform, and a kubernetes cluster can include a master node (Master Node) and multiple computing nodes (Work Node) that communicate with the master node respectively. Among them, the master node can be used to manage and control multiple computing nodes. A computing node is a workload node, and each computing node can be deployed with at least one container group (Pod), and each pod group can encapsulate one or more containers (Containers) for carrying software programs.
Pod是Kubernetes的基本操作单元,而且是最小的可创建、调试和管理的部署单元。另外,位于同一个Pod中的多个容器(Container)可以共享网络资源(如,IP地址)。例如,当第一个Pod包括3个容器,且该第一个Pod具有第一IP地址时,位于该第一个Pod上的3个容器共享该第一IP地址。A Pod is the basic unit of operation of Kubernetes and the smallest unit of deployment that can be created, debugged, and managed. In addition, multiple containers (Containers) located in the same Pod can share network resources (eg, IP addresses). For example, when the first Pod includes 3 containers, and the first Pod has a first IP address, the 3 containers located on the first Pod share the first IP address.
kata是一项开源容器项目,旨在将虚拟机的安全优势与容器的速度以及可管理性统一起来。另外,kata是通过将Intel Clear Containers和Hyper runV这两个现有的开源项目进行合并得到的,以使kata解决了传统容器共享内核的安全和隔离问题。kata is an open source container project that aims to unify the security benefits of virtual machines with the speed and manageability of containers. In addition, kata is obtained by merging two existing open source projects, Intel Clear Containers and Hyper runV, so that kata solves the security and isolation problems of traditional container shared kernels.
kata-runtime是kata中的一个组件,而且kata-runtime用于在一个OCI(Oracle Call Interface)兼容的容器运行时,负责处理OCI运行时规范指定的所有命令并启动kata-shim实例。其中,kata-shim也是kata中的一个组件,而且kata-shim用于监控容器进程。kata-runtime is a component of kata, and kata-runtime is used to process all commands specified by the OCI runtime specification and start a kata-shim instance when an OCI (Oracle Call Interface) compatible container is running. Among them, kata-shim is also a component in kata, and kata-shim is used to monitor the container process.
Yaml(Yet another markup language,仍是一种标记语言)是一种专用于写配置文件的语言。另外,Yaml特别适合用来表达或编辑数据结构、各种设定档、倾印除错内容、文件大纲等等。此外,Yaml比较适用于表达阶层式的数据结构,也适用于表示具有关联性的资料。需要说明的是,利用Yaml撰写的配置文件均是以.yml为后缀的文件。Yaml (Yet another markup language, still a markup language) is a language dedicated to writing configuration files. In addition, Yaml is particularly suitable for expressing or editing data structures, various configuration files, dumping debug content, document outlines, and more. In addition, Yaml is more suitable for expressing hierarchical data structures and for expressing related data. It should be noted that the configuration files written using Yaml are all files with the suffix of .yml.
发明人在对Pod对应的虚拟机计算资源的研究中发现:用户可以预先指定该虚拟机中每个容器的容器计算资源需求(也就是,容器计算资源峰值),以便后续能够将该虚拟机上部署的所有容器的容器计算资源需求之和,确定为该虚拟机的虚拟机计算资源需求。然而,因每个容器在不同运行时刻下消耗的实际计算资源量不同,使得虚拟机中所有容器几乎不可能在同一个时刻下消耗的实际计算资源量均达到计算资源峰值,从而使得基于虚拟机上部署的所有容器的容器计算资源需求之和确定的虚拟机计算资源需求,远远高于该虚拟机的虚拟机计算资源实际值,如此易造成计算资源的浪费。In the research of the virtual machine computing resources corresponding to the Pod, the inventor found that the user can pre-specify the container computing resource requirements (that is, the container computing resource peak) of each container in the virtual machine, so that the virtual machine can be installed on the virtual machine in the future. The sum of the container computing resource requirements of all the deployed containers is determined as the virtual machine computing resource requirement of the virtual machine. However, because the actual amount of computing resources consumed by each container at different running times is different, it is almost impossible for all containers in the virtual machine to consume the actual computing resources at the same time. The virtual machine computing resource requirement determined by the sum of the container computing resource requirements of all the containers deployed on the virtual machine is much higher than the actual value of the virtual machine computing resource of the virtual machine, which is easy to cause waste of computing resources.
例如,当虚拟机上部署有容器1和容器2,容器1的容器计算资源需求为 2C4G,且容器2的容器计算资源需求为2C4G时,可以将容器1的容器计算资源需求2C4G和容器2的容器计算资源需求2C4G的和值4C8G,确定为该虚拟机的虚拟机计算资源需求。另外,如果容器1和容器2在运行过程中消耗的实际计算资源量不可能同时达到最大计算资源,而且虚拟机的实际计算资源峰值为3C6G,则虚拟机的实际计算资源峰值3C6G低于上述计算得到的虚拟机计算资源需求4C8G,如此使得该虚拟机中始终存在至少1C2G的计算资源处于闲置状态,从而导致计算资源的浪费。For example, when container 1 and container 2 are deployed on the virtual machine, the container computing resource requirement of container 1 is 2C4G, and the container computing resource requirement of container 2 is 2C4G, the container computing resource requirement of container 1 can be 2C4G and the container computing resource requirement of container 2 The sum of the container computing resource requirement 2C4G is 4C8G, which is determined as the virtual machine computing resource requirement of the virtual machine. In addition, if the actual computing resources consumed by container 1 and container 2 cannot reach the maximum computing resources at the same time, and the peak value of the actual computing resources of the virtual machine is 3C6G, then the actual peak computing resources of the virtual machine 3C6G is lower than the above calculation The computing resource requirement of the obtained virtual machine is 4C8G, so that there is always at least 1C2G of computing resources in the virtual machine in an idle state, which leads to a waste of computing resources.
为了解决上述技术问题,本申请实施例提供了一种计算资源分配方法,该方法包括:在启动虚拟机之后,获取用户提供的第一配置文件;在确定该第一配置文件包括虚拟机计算资源需求时,先根据该第一配置文件中的虚拟机计算资源需求,确定该虚拟机的待热插计算资源,再将该待热插计算资源热插至该虚拟机,以使得热插后的虚拟机能够拥有充足的计算资源来满足其上部署的容器的计算资源需求。In order to solve the above technical problem, an embodiment of the present application provides a computing resource allocation method. The method includes: after starting a virtual machine, obtaining a first configuration file provided by a user; after determining that the first configuration file includes virtual machine computing resources When required, first determine the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file, and then hot-plug the computing resources to be hot-plugged into the virtual machine, so that the hot-plugged computing resources are hot-plugged. A virtual machine can have sufficient computing resources to meet the computing resource requirements of the containers deployed on it.
可见,因第一配置文件中的虚拟机计算资源需求是由用户根据该虚拟机的实际计算资源需求设定的,使得基于该虚拟机计算资源需求确定的待热插计算资源能够在不浪费计算机资源的前提下满足虚拟机的实际计算资源需求,从而使得热插后的虚拟机能够在不浪费计算机资源的前提下为其上部署的容器提供充足的计算资源,如此能够避免计算资源的浪费。It can be seen that, because the computing resource requirements of the virtual machine in the first configuration file are set by the user according to the actual computing resource requirements of the virtual machine, the computing resources to be hot-plugged determined based on the computing resource requirements of the virtual machine can be used without wasting computer resources. The virtual machine can meet the actual computing resource requirements of the virtual machine on the premise of resources, so that the hot-plugged virtual machine can provide sufficient computing resources for the containers deployed on it without wasting computer resources, thus avoiding the waste of computing resources.
为了使本技术领域的人员更好地理解本申请实施例的方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make those skilled in the art better understand the solutions of the embodiments of 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 in the embodiments of the present application. Obviously, the described The embodiments are only a part of the embodiments of the present application, but not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
方法实施例Method embodiment
参见图1,该图为本申请实施例提供的一种计算资源分配方法的流程图。Referring to FIG. 1 , which is a flowchart of a computing resource allocation method provided by an embodiment of the present application.
本申请实施例提供的计算资源分配方法,包括S101-S106:The computing resource allocation method provided by the embodiment of the present application includes S101-S106:
S101:启动虚拟机。S101: Start the virtual machine.
虚拟机是指k8s中的一个计算节点,而且该虚拟机上可以部署至少一个容器组Pod。其中,一个Pod中可以封装至少一个容器。可见,虚拟机上可以部 署多个容器。例如,虚拟机上可以部署有N个容器,且N为正整数。A virtual machine refers to a computing node in k8s, and at least one container group Pod can be deployed on the virtual machine. Among them, a Pod can encapsulate at least one container. It can be seen that multiple containers can be deployed on a virtual machine. For example, N containers can be deployed on a virtual machine, and N is a positive integer.
另外,因虚拟机启动时所需的计算资源较小,故为了能够保证虚拟机能够正常启动,可以预先将预设标准分配资源分配给虚拟机,以使虚拟机能够利用该预设标准分配资源完成启动。其中,预设标准分配资源是指虚拟机运行过程中所需的最小计算机资源。另外,预设标准分配资源可以预先设定。In addition, since the computing resources required for the virtual machine to start are relatively small, in order to ensure that the virtual machine can be started normally, a preset standard allocation resource can be allocated to the virtual machine in advance, so that the virtual machine can use the preset standard to allocate resources Complete boot. The preset standard allocation resources refer to the minimum computer resources required in the running process of the virtual machine. In addition, the preset standard allocation resource can be preset.
S102:获取用户提供的第一配置文件。S102: Obtain the first configuration file provided by the user.
第一配置文件记录有用户针对虚拟机指定的计算资源需求(如,虚拟机计算资源需求和容器计算资源需求等)。例如,第一配置文件可以是用户在k8s中输入的yaml配置文件。The first configuration file records the computing resource requirements specified by the user for the virtual machine (eg, computing resource requirements of the virtual machine, computing resource requirements of the container, etc.). For example, the first configuration file may be the yaml configuration file entered by the user in k8s.
第一配置文件可以包括虚拟机计算资源需求和/或容器计算资源需求。其中,虚拟机计算资源需求是指在虚拟机运行过程中该虚拟机需求的计算资源峰值。容器计算资源需求是指在容器运行过程中该容器需求的计算资源峰值。The first configuration file may include virtual machine computing resource requirements and/or container computing resource requirements. The computing resource demand of the virtual machine refers to the peak computing resource demanded by the virtual machine during the running process of the virtual machine. The computing resource demand of a container refers to the peak computing resource demanded by the container during the running process of the container.
需要说明的是,在大多数情况下,第一配置文件通常肯定会包括容器计算资源需求,故本申请实施例将以第一配置文件包括虚拟机计算资源需求和容器计算资源需求,或者第一配置文件包括容器计算资源需求为例进行介绍。It should be noted that, in most cases, the first configuration file usually definitely includes the computing resource requirements of the container, so this embodiment of the present application will use the first configuration file to include the computing resource requirements of the virtual machine and the computing resources of the container, or the first configuration file The configuration file includes container computing resource requirements as an example.
还需要说明的是,本申请实施例不限定计算资源,例如,计算资源可以包括内存和中央处理器(central processing unit,CPU)。It should also be noted that the embodiments of the present application do not limit computing resources. For example, computing resources may include a memory and a central processing unit (central processing unit, CPU).
基于上述内容可知,本申请实施例中,当用户想要直接指定Pod对应的虚拟机的计算资源峰值时,用户可以将虚拟机的计算资源峰值作为虚拟机计算资源需求写入第一配置文件,以使后续能够基于该第一配置文件中存在的虚拟机计算资源需求来获知该虚拟机的计算资源峰值。同理,当用户想要直接指定虚拟机中部署的每个容器的计算资源峰值时,用户可以将各个容器的计算资源峰值作为该容器的容器计算资源需求写入第一配置文件,以使后续能够基于该第一配置文件中存在的容器计算资源需求来获知部署在虚拟机中各个容器的计算资源峰值。Based on the above content, in the embodiment of the present application, when the user wants to directly specify the peak value of computing resources of the virtual machine corresponding to the Pod, the user can write the peak value of computing resources of the virtual machine as the computing resource requirement of the virtual machine into the first configuration file, So that the computing resource peak value of the virtual machine can be subsequently known based on the computing resource requirements of the virtual machine existing in the first configuration file. Similarly, when the user wants to directly specify the computing resource peak value of each container deployed in the virtual machine, the user can write the computing resource peak value of each container as the container computing resource requirement of the container into the first configuration file, so that subsequent The peak value of computing resources of each container deployed in the virtual machine can be known based on the computing resource requirements of the containers existing in the first configuration file.
需要说明的是,本申请实施例不限定S101和S102的执行顺序,可以依次执行S101和S102(如图1所示),也可以依次执行S102和S101,还可以同时执行S101和S102。It should be noted that the embodiment of the present application does not limit the execution order of S101 and S102. S101 and S102 may be executed sequentially (as shown in FIG. 1 ), or S102 and S101 may be executed sequentially, or S101 and S102 may be executed simultaneously.
S103:判断第一配置文件是否包括虚拟机计算资源需求;若是,则执行S104;若否,则执行S105。S103: Determine whether the first configuration file includes the computing resource requirements of the virtual machine; if yes, execute S104; if not, execute S105.
本申请实施例中,在获取到第一配置文件之后,可以先判断第一配置文件是否包括虚拟机计算资源需求;若包括,则可以确定用户直接指定了Pod对应的虚拟机的计算资源峰值,故可以直接根据该第一配置文件中存在的虚拟机计算资源需求来确定应该分配给该虚拟机的计算资源;若不包括,则可以确定用户只是指定了该虚拟机中部署的各个容器的计算资源峰值,故为了保证分配给该虚拟机的计算机资源能够满足其上部署的所有容器的计算资源开销,可以将其上部署的所有容器的容器计算资源总和,确定为该虚拟机的虚拟机计算资源需求。In this embodiment of the present application, after the first configuration file is obtained, it can be determined whether the first configuration file includes the computing resource requirements of the virtual machine; if it does, it can be determined that the user has directly specified the peak computing resource of the virtual machine corresponding to the Pod, Therefore, the computing resources that should be allocated to the virtual machine can be determined directly according to the computing resource requirements of the virtual machine existing in the first configuration file; if not included, it can be determined that the user has only specified the computing resources of each container deployed in the virtual machine. Therefore, in order to ensure that the computer resources allocated to the virtual machine can meet the computing resource overhead of all the containers deployed on it, the sum of the container computing resources of all the containers deployed on it can be determined as the virtual machine computing resources of the virtual machine. resource requirements.
另外,本申请实施例还提供了一种S103的实施方式,其具体为:先对第一配置文件进行解析,得到解析结果;再判断该解析结果中是否存在该虚拟机的虚拟机计算资源需求,若存在,则确定第一配置文件包括虚拟机计算资源需求;若不存在,则确定第一配置文件不包括虚拟机计算资源需求。其中,解析结果是指对第一配置文件进行参数解析得到的结果,而且解析结果可以包括虚拟机计算资源需求和/或容器计算资源需求。需要说明的是,本申请实施例不限定对第一配置文件的解析过程,例如,第一配置文件可以由k8s进行解析得到。In addition, the embodiment of the present application also provides an implementation of S103, which is specifically: firstly parse the first configuration file to obtain the parsing result; and then determine whether there is a virtual machine computing resource requirement of the virtual machine in the parsing result , if it exists, it is determined that the first configuration file includes the computing resource requirement of the virtual machine; if it does not exist, it is determined that the first configuration file does not include the computing resource requirement of the virtual machine. The parsing result refers to a result obtained by performing parameter parsing on the first configuration file, and the parsing result may include computing resource requirements of a virtual machine and/or computing resource requirements of a container. It should be noted that the embodiment of the present application does not limit the parsing process of the first configuration file. For example, the first configuration file may be obtained by parsing by k8s.
S104:根据第一配置文件中的虚拟机计算资源需求,确定虚拟机的待热插计算资源。S104: Determine the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file.
待热插计算资源是指在虚拟机启动完成之后需要热插至虚拟机中的计算资源,以使热插后的虚拟机能够满足其上部署的所有容器的启动及运行时的计算资源开销。The computing resources to be hot-plugged refer to computing resources that need to be hot-plugged into the virtual machine after the virtual machine is started, so that the hot-plugged virtual machine can meet the computing resource overhead of starting and running all the containers deployed on it.
本申请实施例还提供了S104的一种实施方式,其具体为:对第一配置文件进行解析,得到虚拟机计算资源需求;根据虚拟机计算资源需求,确定虚拟机的待热插计算资源。The embodiment of the present application also provides an implementation of S104, which specifically includes: analyzing the first configuration file to obtain computing resource requirements of the virtual machine; and determining computing resources to be hot-plugged for the virtual machine according to the computing resource requirements of the virtual machine.
基于此可知,本申请实施例中,在获取到第一配置文件之后,可以先从第一配置文件中解析得到虚拟机计算资源需求,再利用解析得到的虚拟机计算资源需求,确定虚拟机的待热插计算资源。Based on this, in the embodiment of the present application, after the first configuration file is obtained, the computing resource requirements of the virtual machine can be obtained by parsing the first configuration file, and then the computing resource requirements of the virtual machine obtained by the analysis can be used to determine the computing resource requirements of the virtual machine. Computing resources to be hot-plugged.
另外,本申请实施例不限定基于虚拟机计算资源需求确定待热插计算资源的实施过程,其具体为:直接将虚拟机计算资源需求确定为虚拟机的待热插计算资源。In addition, the embodiment of the present application does not limit the implementation process of determining the computing resource to be hot-plugged based on the computing resource requirement of the virtual machine, which specifically includes: directly determining the computing resource requirement of the virtual machine as the computing resource to be hot-plugged of the virtual machine.
在一些情况下,除了用户会指定虚拟机的虚拟机计算资源开销以外,运维人员(也就是,对虚拟机的运行过程进行维护的技术人员)也会指定虚拟机的虚拟机基础计算资源开销,故为了能够同时满足用户和运维人员对虚拟机的计算资源需求,可以同时参考该两者指定的计算资源开销来确定虚拟机的待热插计算资源。基于此,本申请实施例还提供了S104的一种实施方式,其具体包括S1041-S1044:In some cases, in addition to the user specifying the virtual machine computing resource overhead of the virtual machine, the operation and maintenance personnel (that is, the technician who maintains the running process of the virtual machine) will also specify the virtual machine basic computing resource overhead of the virtual machine. Therefore, in order to satisfy the computing resource requirements of the user and the operation and maintenance personnel for the virtual machine at the same time, the computing resource to be hot-plugged of the virtual machine can be determined by referring to the computing resource overhead specified by the two at the same time. Based on this, the embodiment of the present application also provides an implementation of S104, which specifically includes S1041-S1044:
S1041:获取第二配置文件。S1041: Obtain a second configuration file.
第二配置文件是指由运维人员提供的用于维护虚拟机运行过程的参数配置文件,而且第二配置文件可以包括虚拟机的基础资源需求。其中,虚拟机的基础资源需求是指用于维护虚拟机运行过程所必须的计算资源开销。The second configuration file refers to a parameter configuration file provided by the operation and maintenance personnel for maintaining the running process of the virtual machine, and the second configuration file may include basic resource requirements of the virtual machine. The basic resource requirement of the virtual machine refers to the computing resource overhead necessary for maintaining the running process of the virtual machine.
S1042:判断虚拟机的基础资源需求满足预设条件;若是,则执行S1043;若否,则执行S1044。S1042: Determine that the basic resource requirement of the virtual machine meets the preset condition; if yes, execute S1043; if not, execute S1044.
预设条件用于表征在确定待热插计算资源时需要参考虚拟机的基础资源需求所满足的条件,而且该预设条件为预先设定。The preset condition is used to represent a condition that needs to be satisfied by reference to the basic resource requirements of the virtual machine when determining the computing resource to be hot-plugged, and the preset condition is preset.
在实际应用中,运维人员针对虚拟机指定的基础资源需求应该不超过预设标准分配资源(也就是,虚拟机启动时实际所需的计算资源),使得在虚拟机启动完成之后,虚拟机能够继续利用被释放的预设标准分配资源来抵消虚拟机的基础资源需求,故在这种情况下无需考虑虚拟机的基础资源需求对待热插计算资源产生的影响;但是,在一些特殊情况下,运维人员对虚拟机指定的基础资源需求会超过预设标准分配资源,使得在虚拟机启动完成之后,虚拟机无法利用被释放的预设标准分配资源来完全抵消虚拟机的基础资源需求,故在这种情况下应该考虑虚拟机的基础资源需求对待热插计算资源产生的影响。In practical applications, the basic resource requirements specified by the operation and maintenance personnel for the virtual machine should not exceed the preset standard allocation resources (that is, the computing resources actually required when the virtual machine is started), so that after the virtual machine is started, the virtual machine It can continue to use the released preset standard allocation resources to offset the basic resource requirements of the virtual machine, so in this case, it is not necessary to consider the impact of the basic resource requirements of the virtual machine on hot-plug computing resources; however, in some special cases , the basic resource requirements specified by the operation and maintenance personnel for the virtual machine will exceed the preset standard allocation resources, so that after the virtual machine is started, the virtual machine cannot use the released preset standard allocation resources to completely offset the basic resource requirements of the virtual machine. Therefore, in this case, the influence of the basic resource requirements of virtual machines on hot-plug computing resources should be considered.
为了能够满足上述两种情况对虚拟机的计算资源需求,可以预先将预设条件设定为虚拟机的基础资源需求高于预设标准分配资源,以使得能够基于该预设条件来判断上述两种情况。In order to meet the computing resource requirements of the virtual machine in the above two situations, a preset condition may be set in advance such that the basic resource requirements of the virtual machine are higher than the preset standard to allocate resources, so that the above two conditions can be determined based on the preset conditions. a situation.
基于上述S1042的相关内容可知,在获取到虚拟机的基础资源需求之后,可以先判断虚拟机的基础资源需求是否满足高于预设标准分配资源;若高于,则可以确定虚拟机启动完成后所释放的预设标准分配资源无法满足虚拟机的基础资源需求,故为了能够同时满足运维人员指定的基础资源需求以及用户指定的虚拟机计算资源需求,可以综合虚拟机的基础资源需求和虚拟机计算资源 需求来共同确定虚拟机的待热插计算资源;若不高于,则可以确定虚拟机启动完成后所释放的预设标准分配资源能够满足虚拟机的基础资源需求,故为了节省计算资源,可以只考虑用户指定的虚拟机计算资源需求来确定虚拟机的待热插计算资源。Based on the relevant content of S1042 above, it can be known that after obtaining the basic resource requirements of the virtual machine, it can be determined whether the basic resource requirements of the virtual machine are higher than the preset standard to allocate resources; if it is higher, it can be determined that after the virtual machine is started The released preset standard allocation resources cannot meet the basic resource requirements of the virtual machine. Therefore, in order to meet the basic resource requirements specified by the operation and maintenance personnel and the computing resource requirements of the virtual machine specified by the user at the same time, the basic resource requirements of the virtual machine and the virtual machine can be integrated. The computing resources to be hot-plugged of the virtual machine are jointly determined according to the computing resource requirements of the virtual machine; if it is not higher than that, it can be determined that the preset standard allocation resources released after the virtual machine is started can meet the basic resource requirements of the virtual machine, so in order to save computing resources resources, the computing resources to be hot-plugged of the virtual machine may be determined only by considering the computing resource requirements of the virtual machine specified by the user.
S1043:根据基础资源需求和第一配置文件中的虚拟机计算资源需求,确定虚拟机的待热插计算资源。S1043: Determine the computing resources to be hot-plugged of the virtual machine according to the basic resource requirements and the computing resource requirements of the virtual machine in the first configuration file.
本申请实施例中,在确定出运维人员指定的基础资源需求高于预设标准分配资源之后,可以确定虚拟机中已有的预设标准分配资源只能抵消该基础资源需求的一部分,故为了节省计算资源,可以根据基础资源需求中未被抵消的部分和用户指定的虚拟机计算资源需求来确定虚拟机的待热插计算资源。In the embodiment of the present application, after it is determined that the basic resource requirements specified by the operation and maintenance personnel are higher than the preset standard allocation resources, it can be determined that the existing preset standard allocation resources in the virtual machine can only offset a part of the basic resource requirements. In order to save computing resources, the computing resources to be hot-plugged of the virtual machine may be determined according to the unoffset part of the basic resource requirements and the computing resource requirements of the virtual machine specified by the user.
基于此,本申请实施例提供了S1043的一种实施方式,其具体为:根据基础资源需求和预设标准分配资源,得到资源差值;根据资源差值和第一配置文件中的虚拟机计算资源需求,确定虚拟机的待热插计算资源。Based on this, the embodiment of the present application provides an implementation of S1043, which specifically includes: allocating resources according to basic resource requirements and preset standards, and obtaining a resource difference; calculating according to the resource difference and the virtual machine in the first configuration file Resource requirements, determine the computing resources to be hot-plugged for the virtual machine.
其中,资源差值用于表征运维人员指定的基础资源需求中未被抵消的部分。Among them, the resource difference is used to represent the unoffset part of the basic resource requirements specified by the operation and maintenance personnel.
基于上述S1043的相关内容可知,在确定出运维人员指定的基础资源需求高于预设标准分配资源之后,可以先将基础资源需求和预设标准分配资源作差,得到资源差值;再将资源差值和用户指定的虚拟机计算资源需求进行求和,确定为虚拟机的待热插计算资源,以使该待热插计算资源与预设标准分配资源的加和能够共同满足运维人员指定的基础资源需求以及用户指定的虚拟机计算资源需求,如此使得热插完成后的虚拟机能够同时满足运维人员以及用户对虚拟机的计算资源需求。Based on the relevant content of the above S1043, after it is determined that the basic resource requirements specified by the operation and maintenance personnel are higher than the preset standard allocation resources, the difference between the basic resource requirements and the preset standard allocation resources can be calculated to obtain the resource difference; The resource difference and the computing resource requirements of the virtual machine specified by the user are summed to determine the computing resources to be hot-plugged for the virtual machine, so that the sum of the computing resources to be hot-plugged and the resources allocated by the preset standard can jointly satisfy the operation and maintenance personnel. The specified basic resource requirements and the user-specified computing resource requirements of the virtual machine, so that the virtual machine after the hot-plug is completed can meet the computing resource requirements of the operation and maintenance personnel and the user for the virtual machine at the same time.
S1044:根据第一配置文件中的虚拟机计算资源需求,确定虚拟机的待热插计算资源。S1044: Determine the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file.
基于上述S1041至S1044的相关内容可知,在获取到用户指定的虚拟机计算资源需求之后,先判断运维人员指定的基础资源需求是否高于虚拟机启动完成后所释放出的预设标准分配资源,若高于,则可以根据用户指定的虚拟机计算资源需求、运维人员指定的基础资源需求和预设标准分配资源的运算,确定虚拟机的待热插计算资源,以使得待热插计算资源与预设标准分配资源的加和能够不低于用户指定的虚拟机计算资源需求与运维人员指定的基础资源需求 的加和,从而使得热插完成后的虚拟机能够同时满足运维人员以及用户对虚拟机的计算资源需求;若不高于,则可以直接根据用户指定的虚拟机计算资源需求确定虚拟机的待热插计算资源即可,如此也能够使得待热插计算资源与预设标准分配资源的加和能够不低于用户指定的虚拟机计算资源需求与运维人员指定的基础资源需求的加和,从而使得热插完成后的虚拟机能够同时满足运维人员以及用户对虚拟机的计算资源需求。Based on the relevant contents of S1041 to S1044 above, it can be known that after obtaining the computing resource requirements of the virtual machine specified by the user, it is first determined whether the basic resource requirements specified by the operation and maintenance personnel are higher than the preset standard allocated resources released after the virtual machine is started. , if it is higher than the computing resource requirements of the virtual machine specified by the user, the basic resource requirements specified by the operation and maintenance personnel, and the calculation of allocating resources according to the preset standard, the computing resources to be hot-plugged of the virtual machine can be determined, so that the computing resources to be hot-plugged can be determined. The sum of resources and preset standard allocation resources can be no less than the sum of the virtual machine computing resource requirements specified by the user and the basic resource requirements specified by the operation and maintenance personnel, so that the virtual machine after the hot swap can meet the requirements of the operation and maintenance personnel at the same time. and the user's computing resource requirements for the virtual machine; if it is not higher than that, the computing resources to be hot-plugged for the virtual machine can be determined directly according to the computing resource requirements of the virtual machine specified by the user. The sum of the standard allocation resources can be no less than the sum of the computing resource requirements of the virtual machine specified by the user and the basic resource requirements specified by the operation and maintenance personnel, so that the virtual machine after the hot-plug can meet the requirements of the operation and maintenance personnel and users at the same time. The computing resource requirements of the virtual machine.
基于上述S104的相关内容可知,在确定出第一配置文件中存在该虚拟机的虚拟机计算资源需求之后,可以直接将该虚拟机的虚拟机计算资源需求,确定为该虚拟机的热插计算资源,其具体为:当虚拟机计算资源需求包括内存需求和CPU需求时,可以直接将该虚拟机的内存需求确定该虚拟机的待热插内存,并且直接将该虚拟机的CPU需求确定为该虚拟机的待热插CPU。其中,因虚拟机的虚拟机计算资源需求是由用户根据该虚拟机的实际计算资源需求直接指定的,使得基于该虚拟机计算资源需求确定的待热插计算资源能够在不浪费计算机资源的前提下满足虚拟机的实际计算资源需求,从而使得热插后的虚拟机能够在不浪费计算机资源的前提下为其上部署的容器提供充足的计算资源,如此能够避免计算资源的浪费。Based on the relevant content of S104 above, it can be known that after determining that the virtual machine computing resource requirements of the virtual machine exist in the first configuration file, the virtual machine computing resource requirements of the virtual machine can be directly determined as the hot-plug computing of the virtual machine. resources, which are specifically: when the computing resource requirements of the virtual machine include memory requirements and CPU requirements, the memory requirements of the virtual machine can be directly determined as the memory to be hot-plugged of the virtual machine, and the CPU requirements of the virtual machine can be directly determined as The CPU to be hot-plugged for this virtual machine. Among them, because the virtual machine computing resource requirements of the virtual machine are directly specified by the user according to the actual computing resource requirements of the virtual machine, the computing resources to be hot-plugged determined based on the computing resource requirements of the virtual machine can be used without wasting computer resources. Therefore, the hot-plugged virtual machine can provide sufficient computing resources for the containers deployed on it without wasting computer resources, thus avoiding the waste of computing resources.
S105:根据第一配置文件中的容器计算资源需求,确定虚拟机的待热插计算资源。S105: Determine the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the container in the first configuration file.
本申请实施例还提供了S105的一种实施方式,其具体为:对第一配置文件进行解析,得到容器计算资源需求;根据该容器计算资源需求,确定虚拟机的待热插计算资源。The embodiment of the present application also provides an implementation of S105, which specifically includes: analyzing the first configuration file to obtain the computing resource requirements of the container; and determining the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the container.
基于此可知,本申请实施例中,在获取到第一配置文件之后,可以先从第一配置文件中解析得到该虚拟机上部署的各个容器的容器计算资源需求,再利用该虚拟机上部署的各个容器的容器计算资源需求,确定虚拟机的待热插计算资源。Based on this, in the embodiment of the present application, after the first configuration file is obtained, the container computing resource requirements of each container deployed on the virtual machine can be obtained by parsing the first configuration file, and then the container computing resource requirements of each container deployed on the virtual machine can be obtained by using the first configuration file. The container computing resource requirements of each container of the virtual machine are determined, and the computing resources to be hot-plugged of the virtual machine are determined.
另外,本申请实施例不限定基于容器计算资源需求确定待热插计算资源的实施过程,其具体为:当虚拟机上部署有N个容器,且第一配置文件包括第1个容器的容器计算资源需求至第N个容器的容器计算资源需求时,根据第1个容器的容器计算资源需求至第N个容器的容器计算资源需求的加和,得到虚拟机的待热插计算资源。In addition, the embodiment of the present application does not limit the implementation process of determining the computing resources to be hot-plugged based on the container computing resource requirements. When the resource demand reaches the container computing resource demand of the Nth container, the computing resources to be hot-plugged of the virtual machine are obtained according to the sum of the container computing resource demand of the first container to the container computing resource demand of the Nth container.
基于此可知,在确定出第一配置文件中存在虚拟机上部署的N个容器的容器计算资源需求之后,可以根据第1个容器的容器计算资源需求至第N个容器的容器计算资源需求的加和,得到虚拟机的待热插计算资源,其具体为:将第1个容器的容器计算资源需求至第N个容器的容器计算资源需求的和值,确定为虚拟机的待热插计算资源。Based on this, after it is determined that there are container computing resource requirements of N containers deployed on the virtual machine in the first configuration file, the container computing resource requirements of the first container can be calculated from the container computing resource requirements of the first container to the container computing resource requirements of the Nth container. Adding the sum to obtain the computing resources to be hot-plugged of the virtual machine, which is specifically: determining the sum of the computing resource requirements of the container from the first container to the computing resource requirements of the N-th container as the computing resources to be hot-plugged of the virtual machine resource.
另外,基于S104中关于“运维人员指定的基础资源需求”的相关内容,本申请实施例还提供了S105的一种可能的实施方式,其具体为包括S1051-S1054:In addition, based on the relevant content of "basic resource requirements specified by operation and maintenance personnel" in S104, this embodiment of the present application also provides a possible implementation of S105, which specifically includes S1051-S1054:
S1051:获取第二配置文件。S1051: Obtain a second configuration file.
S1052:判断虚拟机的基础资源需求满足预设条件;若是,则执行S1053;若否,则执行S1054。S1052: Determine that the basic resource requirement of the virtual machine meets the preset condition; if yes, execute S1053; if not, execute S1054.
S1053:根据基础资源需求和第一配置文件中的容器计算资源需求,确定虚拟机的待热插计算资源。S1053: Determine the computing resources to be hot-plugged of the virtual machine according to the basic resource requirements and the container computing resource requirements in the first configuration file.
S1054:根据第一配置文件中的容器计算资源需求,确定虚拟机的待热插计算资源。S1054: Determine the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the container in the first configuration file.
需要说明的是,S1051至S1054的相关内容分别类似于上文中S1041至S1044的相关内容,只需将上文中S1041至S1044中的“虚拟机计算资源需求”替换为“容器计算资源需求”即可。It should be noted that the relevant contents of S1051 to S1054 are respectively similar to the relevant contents of S1041 to S1044 above, and it is only necessary to replace the “computing resource requirement of virtual machine” in S1041 to S1044 above with “computing resource requirement of container”. .
基于上述S1051至S1054的相关内容可知,在获取到用户指定的容器计算资源需求之后,先判断运维人员指定的基础资源需求是否高于虚拟机启动完成后所释放出的预设标准分配资源,若高于,则可以根据用户指定的容器计算资源需求、运维人员指定的基础资源需求和预设标准分配资源的运算,确定虚拟机的待热插计算资源,以使得待热插计算资源与预设标准分配资源的加和能够不低于用户指定的容器计算资源需求与运维人员指定的基础资源需求的加和,从而使得热插完成后的虚拟机能够同时满足运维人员以及用户对虚拟机的计算资源需求;若不高于,则可以直接根据用户指定的容器计算资源需求确定虚拟机的待热插计算资源即可,如此也能够使得待热插计算资源与预设标准分配资源的加和能够不低于用户指定的容器计算资源需求与运维人员指定的基础资源需求的加和,从而使得热插完成后的虚拟机能够同时满足运维人员以及用户对虚拟机的计算资源需求。Based on the relevant content of S1051 to S1054 above, it can be known that after obtaining the container computing resource requirements specified by the user, it is first determined whether the basic resource requirements specified by the operation and maintenance personnel are higher than the preset standard allocation resources released after the virtual machine is started. If it is higher than that, the computing resources to be hot-plugged of the virtual machine can be determined according to the computing resource requirements of the container specified by the user, the basic resource requirements specified by the operation and maintenance personnel, and the operation of allocating resources according to the preset standard, so that the computing resources to be hot-plugged are different from the computing resources to be hot-plugged. The sum of the resources allocated by the preset standard can be no less than the sum of the container computing resource requirements specified by the user and the basic resource requirements specified by the operation and maintenance personnel, so that the virtual machine after the hot-plug can meet the requirements of the operation and maintenance personnel and users at the same time. The computing resource requirements of the virtual machine; if not higher, the computing resources to be hot-plugged of the virtual machine can be determined directly according to the computing resource requirements of the container specified by the user, which can also make the computing resources to be hot-plugged and the preset standard allocation resources The sum of the container computing resource requirements specified by the user and the basic resource requirements specified by the operation and maintenance personnel can be no less than the sum of the computing resource requirements of the container specified by the user and the basic resource requirements specified by the operation and maintenance personnel, so that the virtual machine after the hot swap can meet the computing resources of the operation and maintenance personnel and the user. need.
基于上述S105的相关内容可知,在确定出第一配置文件中不包括虚拟机的虚拟机计算资源需求,但是包括该虚拟机上部署的所有容器的容器计算资源需求之后,可以直接利用该虚拟机上部署的所有容器的容器计算资源需求的加和,来确定虚拟机的待热插计算资源,以使确定出的待热插计算资源能够满足虚拟机上所有容器的计算资源最大开销。Based on the relevant content of the above S105, it can be seen that after it is determined that the first configuration file does not include the computing resource requirements of the virtual machine of the virtual machine, but includes the computing resource requirements of all the containers deployed on the virtual machine, the virtual machine can be directly used. The sum of the container computing resource requirements of all containers deployed on the virtual machine is used to determine the computing resources to be hot-plugged for the virtual machine, so that the determined computing resources to be hot-plugged can meet the maximum computing resource overhead of all containers on the virtual machine.
S106:将虚拟机的待热插计算资源热插至该虚拟机。S106: Hot-plug the computing resources to be hot-plugged of the virtual machine to the virtual machine.
本申请实施例中,在获取到虚拟机的待热插计算资源之后,可以直接将这些获取到的待热插计算资源热插至虚拟机,以使虚拟机能够满足其上部署的所有容器在运行过程中的计算资源开销。In this embodiment of the present application, after obtaining the computing resources to be hot-plugged of the virtual machine, the obtained computing resources to be hot-plugged can be directly hot-plugged into the virtual machine, so that the virtual machine can meet the requirements of all containers deployed on it. Computational resource overhead during operation.
在一些情况下,在将待热插计算资源热插至虚拟机之后,可以启动该虚拟机上的容器,并对该容器的容器控制组(control groups,cgroups)进行配置。基于此,本申请实施例还提供了计算资源分配方法的一种可能的实施方式,在该实施方式中,该计算机资源分配方法除了包括S101-S106中的全部或部分步骤以外,还包括S107:In some cases, after hot-plugging the computing resource to be hot-plugged into the virtual machine, a container on the virtual machine may be started, and a container control group (control groups, cgroups) of the container may be configured. Based on this, the embodiment of the present application also provides a possible implementation of the computing resource allocation method. In this implementation, the computer resource allocation method includes S107 in addition to all or part of the steps in S101-S106:
S107:启动虚拟机上部署的容器,并根据容器计算资源需求对容器对应的容器控制组进行配置。其中,容器控制组用于对虚拟机上部署的所有容器的容器计算资源进行限制分配。S107: Start the container deployed on the virtual machine, and configure a container control group corresponding to the container according to the container computing resource requirements. The container control group is used to limit the allocation of container computing resources of all containers deployed on the virtual machine.
基于上述S107的相关内容可知,本申请实施例中,在完成对虚拟机的计算资源分配(也就是,将待热插计算资源热插至虚拟机)之后,可以启动该虚拟机上部署的各个容器,并根据各个容器的容器计算资源需求对这些容器对应的容器控制组进行参数配置,以使配置完成的容器控制组能够对该虚拟机上部署的各个容器进行计算资源限制分配。Based on the relevant content of S107 above, it can be known that in the embodiment of the present application, after the computing resource allocation to the virtual machine is completed (that is, the computing resources to be hot-plugged are hot-plugged into the virtual machine), the various components deployed on the virtual machine can be started. Containers, and configure parameters for the container control groups corresponding to these containers according to the container computing resource requirements of each container, so that the configured container control group can perform computing resource limit allocation for each container deployed on the virtual machine.
基于上述计算资源分配方法的相关内容可知,在启动虚拟机之后,获取用户提供的第一配置文件;在确定该第一配置文件包括虚拟机计算资源需求时,先根据该第一配置文件中的虚拟机计算资源需求,确定该虚拟机的待热插计算资源,再将该待热插计算资源热插至该虚拟机,以使得热插后的虚拟机能够拥有充足的计算资源来满足其上部署的容器的计算资源需求。另外,因第一配置文件中的虚拟机计算资源需求是由用户根据该虚拟机的实际计算资源需求设定的,使得基于该虚拟机计算资源需求确定的待热插计算资源能够在不浪费计算机资源的前提下满足虚拟机的实际计算资源需求,从而使得热插后的虚拟机 能够在不浪费计算机资源的前提下为其上部署的容器提供充足的计算资源,如此能够避免计算资源的浪费。Based on the relevant content of the above computing resource allocation method, after starting the virtual machine, the first configuration file provided by the user is obtained; when it is determined that the first configuration file includes the computing resource requirements of the virtual machine, the first configuration file is determined according to the first configuration file The computing resource requirements of the virtual machine, determine the computing resources to be hot-plugged of the virtual machine, and then hot-plug the computing resources to be hot-plugged into the virtual machine, so that the hot-plugged virtual machine can have sufficient computing resources to meet the needs of the virtual machine. The computing resource requirements of the deployed container. In addition, because the computing resource requirements of the virtual machine in the first configuration file are set by the user according to the actual computing resource requirements of the virtual machine, the computing resources to be hot-plugged determined based on the computing resource requirements of the virtual machine can be used without wasting the computer. The virtual machine can meet the actual computing resource requirements of the virtual machine on the premise of resources, so that the hot-plugged virtual machine can provide sufficient computing resources for the containers deployed on it without wasting computer resources, thus avoiding the waste of computing resources.
为了便于理解本申请实施提供的技术方案,下面结合场景实施例进行具体说明。In order to facilitate the understanding of the technical solutions provided by the implementation of the present application, specific descriptions are given below with reference to scene embodiments.
场景实施例Scenario Example
参见图2,该图为本申请实施例提供的使用计算资源分配方法的应用场景示意图。Referring to FIG. 2 , this figure is a schematic diagram of an application scenario of using the computing resource allocation method provided by the embodiment of the present application.
本申请实施例提供的应用于图2所示的应用场景中的计算资源分配方法,包括以下步骤:The computing resource allocation method provided in the embodiment of the present application and applied to the application scenario shown in FIG. 2 includes the following steps:
步骤1:k8s对用户提供的第一配置文件进行解析,得到指定计算资源需求。Step 1: k8s parses the first configuration file provided by the user to obtain the specified computing resource requirements.
k8s用于对集群进行管理控制。k8s is used to manage and control the cluster.
第一配置文件可以是yaml配置文件。另外,yaml配置文件可以包括内存配置项和CPU配置项。其中,内存配置项用于向kata传递用户指定的虚拟机内存的限制信息;CPU配置项用于向kata传递用户指定的虚拟机CPU的限制信息。The first configuration file may be a yaml configuration file. In addition, the yaml configuration file can include memory configuration items and CPU configuration items. Among them, the memory configuration item is used to pass the user-specified virtual machine memory limit information to kata; the CPU configuration item is used to pass the user-specified virtual machine CPU limit information to kata.
指定计算资源需求用于表征用户指定的计算机资源限制,而且指定计算资源需求可以包括虚拟机计算资源需求和/或容器计算资源需求。The specified computing resource requirements are used to characterize user-specified computer resource constraints, and the specified computing resource requirements may include virtual machine computing resource requirements and/or container computing resource requirements.
步骤2:在kata-runtime获取到指定计算资源需求之后,判断该指定计算资源需求是否包括虚拟机的虚拟机计算资源需求;若是,则执行步骤3;若否,则执行步骤4。其中,kata-runtime用于对虚拟机进行管理控制。Step 2: After kata-runtime obtains the specified computing resource requirement, it is judged whether the specified computing resource requirement includes the virtual machine computing resource requirement of the virtual machine; if so, step 3 is performed; if not, step 4 is performed. Among them, kata-runtime is used to manage and control the virtual machine.
步骤3:根据虚拟机的虚拟机计算资源需求、基础资源需求和预设标准分配资源,确定虚拟机的待热插计算资源。Step 3: Allocate resources according to virtual machine computing resource requirements, basic resource requirements, and preset standards of the virtual machine, and determine computing resources to be hot-plugged for the virtual machine.
步骤4:将待热插计算资源热插至虚拟机。Step 4: Hot-plug the computing resources to be hot-plugged to the virtual machine.
步骤5:启动虚拟机上部署的容器,并根据容器计算资源需求对容器对应的容器控制组进行配置。Step 5: Start the container deployed on the virtual machine, and configure the container control group corresponding to the container according to the container computing resource requirements.
需要说明的是,上述步骤1至步骤5的相关内容请参见上文方法实施例中的相关内容。It should be noted that, for the relevant content of the above steps 1 to 5, please refer to the relevant content in the above method embodiments.
基于上述步骤1至步骤5的相关内容可知,用户可以预先在第一配置文件 中指定虚拟机计算资源需求以及容器计算资源需求,以便后续能够基于虚拟机计算资源需求来确定需要再热插至虚拟机中的计算资源(CPU和/或内存),并基于该虚拟机上部署的各个容器的容器计算资源需求对容器控制组进行配置,以使该容器控制组能够对虚拟机上部署的所有容器进行控制限制。Based on the above steps 1 to 5, it can be known that the user can specify the computing resource requirements of the virtual machine and the computing resource of the container in the first configuration file in advance, so that the user can subsequently determine the need to hot-plug to the virtual machine based on the computing resource requirements of the virtual machine. the computing resources (CPU and/or memory) in the virtual machine, and configure the container control group based on the container computing resource requirements of each container deployed on the virtual machine, so that the container control group can control all the containers deployed on the virtual machine. Control restrictions.
基于上述方法实施例提供的计算资源分配方法,本申请实施例还提供了一种计算资源分配装置,下面结合附图进行解释和说明。Based on the computing resource allocation method provided by the above method embodiments, the embodiments of the present application further provide a computing resource allocation device, which will be explained and described below with reference to the accompanying drawings.
装置实施例Device embodiment
装置实施例提供的计算资源分配装置的技术详情,请参照上述方法实施例。For technical details of the computing resource allocation apparatus provided by the apparatus embodiment, please refer to the above method embodiment.
参见图3,该图为本申请实施例提供的一种计算资源分配装置的结构示意图。Referring to FIG. 3 , this figure is a schematic structural diagram of a computing resource allocation apparatus provided by an embodiment of the present application.
本申请实施例提供的计算资源分配装置300,包括:The computing resource allocation apparatus 300 provided by the embodiment of the present application includes:
启动单元301,设置为启动虚拟机;A startup unit 301, configured to start a virtual machine;
第一获取单元302,设置为获取用户提供的第一配置文件;The first obtaining unit 302 is configured to obtain the first configuration file provided by the user;
第一确定单元303,设置为在确定所述第一配置文件包括虚拟机计算资源需求时,根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源;The first determining unit 303 is configured to, when determining that the first configuration file includes the computing resource requirements of the virtual machine, determine the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file ;
热插单元304,设置为将所述待热插计算资源热插至所述虚拟机。The hot-plug unit 304 is configured to hot-plug the computing resource to be hot-plugged into the virtual machine.
在一种可能的实施方式中,所述第一确定单元303,具体设置为:对所述第一配置文件进行解析,得到虚拟机计算资源需求;根据所述虚拟机计算资源需求,确定所述虚拟机的待热插计算资源。In a possible implementation manner, the first determining unit 303 is specifically configured to: parse the first configuration file to obtain computing resource requirements of the virtual machine; determine the computing resource requirements of the virtual machine according to the computing resource requirements of the virtual machine The computing resources to be hot-plugged for the virtual machine.
在一种可能的实施方式中,所述第一确定单元303,包括:In a possible implementation manner, the first determining unit 303 includes:
第一获取子单元,设置为获取第二配置文件,所述第二配置文件包括所述虚拟机的基础资源需求;a first obtaining subunit, configured to obtain a second configuration file, where the second configuration file includes basic resource requirements of the virtual machine;
第一确定子单元,设置为在确定所述基础资源需求满足预设条件时,根据所述基础资源需求和所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源;a first determining subunit, configured to determine the standby-heating of the virtual machine according to the basic resource requirements and the computing resource requirements of the virtual machine in the first configuration file when it is determined that the basic resource requirements meet a preset condition Insert computing resources;
第二确定子单元,设置为在确定所述基础资源需求不满足预设条件时,根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算 资源。The second determination subunit is configured to determine the computing resource to be hot-plugged of the virtual machine according to the computing resource requirement of the virtual machine in the first configuration file when it is determined that the basic resource requirement does not meet the preset condition.
在一种可能的实施方式中,所述第一确定子单元,具体设置为:根据所述基础资源需求和预设标准分配资源,得到资源差值;根据所述资源差值和所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源。In a possible implementation manner, the first determining subunit is specifically configured to: allocate resources according to the basic resource requirements and preset criteria, and obtain a resource difference value; according to the resource difference value and the first The computing resource requirements of the virtual machine in the configuration file determine the computing resources to be hot-plugged for the virtual machine.
在一种可能的实施方式中,所述计算资源分配装置300还包括:In a possible implementation manner, the computing resource allocation apparatus 300 further includes:
第二确定单元,设置为在确定所述第一配置文件不包括虚拟机计算资源需求,且确定所述第一配置文件包括容器计算资源需求时,根据所述第一配置文件中的容器计算资源需求,确定所述虚拟机的待热插计算资源。A second determining unit, configured to, when it is determined that the first configuration file does not include the computing resource requirements of the virtual machine, and that the first configuration file includes the computing resource requirements of the container, according to the computing resources of the container in the first configuration file requirements, and determine the computing resources to be hot-plugged for the virtual machine.
在一种可能的实施方式中,所述第二确定单元,具体设置为:当所述虚拟机上部署有N个容器,且所述第一配置文件包括第1个容器的容器计算资源需求至第N个容器的容器计算资源需求时,根据第1个容器的容器计算资源需求至第N个容器的容器计算资源需求的加和,得到所述虚拟机的待热插计算资源。In a possible implementation manner, the second determining unit is specifically set to: when N containers are deployed on the virtual machine, and the first configuration file includes the container computing resource requirements of the first container to When the container computing resource requirements of the Nth container are used, the computing resources to be hot-plugged of the virtual machine are obtained according to the sum of the container computing resource requirements of the first container to the container computing resource requirements of the Nth container.
在一种可能的实施方式中,当所述第一配置文件还包括容器计算资源需求时,所述计算资源分配装置300还包括:In a possible implementation manner, when the first configuration file further includes container computing resource requirements, the computing resource allocation apparatus 300 further includes:
配置单元,设置为启动所述虚拟机上部署的容器,并根据所述容器计算资源需求对所述容器对应的容器控制组进行配置。The configuration unit is configured to start the container deployed on the virtual machine, and configure the container control group corresponding to the container according to the computing resource requirements of the container.
基于上述计算资源分配装置300的相关内容可知,在计算资源分配装置300中,启动虚拟机,并获取用户提供的第一配置文件;在确定该第一配置文件包括虚拟机计算资源需求时,先根据该第一配置文件中的虚拟机计算资源需求,确定该虚拟机的待热插计算资源,再将该待热插计算资源热插至该虚拟机,以使得热插后的虚拟机能够拥有充足的计算资源来满足其上部署的容器的计算资源需求。另外,因第一配置文件中的虚拟机计算资源需求是由用户根据该虚拟机的实际计算资源需求设定的,使得基于该虚拟机计算资源需求确定的待热插计算资源能够满足虚拟机的实际计算资源需求,从而使得热插后的虚拟机能够为其上部署的容器提供充足的计算资源。Based on the above-mentioned relevant content of the computing resource allocation device 300, it can be known that in the computing resource allocation device 300, the virtual machine is started, and the first configuration file provided by the user is obtained; when it is determined that the first configuration file includes the computing resource requirements of the virtual machine, the According to the computing resource requirements of the virtual machine in the first configuration file, determine the computing resources to be hot-plugged for the virtual machine, and then hot-plug the computing resources to be hot-plugged into the virtual machine, so that the hot-plugged virtual machine can have Sufficient computing resources to meet the computing resource requirements of the containers deployed on it. In addition, since the computing resource requirements of the virtual machine in the first configuration file are set by the user according to the actual computing resource requirements of the virtual machine, the computing resources to be hot-plugged determined based on the computing resource requirements of the virtual machine can meet the requirements of the virtual machine. Actual computing resource requirements, so that the hot-plugged virtual machine can provide sufficient computing resources for the containers deployed on it.
基于上述方法实施例提供的计算资源分配方法,本申请实施例还提供了一种设备,下面结合附图进行解释和说明。Based on the computing resource allocation method provided by the above method embodiment, the embodiment of the present application further provides a device, which is explained and described below with reference to the accompanying drawings.
设备实施例Device Embodiment
设备实施例提供的设备技术详情,请参照上述方法实施例。For details of the device technology provided by the device embodiment, please refer to the above method embodiment.
参见图4,该图为本申请实施例提供的设备结构示意图。Referring to FIG. 4 , this figure is a schematic structural diagram of a device provided by an embodiment of the present application.
本申请实施例提供的设备400,包括:处理器401以及存储器402;The device 400 provided by this embodiment of the present application includes: a processor 401 and a memory 402;
所述存储器402用于存储计算机程序;The memory 402 is used to store computer programs;
所述处理器401用于根据所述计算机程序执行上述方法实施例提供的计算资源分配方法的任一实施方式。也就是说,处理器401用于执行以下步骤:The processor 401 is configured to execute any implementation manner of the computing resource allocation method provided by the above method embodiments according to the computer program. That is, the processor 401 is configured to perform the following steps:
启动虚拟机;start the virtual machine;
获取用户提供的第一配置文件;Obtain the first configuration file provided by the user;
在确定所述第一配置文件包括虚拟机计算资源需求时,根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源;When it is determined that the first configuration file includes the computing resource requirements of the virtual machine, determining the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file;
将所述待热插计算资源热插至所述虚拟机。Hot-plug the computing resource to be hot-plugged to the virtual machine.
在一实施方式中,所述根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源,包括:In one embodiment, the determining of the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file includes:
对所述第一配置文件进行解析,得到虚拟机计算资源需求;Parsing the first configuration file to obtain computing resource requirements of the virtual machine;
根据所述虚拟机计算资源需求,确定所述虚拟机的待热插计算资源。According to the computing resource requirements of the virtual machine, the computing resources to be hot-plugged of the virtual machine are determined.
在一实施方式中,所述根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源,包括:In one embodiment, the determining of the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file includes:
获取第二配置文件,所述第二配置文件包括所述虚拟机的基础资源需求;obtaining a second configuration file, where the second configuration file includes basic resource requirements of the virtual machine;
在确定所述基础资源需求满足预设条件时,根据所述基础资源需求和所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源;When it is determined that the basic resource requirement satisfies the preset condition, the computing resource to be hot-plugged of the virtual machine is determined according to the basic resource requirement and the computing resource requirement of the virtual machine in the first configuration file;
在确定所述基础资源需求不满足预设条件时,根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源。When it is determined that the basic resource requirement does not meet the preset condition, the computing resource to be hot-plugged of the virtual machine is determined according to the computing resource requirement of the virtual machine in the first configuration file.
在一实施方式中,所述根据所述基础资源需求和所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源,包括:In one embodiment, the determining of the computing resources to be hot-plugged for the virtual machine according to the basic resource requirements and the computing resource requirements of the virtual machine in the first configuration file includes:
根据所述基础资源需求和预设标准分配资源,得到资源差值;Allocate resources according to the basic resource requirements and preset criteria to obtain a resource difference;
根据所述资源差值和所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源。According to the resource difference and the computing resource requirements of the virtual machine in the first configuration file, the computing resources to be hot-plugged for the virtual machine are determined.
在一实施方式中,所述方法还包括:In one embodiment, the method further includes:
在确定所述第一配置文件不包括虚拟机计算资源需求,且确定所述第一配置文件包括容器计算资源需求时,根据所述第一配置文件中的容器计算资源需 求,确定所述虚拟机的待热插计算资源。When it is determined that the first configuration file does not include the computing resource requirement of the virtual machine, and it is determined that the first configuration file includes the computing resource requirement of the container, the virtual machine is determined according to the computing resource requirement of the container in the first configuration file The computing resources to be hot-plugged.
在一实施方式中,当所述虚拟机上部署有N个容器,且所述第一配置文件包括第1个容器的容器计算资源需求至第N个容器的容器计算资源需求时,所述根据所述第一配置文件中的容器计算资源需求,确定所述虚拟机的待热插计算资源,包括:In one embodiment, when N containers are deployed on the virtual machine, and the first configuration file includes the container computing resource requirements of the first container to the container computing resource requirements of the Nth container, the The container computing resource requirements in the first configuration file determine the computing resources to be hot-plugged for the virtual machine, including:
根据第1个容器的容器计算资源需求至第N个容器的容器计算资源需求的加和,得到所述虚拟机的待热插计算资源。According to the sum of the container computing resource requirements of the first container to the container computing resource requirements of the Nth container, the computing resources to be hot-plugged of the virtual machine are obtained.
在一实施方式中,当所述第一配置文件还包括容器计算资源需求时,所述方法还包括:In one embodiment, when the first configuration file further includes container computing resource requirements, the method further includes:
启动所述虚拟机上部署的容器,并根据所述容器计算资源需求对所述容器对应的容器控制组进行配置。A container deployed on the virtual machine is started, and a container control group corresponding to the container is configured according to the computing resource requirements of the container.
以上为本申请实施例提供的设备400的相关内容。The above is the related content of the device 400 provided in the embodiment of the present application.
基于上述方法实施例提供的计算资源分配方法,本申请实施例还提供了一种计算机可读存储介质。Based on the computing resource allocation method provided by the foregoing method embodiments, the embodiments of the present application further provide a computer-readable storage medium.
介质实施例medium example
介质实施例提供的计算机可读存储介质的技术详情,请参照方法实施例。For technical details of the computer-readable storage medium provided by the medium embodiment, please refer to the method embodiment.
本申请实施例提供了一种计算机可读存储介质,该计算机可读存储介质用于存储计算机程序,所述计算机程序用于执行上述方法实施例提供的计算资源分配方法的任一实施方式。也就是说,该计算机程序用于执行以下步骤:The embodiments of the present application provide a computer-readable storage medium, where the computer-readable storage medium is used to store a computer program, and the computer program is used to execute any implementation manner of the computing resource allocation method provided by the above method embodiments. That is, the computer program is used to perform the following steps:
启动虚拟机;start the virtual machine;
获取用户提供的第一配置文件;Obtain the first configuration file provided by the user;
在确定所述第一配置文件包括虚拟机计算资源需求时,根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源;When it is determined that the first configuration file includes the computing resource requirements of the virtual machine, determining the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file;
将所述待热插计算资源热插至所述虚拟机。Hot-plug the computing resource to be hot-plugged to the virtual machine.
在一实施方式中,所述根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源,包括:In one embodiment, the determining of the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file includes:
对所述第一配置文件进行解析,得到虚拟机计算资源需求;Parsing the first configuration file to obtain computing resource requirements of the virtual machine;
根据所述虚拟机计算资源需求,确定所述虚拟机的待热插计算资源。According to the computing resource requirements of the virtual machine, the computing resources to be hot-plugged of the virtual machine are determined.
在一实施方式中,所述根据所述第一配置文件中的虚拟机计算资源需求, 确定所述虚拟机的待热插计算资源,包括:In one embodiment, the determining of the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file includes:
获取第二配置文件,所述第二配置文件包括所述虚拟机的基础资源需求;obtaining a second configuration file, where the second configuration file includes basic resource requirements of the virtual machine;
在确定所述基础资源需求满足预设条件时,根据所述基础资源需求和所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源;When it is determined that the basic resource requirement satisfies the preset condition, the computing resource to be hot-plugged of the virtual machine is determined according to the basic resource requirement and the computing resource requirement of the virtual machine in the first configuration file;
在确定所述基础资源需求不满足预设条件时,根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源。When it is determined that the basic resource requirement does not meet the preset condition, the computing resource to be hot-plugged of the virtual machine is determined according to the computing resource requirement of the virtual machine in the first configuration file.
在一实施方式中,所述根据所述基础资源需求和所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源,包括:In one embodiment, the determining of the computing resources to be hot-plugged for the virtual machine according to the basic resource requirements and the computing resource requirements of the virtual machine in the first configuration file includes:
根据所述基础资源需求和预设标准分配资源,得到资源差值;Allocate resources according to the basic resource requirements and preset criteria to obtain a resource difference;
根据所述资源差值和所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源。According to the resource difference and the computing resource requirements of the virtual machine in the first configuration file, the computing resources to be hot-plugged for the virtual machine are determined.
在一实施方式中,所述方法还包括:In one embodiment, the method further includes:
在确定所述第一配置文件不包括虚拟机计算资源需求,且确定所述第一配置文件包括容器计算资源需求时,根据所述第一配置文件中的容器计算资源需求,确定所述虚拟机的待热插计算资源。When it is determined that the first configuration file does not include the computing resource requirement of the virtual machine, and it is determined that the first configuration file includes the computing resource requirement of the container, the virtual machine is determined according to the computing resource requirement of the container in the first configuration file The computing resources to be hot-plugged.
在一实施方式中,当所述虚拟机上部署有N个容器,且所述第一配置文件包括第1个容器的容器计算资源需求至第N个容器的容器计算资源需求时,所述根据所述第一配置文件中的容器计算资源需求,确定所述虚拟机的待热插计算资源,包括:In one embodiment, when N containers are deployed on the virtual machine, and the first configuration file includes the container computing resource requirements of the first container to the container computing resource requirements of the Nth container, the The container computing resource requirements in the first configuration file determine the computing resources to be hot-plugged for the virtual machine, including:
根据第1个容器的容器计算资源需求至第N个容器的容器计算资源需求的加和,得到所述虚拟机的待热插计算资源。According to the sum of the container computing resource requirements of the first container to the container computing resource requirements of the Nth container, the computing resources to be hot-plugged of the virtual machine are obtained.
在一实施方式中,当所述第一配置文件还包括容器计算资源需求时,所述方法还包括:In one embodiment, when the first configuration file further includes container computing resource requirements, the method further includes:
启动所述虚拟机上部署的容器,并根据所述容器计算资源需求对所述容器对应的容器控制组进行配置。A container deployed on the virtual machine is started, and a container control group corresponding to the container is configured according to the computing resource requirements of the container.
以上为本申请实施例提供的计算机可读存储介质的相关内容。The above is the related content of the computer-readable storage medium provided by the embodiments of the present application.
应当理解,在本申请实施例中,“至少一个(项)”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,用于描述关联对象的关联关系,表示可以存在三种关系,例如,“A和/或B”可以表示:只存在A,只存在B以及同 时存在A和B三种情况,其中A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。“以下至少一项(个)”或其类似表达,是指这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a,b或c中的至少一项(个),可以表示:a,b,c,“a和b”,“a和c”,“b和c”,或“a和b和c”,其中a,b,c可以是单个,也可以是多个。It should be understood that, in the embodiments of the present application, "at least one (item)" refers to one or more, and "a plurality" refers to two or more. "And/or" is used to describe the relationship between related objects, indicating that there can be three kinds of relationships, for example, "A and/or B" can mean: only A, only B, and both A and B exist , where A and B can be singular or plural. The character "/" generally indicates that the related objects are an "or" relationship. "At least one item(s) below" or similar expressions thereof refer to any combination of these items, including any combination of single item(s) or plural items(s). For example, at least one (a) of a, b or c, can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c" ", where a, b, c can be single or multiple.
以上所述,仅是本公开的较佳实施例而已,并非对本公开作任何形式上的限制。虽然本公开已以较佳实施例揭露如上,然而并非用以限定本公开。任何熟悉本领域的技术人员,在不脱离本公开技术方案范围情况下,都可利用上述揭示的方法和技术内容对本公开技术方案做出许多可能的变动和修饰,或修改为等同变化的等效实施例。因此,凡是未脱离本公开技术方案的内容,依据本公开的技术实质对以上实施例所做的任何简单修改、等同变化及修饰,均仍属于本公开技术方案保护的范围内。The above descriptions are only preferred embodiments of the present disclosure, and do not limit the present disclosure in any form. Although the present disclosure has been disclosed above with preferred embodiments, it is not intended to limit the present disclosure. Any person skilled in the art, without departing from the scope of the technical solutions of the present disclosure, can make many possible changes and modifications to the technical solutions of the present disclosure by using the methods and technical contents disclosed above, or modify them into equivalents of equivalent changes. Example. Therefore, any simple modifications, equivalent changes and modifications made to the above embodiments according to the technical essence of the present disclosure without departing from the content of the technical solutions of the present disclosure still fall within the protection scope of the technical solutions of the present disclosure.
工业实用性Industrial Applicability
基于本公开实施例提供的计算资源分配方法及相关设备,启动虚拟机,并获取用户提供的第一配置文件;在确定该第一配置文件包括虚拟机计算资源需求时,先根据该第一配置文件中的虚拟机计算资源需求,确定该虚拟机的待热插计算资源,再将该待热插计算资源热插至该虚拟机,以使得热插后的虚拟机能够拥有充足的计算资源来满足其上部署的容器的计算资源需求。另外,因第一配置文件中的虚拟机计算资源需求是由用户根据该虚拟机的实际计算资源需求设定的,使得基于该虚拟机计算资源需求确定的待热插计算资源能够满足虚拟机的实际计算资源需求,从而使得热插后的虚拟机能够为其上部署的容器提供充足的计算资源。Based on the computing resource allocation method and related devices provided by the embodiments of the present disclosure, start the virtual machine, and obtain the first configuration file provided by the user; when it is determined that the first configuration file includes the computing resource requirements of the virtual machine, according to the first configuration The computing resource requirements of the virtual machine in the file, determine the computing resources to be hot-plugged for the virtual machine, and then hot-plug the computing resources to be hot-plugged into the virtual machine, so that the hot-plugged virtual machine can have sufficient computing resources to Satisfy the computing resource requirements of the containers deployed on it. In addition, because the computing resource requirements of the virtual machine in the first configuration file are set by the user according to the actual computing resource requirements of the virtual machine, the computing resources to be hot-plugged determined based on the computing resource requirements of the virtual machine can meet the requirements of the virtual machine. Actual computing resource requirements, so that the hot-plugged virtual machine can provide sufficient computing resources for the containers deployed on it.

Claims (10)

  1. 一种计算资源分配方法,包括:A computing resource allocation method, comprising:
    启动虚拟机;start the virtual machine;
    获取用户提供的第一配置文件;Obtain the first configuration file provided by the user;
    在确定所述第一配置文件包括虚拟机计算资源需求时,根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源;When it is determined that the first configuration file includes the computing resource requirements of the virtual machine, determining the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file;
    将所述待热插计算资源热插至所述虚拟机。Hot-plug the computing resource to be hot-plugged to the virtual machine.
  2. 根据权利要求1所述的方法,其中,所述根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源,包括:The method according to claim 1, wherein the determining the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file comprises:
    对所述第一配置文件进行解析,得到虚拟机计算资源需求;Parsing the first configuration file to obtain computing resource requirements of the virtual machine;
    根据所述虚拟机计算资源需求,确定所述虚拟机的待热插计算资源。According to the computing resource requirements of the virtual machine, the computing resources to be hot-plugged of the virtual machine are determined.
  3. 根据权利要求1所述的方法,其中,所述根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源,包括:The method according to claim 1, wherein the determining the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file comprises:
    获取第二配置文件,所述第二配置文件包括所述虚拟机的基础资源需求;obtaining a second configuration file, where the second configuration file includes basic resource requirements of the virtual machine;
    在确定所述基础资源需求满足预设条件时,根据所述基础资源需求和所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源;When it is determined that the basic resource requirement satisfies the preset condition, the computing resource to be hot-plugged of the virtual machine is determined according to the basic resource requirement and the computing resource requirement of the virtual machine in the first configuration file;
    在确定所述基础资源需求不满足预设条件时,根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源。When it is determined that the basic resource requirement does not meet the preset condition, the computing resource to be hot-plugged of the virtual machine is determined according to the computing resource requirement of the virtual machine in the first configuration file.
  4. 根据权利要求3所述的方法,其中,所述根据所述基础资源需求和所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源,包括:The method according to claim 3, wherein the determining the computing resources to be hot-plugged of the virtual machine according to the basic resource requirements and the computing resource requirements of the virtual machine in the first configuration file comprises:
    根据所述基础资源需求和预设标准分配资源,得到资源差值;Allocate resources according to the basic resource requirements and preset criteria to obtain a resource difference;
    根据所述资源差值和所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源。According to the resource difference and the computing resource requirements of the virtual machine in the first configuration file, the computing resources to be hot-plugged for the virtual machine are determined.
  5. 根据权利要求1-4任一项所述的方法,其中,所述方法还包括:The method according to any one of claims 1-4, wherein the method further comprises:
    在确定所述第一配置文件不包括虚拟机计算资源需求,且确定所述第一配置文件包括容器计算资源需求时,根据所述第一配置文件中的容器计算资源需求,确定所述虚拟机的待热插计算资源。When it is determined that the first configuration file does not include the computing resource requirement of the virtual machine, and it is determined that the first configuration file includes the computing resource requirement of the container, the virtual machine is determined according to the computing resource requirement of the container in the first configuration file The computing resources to be hot-plugged.
  6. 根据权利要求5所述的方法,其中,当所述虚拟机上部署有N个容器,且所述第一配置文件包括第1个容器的容器计算资源需求至第N个容器的容器计算资源需求,N为正整数时,所述根据所述第一配置文件中的容器计算资源需求,确定所述虚拟机的待热插计算资源,包括:The method according to claim 5, wherein when N containers are deployed on the virtual machine, and the first configuration file includes the container computing resource requirements of the first container to the container computing resource requirements of the Nth container , when N is a positive integer, determining the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the container in the first configuration file, including:
    根据第1个容器的容器计算资源需求至第N个容器的容器计算资源需求的加和,得到所述虚拟机的待热插计算资源。According to the sum of the container computing resource requirements of the first container to the container computing resource requirements of the Nth container, the computing resources to be hot-plugged of the virtual machine are obtained.
  7. 根据权利要求1-6任一项所述的方法,其中,当所述第一配置文件还包括容器计算资源需求时,所述方法还包括:The method according to any one of claims 1-6, wherein, when the first configuration file further includes container computing resource requirements, the method further includes:
    启动所述虚拟机上部署的容器,并根据所述容器计算资源需求对所述容器对应的容器控制组进行配置。A container deployed on the virtual machine is started, and a container control group corresponding to the container is configured according to the computing resource requirements of the container.
  8. 一种计算资源分配装置,包括:A computing resource allocation device, comprising:
    启动单元,设置为启动虚拟机;Start the unit, set to start the virtual machine;
    第一获取单元,设置为获取用户提供的第一配置文件;a first obtaining unit, configured to obtain the first configuration file provided by the user;
    第一确定单元,设置为在确定所述第一配置文件包括虚拟机计算资源需求时,根据所述第一配置文件中的虚拟机计算资源需求,确定所述虚拟机的待热插计算资源;a first determining unit, configured to, when determining that the first configuration file includes the computing resource requirements of the virtual machine, determine the computing resources to be hot-plugged of the virtual machine according to the computing resource requirements of the virtual machine in the first configuration file;
    热插单元,设置为将所述待热插计算资源热插至所述虚拟机。A hot-plug unit, configured to hot-plug the computing resource to be hot-plugged into the virtual machine.
  9. 一种设备,所述设备包括处理器以及存储器:A device comprising a processor and a memory:
    所述存储器用于存储计算机程序;the memory is used to store computer programs;
    所述处理器用于根据所述计算机程序执行权利要求1-7中任一项所述的方法。The processor is adapted to perform the method of any one of claims 1-7 according to the computer program.
  10. 一种计算机可读存储介质,所述计算机可读存储介质用于存储计算机程序,所述计算机程序用于执行权利要求1-7中任一项所述的方法。A computer-readable storage medium for storing a computer program for performing the method of any one of claims 1-7.
PCT/CN2021/097603 2020-09-18 2021-06-01 Computing resource allocation method and related device WO2022057317A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010989061.0 2020-09-18
CN202010989061.0A CN112114936A (en) 2020-09-18 2020-09-18 Computing resource allocation method and related equipment

Publications (1)

Publication Number Publication Date
WO2022057317A1 true WO2022057317A1 (en) 2022-03-24

Family

ID=73800713

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/097603 WO2022057317A1 (en) 2020-09-18 2021-06-01 Computing resource allocation method and related device

Country Status (2)

Country Link
CN (1) CN112114936A (en)
WO (1) WO2022057317A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112114936A (en) * 2020-09-18 2020-12-22 北京金山云网络技术有限公司 Computing resource allocation method and related equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103455379A (en) * 2013-09-05 2013-12-18 华为技术有限公司 Resource allocation method and system
US8615579B1 (en) * 2010-12-28 2013-12-24 Amazon Technologies, Inc. Managing virtual machine migration
CN107729218A (en) * 2017-11-10 2018-02-23 郑州云海信息技术有限公司 A kind of system and method for monitoring processing computing resource equipment
CN110532064A (en) * 2019-08-27 2019-12-03 北京百度网讯科技有限公司 Method, apparatus, equipment and the storage medium of computing resource are provided
CN110998530A (en) * 2017-08-02 2020-04-10 华为技术有限公司 Virtual machine resource allocation system, method and computer program
CN112114936A (en) * 2020-09-18 2020-12-22 北京金山云网络技术有限公司 Computing resource allocation method and related equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8615579B1 (en) * 2010-12-28 2013-12-24 Amazon Technologies, Inc. Managing virtual machine migration
CN103455379A (en) * 2013-09-05 2013-12-18 华为技术有限公司 Resource allocation method and system
CN110998530A (en) * 2017-08-02 2020-04-10 华为技术有限公司 Virtual machine resource allocation system, method and computer program
CN107729218A (en) * 2017-11-10 2018-02-23 郑州云海信息技术有限公司 A kind of system and method for monitoring processing computing resource equipment
CN110532064A (en) * 2019-08-27 2019-12-03 北京百度网讯科技有限公司 Method, apparatus, equipment and the storage medium of computing resource are provided
CN112114936A (en) * 2020-09-18 2020-12-22 北京金山云网络技术有限公司 Computing resource allocation method and related equipment

Also Published As

Publication number Publication date
CN112114936A (en) 2020-12-22

Similar Documents

Publication Publication Date Title
US11182196B2 (en) Unified resource management for containers and virtual machines
US11875173B2 (en) Execution of auxiliary functions in an on-demand network code execution system
US10817331B2 (en) Execution of auxiliary functions in an on-demand network code execution system
EP3811209A1 (en) Execution of auxiliary functions in an on-demand network code execution system
US9582312B1 (en) Execution context trace for asynchronous tasks
JP5510556B2 (en) Method and system for managing virtual machine storage space and physical hosts
US20060155708A1 (en) System and method for generating virtual networks
CN108845954B (en) Pressure testing method, system and storage medium
WO2019196250A1 (en) Task handling method, storage medium, server, and device
US8239872B2 (en) Method and system for controlling distribution of work items to threads in a server
GB2437145A (en) Dynamically allocating resources used by software
WO2020114057A1 (en) Data processing method and apparatus, and server
US9619288B2 (en) Deploying software in a multi-instance node
US9513934B2 (en) Platform and software framework for data intensive applications in the cloud
WO2018228216A1 (en) Virtual machine deployment method and omm virtual machine
CN110971700B (en) Method and device for realizing distributed lock
CN110633130B (en) Virtual memory management method and device based on memory hot plug technology
CN111064746A (en) Resource allocation method, device, equipment and storage medium
WO2022057317A1 (en) Computing resource allocation method and related device
CN107038066B (en) Job computing system based on Web
CN114546587A (en) Capacity expansion and reduction method of online image recognition service and related device
CN104700255B (en) Multi-process processing method, device and system
WO2021169287A1 (en) Master-slave architecture configuration method, appartus and device, and computer-readable storage medium
WO2022267646A1 (en) Pod deployment method and apparatus
EP4177742A1 (en) Multitenancy management method and apparatus

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21868153

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21868153

Country of ref document: EP

Kind code of ref document: A1