CN115617459A - Method, device and equipment for resource scheduling - Google Patents

Method, device and equipment for resource scheduling Download PDF

Info

Publication number
CN115617459A
CN115617459A CN202211329279.9A CN202211329279A CN115617459A CN 115617459 A CN115617459 A CN 115617459A CN 202211329279 A CN202211329279 A CN 202211329279A CN 115617459 A CN115617459 A CN 115617459A
Authority
CN
China
Prior art keywords
virtual machine
platform
information
resource object
custom
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211329279.9A
Other languages
Chinese (zh)
Inventor
陈金辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Yunzhou Information Technology Co ltd
Original Assignee
Shanghai Yunzhou Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Yunzhou Information Technology Co ltd filed Critical Shanghai Yunzhou Information Technology Co ltd
Priority to CN202211329279.9A priority Critical patent/CN115617459A/en
Publication of CN115617459A publication Critical patent/CN115617459A/en
Pending legal-status Critical Current

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/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources
    • 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/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • 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/5077Logical partitioning of resources; Management or configuration of virtualized resources
    • 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/45562Creating, deleting, cloning 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/4557Distribution of virtual machine instances; Migration and load balancing
    • 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/45595Network integration; Enabling network access in virtual machine instances

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The application provides a method, a device and equipment for resource scheduling, which are applied to a cloud platform for deploying a virtual machine platform and a container platform k8s simultaneously. The method comprises the following steps: creating a CRD resource type in a container platform k8s, and deploying a corresponding Controller; based on the CRD resource type, creating a custom resource object and editing custom field information therein, or modifying custom field information in the existing custom resource object, wherein the custom field comprises an expected state attribute and a virtual machine attribute; based on the watch mechanism of the container platform k8s, when the Controller monitors that the custom resource object changes, according to the information of the expected state attribute, a corresponding processing flow is executed, so that the physical resources of the cloud platform are scheduled to be used for the virtual machine platform through the container platform k8s. By the method, the unified scheduling of physical resources of the cloud platform can be realized, the deep coupling of the virtual machine platform and the container platform k8s is not needed, and the method is suitable for simultaneous deployment of different virtual machine platforms and container platforms k8s.

Description

Method, device and equipment for resource scheduling
Technical Field
The application relates to the technical field of cloud platforms, in particular to a technology for resource scheduling.
Background
With the development of cloud platform virtualization technology, cloud-native represented by Virtual Machines (VMs) and containers has become two major directions of cloud platform virtualization technology. Compared with a virtual machine with hardware level virtualization, the container is operating system level virtualization, has lighter-weight second-level startup and performance closer to the original performance, and therefore more applications can be more conveniently deployed under the same resources, but the aspects of resource isolation and safety are inferior to those of the virtual machine.
For a scene needing efficient and convenient application deployment, the cloud native platform based on the container is more suitable, but the cloud native platform based on the virtual machine is suitable for a scene needing high-efficiency and convenient application deployment, or a scene needing to keep an old application system based on the virtual machine is suitable for the cloud platform based on the virtual machine. Therefore, there are cases where both are required at the same time in practical application scenarios.
When a virtual machine and a container are used in the same cloud platform, that is, when the virtual machine platform and the container platform are used in the same physical resource, scheduling of the physical resource of the cloud platform is very important. In the prior art, a virtual machine platform and a container platform in the same cloud platform are deeply coupled, for example, a Tanzu scheme of a borui (VMware) company deeply integrates a container platform k8s into a virtual machine platform VMware sphere thereof, and cannot be connected with other virtual machine platforms. However, as in the kubevir scheme of Red Hat (Red Hat) company, the virtual machine is operated in a container mode, and besides the fact that other virtual machine platforms cannot be connected, the problems of resource isolation and safety which cannot be solved by the container are introduced.
Disclosure of Invention
The application aims to provide a technical scheme for resource scheduling, so as to at least partially solve the technical problem that a virtual machine platform and a container platform in the same cloud platform in the prior art are deeply coupled.
According to an aspect of the present application, there is provided a method for resource scheduling, which is applied to a cloud platform, wherein a virtual machine platform and a container platform k8s are deployed in the cloud platform at the same time, and the method includes:
creating a CRD resource type in the container platform k8s, and deploying a Controller of the CRD resource type;
based on the CRD resource type, creating a custom resource object in the container platform k8s and editing custom field information therein, or modifying custom field information in the existing custom resource object in the container platform k8s, wherein the custom field comprises an expected state attribute and a virtual machine attribute;
based on the fetch mechanism of the container platform k8s, when the Controller monitors that the custom resource object changes, a corresponding processing flow is executed according to the information of the expected state attribute in the custom resource object, so that the physical resources of the cloud platform are scheduled to be used for the virtual machine platform through the container platform k8s.
Optionally, the executing, according to the information about the expected state attribute in the custom resource object, a corresponding processing procedure includes:
when the information of the desired state attribute is the creation state, then,
creating an empty Pod in the container platform k8s according to the information of the virtual machine attribute in the user-defined resource object, and distributing physical resources for the Pod by combining the use condition of the physical resources of the cloud platform;
and calling a first interface of the virtual machine platform to create a virtual machine in the virtual machine platform based on the physical resources.
Optionally, the executing, according to the information about the expected state attribute in the custom resource object, a corresponding processing procedure includes:
when the information of the desired state attribute is the startup state, then,
creating an empty Pod in the container platform k8s according to the information of the virtual machine attribute in the user-defined resource object, and distributing physical resources for the Pod by combining the use condition of the physical resources of the cloud platform;
and calling a second interface of the virtual machine platform to start a corresponding virtual machine based on the physical resources in the virtual machine platform.
Optionally, the executing, according to the information about the expected state attribute in the custom resource object, a corresponding processing procedure includes:
when the information of the desired state attribute is an off state, then,
calling a third interface of the virtual machine platform according to the virtual machine attribute information in the user-defined resource object so as to close the corresponding virtual machine in the virtual machine platform;
and deleting the corresponding Pod in the container platform k8s so as to release the physical resources occupied by the Pod.
Optionally, the executing, according to the information about the expected state attribute in the custom resource object, a corresponding processing procedure includes:
when the information of the desired state attribute is a restart state, then,
and calling a fourth interface of the virtual machine platform according to the virtual machine attribute information in the user-defined resource object so as to restart the corresponding virtual machine in the virtual machine platform.
Optionally, the executing, according to the information about the expected state attribute in the custom resource object, a corresponding processing procedure includes:
when the information of the desired state attribute is a deleted state, then,
calling a fifth interface of the virtual machine platform according to the virtual machine attribute information in the user-defined resource object so as to delete the corresponding virtual machine in the virtual machine platform;
and deleting the corresponding Pod in the container platform k8s so as to release the physical resources occupied by the Pod and delete the custom resource object.
Optionally, the method for resource scheduling further includes:
and recording an execution result into the custom resource object.
Optionally, the method for resource scheduling further includes:
starting a preset timing task to periodically poll the current state of the virtual machine platform and the information of the expected state attribute in the custom resource object of the container platform k8s, and comparing the current state of the virtual machine with the expected state attribute;
and when the current state of the virtual machine is inconsistent with the information of the expected state attribute in the self-defined resource object corresponding to the virtual machine, updating the information of the expected state attribute in the self-defined resource object to be the current state of the virtual machine.
According to another aspect of the present application, there is provided an apparatus for resource scheduling, deployed in a cloud platform, where a virtual machine platform and a container platform k8s are deployed in the cloud platform at the same time, the apparatus including:
a first module, configured to create a CRD resource type in the container platform k8s, and deploy a Controller of the CRD resource type;
a second module, configured to create a custom resource object in the container platform k8s and edit custom field information therein based on the CRD resource type, or modify custom field information in an existing custom resource object in the container platform k8s, where the custom field includes an expected state attribute and a virtual machine attribute;
and the third module is used for executing a corresponding processing flow according to the information of the expected state attribute in the user-defined resource object when the Controller monitors that the user-defined resource object changes based on the watch mechanism of the container platform k8s, so as to schedule the physical resource of the cloud platform for the virtual machine platform through the container platform k8s.
Optionally, wherein the third module is further configured to:
and recording an execution result into the custom resource object.
Optionally, the apparatus for resource scheduling further includes:
a fourth module, configured to start a preset timing task, so as to periodically poll information about a current state of a virtual machine of the virtual machine platform and an expected state attribute in a custom resource object of the container platform k8s, and compare the information;
and a fifth module, configured to update the information of the expected state attribute in the custom resource object to the current state of the virtual machine when the current state of the virtual machine is inconsistent with the information of the expected state attribute in the custom resource object corresponding to the virtual machine.
Compared with the prior art, the method, the device and the equipment for resource scheduling are applied to a cloud platform, wherein a virtual machine platform and a container platform k8s are deployed in the cloud platform at the same time. The method comprises the following steps: creating a CRD resource type in the container platform k8s, and deploying a Controller of the CRD resource type; based on the CRD resource type, creating a custom resource object in the container platform k8s and editing custom field information therein, or modifying the custom field information in the existing custom resource object in the container platform k8s, wherein the custom field comprises an expected state attribute and a virtual machine attribute; based on the fetch mechanism of the container platform k8s, when the Controller monitors that the custom resource object changes, a corresponding processing flow is executed according to the information of the expected state attribute in the custom resource object, so that the physical resources of the cloud platform are scheduled to be used for the virtual machine platform through the container platform k8s. Optionally, the execution result is also recorded into the custom resource object. Optionally, a preset timing task is also started to periodically poll the current state of the virtual machine platform and the information of the expected state attribute in the custom resource object of the container platform k8s, and compare the current state of the virtual machine with the information of the expected state attribute; and when the current state of the virtual machine is inconsistent with the information of the expected state attribute in the self-defined resource object corresponding to the virtual machine, updating the information of the expected state attribute in the self-defined resource object to be the current state of the virtual machine.
The technical effect that the technical scheme for resource scheduling can bring is that:
by the method, the unified scheduling of the physical resources of the cloud platform for deploying the virtual machine platform and the container platform k8s simultaneously can be realized in a light weight loose coupling mode, the virtual machine platform and the container platform k8s are not required to be deeply coupled, the normal operation of the two platforms is not influenced mutually, and the method is suitable for the simultaneous deployment of different virtual machine platforms and container platforms k8s. Optionally, the resource scheduling condition for the virtual machine platform may also be recorded in the custom resource object of the container platform k8s, so as to facilitate subsequent resource scheduling. Optionally, the state of the virtual machine platform is periodically polled by the timing task and relevant measures are taken to schedule the physical resources in time, so as to ensure effective use of the physical resources.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 illustrates a flow diagram of a method for resource scheduling in accordance with an aspect of the subject application;
FIG. 2 illustrates an apparatus diagram for resource scheduling in accordance with another aspect of the subject application;
the same or similar reference numbers in the drawings identify the same or similar elements.
Detailed Description
The present application is described in further detail below with reference to the attached figures.
In a typical configuration of the embodiments of the present application, the execution main body of the method, each trusted party of the system, and/or each module of the apparatus may include one or more processors (CPUs), input/output interfaces, network interfaces, and memories.
The memory may include forms of volatile memory in a computer readable medium, random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory computer readable media (transient media), such as modulated data signals and carrier waves.
In order to further explain the technical means and effects adopted by the present application, the following description clearly and completely describes the technical solutions of the present application with reference to the accompanying drawings and various embodiments.
Fig. 1 shows a flowchart of a method for resource scheduling according to an aspect of the present application, the method is applied to a cloud platform, wherein a virtual machine platform and a container platform k8s are deployed in the cloud platform at the same time, and the method of an embodiment includes:
s101, creating a CRD resource type in the container platform k8S, and deploying a Controller of the CRD resource type;
s102, based on the CRD resource type, creating a custom resource object in the container platform k8S and editing custom field information in the custom resource object, or modifying the custom field information in the existing custom resource object in the container platform k8S, wherein the custom field comprises an expected state attribute and a virtual machine attribute;
and S103, based on the watch mechanism of the container platform k8S, when the Controller monitors that the custom resource object changes, executing a corresponding processing flow according to the information of the expected state attribute in the custom resource object, so as to schedule the physical resources of the cloud platform for the virtual machine platform through the container platform k8S.
The method embodiment of the application is implemented in a cloud platform 100, the cloud platform 100 is provided with a plurality of physical machine nodes, a virtual machine platform and a container platform k8s are independently deployed, and a virtual machine and a container are simultaneously operated. The physical machine comprises but is not limited to a personal computer, a notebook computer, an industrial computer, a network host, a single network server and a plurality of network server clusters; the Cloud platform is composed of a large number of physical machine nodes based on Cloud Computing (Cloud Computing), wherein Cloud Computing is one of distributed Computing and is a virtual super computer composed of a group of loosely coupled physical machine nodes.
The physical machines and/or clouds are merely examples, and other existing or future devices and/or resource sharing platforms, as applicable, are also intended to be included within the scope of the present application and are hereby incorporated by reference.
In this embodiment, in step S101, a CRD resource type is created in the container platform k8S of the cloud platform 100, and a Controller of the CRD resource type is deployed.
The k8s (short for Kubernetes) is a container cluster management system which is most widely used at present, is used for managing containerization application on a plurality of physical machine nodes in a cloud platform, and is a mainstream choice of cloud in current enterprise business. The CRD (Custom Resource Definition) is a Resource of k8s, and allows a user to define a new Resource type, and each Resource type in k8s needs to deploy a corresponding Controller (Controller), so if the user defines the CRD Resource type, a Controller needs to be deployed in k8s to correspond to the defined CRD Resource type, and implement corresponding logic.
Therefore, a developer may directly create a CRD resource type in the container platform k8s of the cloud platform, or define a CRD resource type through an upstream application and deploy the CRD resource type into the container platform k8s of the cloud platform, and deploy a Controller of the CRD resource type in the container platform k8s of the cloud platform.
Continuing in this embodiment, in step S102, based on the CRD resource type, creating a custom resource object in the container platform k8S and editing custom field information therein, or modifying custom field information in an existing custom resource object in the container platform k8S, where the custom field includes an expected state attribute and a virtual machine attribute.
By adopting the CRD resource type created in step S101, a developer may create a custom resource object of the CRD resource type in the container platform k8S of the cloud platform directly or through an upstream application, or modify an existing custom resource object in the container platform k8S. The custom resource object uniquely corresponds to a virtual machine on the virtual machine platform, for example, a mapping relationship may be established between a unique name or identification number (ID) of the custom resource object and a unique identification number of a virtual machine on the virtual machine platform.
The information of the relevant custom field of the custom resource object can be edited, for example, the relevant information of the virtual machine includes: the name of the virtual machine, the abstract (or brief description), the required physical resources (such as the amount of CPU, the memory size), the image file used, the password, etc. are written into the custom fields related to the attributes of the virtual machine, and the information related to the operation of the virtual machine, such as: creating, starting, closing, restarting, deleting and the like, only the information of the custom field corresponding to the expected state attribute needs to be modified.
In this embodiment, in step S103, based on the watch mechanism of the container platform k8S, when the Controller monitors that the custom resource object changes, according to the information of the expected state attribute in the custom resource object, a corresponding processing procedure is executed, so as to schedule the physical resource of the cloud platform for the virtual machine platform through the container platform k8S.
According to the watch mechanism of the container platform k8s, the Controller corresponding to the CRD resource type monitors the user-defined resource object in real time after the user-defined resource object is created. When the Controller monitors that the custom resource object changes (for example, when a developer modifies the information of the expected state attribute of the custom resource object directly or through an upstream application, or modifies the information of the expected state attribute of the custom resource object when the state of a corresponding virtual machine in the virtual machine platform is not consistent with the information of the expected state attribute of the custom resource object through regular polling of a timed task), a corresponding processing flow is executed according to the changed information of the expected state attribute in the custom resource object, so that the physical resource of the cloud platform is scheduled to be used for the virtual machine platform through the container platform k8s.
In an optional embodiment, when the information of the expected state attribute in the custom resource object is the creation state, creating an empty Pod in a container platform k8s according to the information of the virtual machine attribute in the custom resource object, and allocating a physical resource on a certain physical machine node to the Pod in combination with the use condition of the physical resource of each physical machine node of the cloud platform; and calling a first interface of the virtual machine platform to create a virtual machine in the virtual machine platform by adopting the information in the virtual machine attribute based on the physical resource.
For example, if the number of CPUs is set to be 4 and the memory is set to be 2GB in the virtual machine attribute, the number of CPUs allocated to a certain physical machine node for the Pod is 4 and the memory is set to be 2GB. And creating a virtual machine on the physical node according to the name, the brief description, the used mirror image, the password and other information in the virtual machine attribute, and using the allocated physical resources when the virtual machine is started.
The empty pod is used for occupying physical resources on a certain physical machine node, but the empty pod does not use the physical resources, but creates a virtual machine corresponding to the self-defined resource object in the virtual machine platform by calling a first interface of the virtual machine platform, and uses the physical resources after the virtual machine is started. Because the physical resources of the cloud platform are uniformly scheduled through the container platform k8s, the scheduling of physical machine nodes without heavy tasks can be ensured, and the balance of virtual machines and containers running on each physical machine node of the cloud platform is ensured.
In an optional embodiment, when the information of the expected state attribute is the starting state, an empty Pod is created in the container platform k8s according to the information of the virtual machine attribute in the custom resource object, and physical resources on a certain physical machine node are allocated to the Pod in combination with the use condition of the physical resources of each physical machine node of the cloud platform; and calling a second interface of the virtual machine platform to start the corresponding virtual machine in the virtual machine platform based on the physical resource.
When monitoring that the information of the expected state in the user-defined resource object corresponding to one virtual machine is the starting state, according to the information of the virtual machine attribute in the user-defined resource object, on one hand, an empty Pod is created in a container platform k8s, and physical resources on a certain physical machine node are allocated to the Pod in combination with the use condition of the physical resources of each physical machine node of the cloud platform, and on the other hand, the corresponding virtual machine in the virtual machine platform is determined; and then, by calling a second interface of the virtual machine platform, starting a corresponding virtual machine in the virtual machine platform and using the physical resource. Wherein the virtual machine already exists in the virtual machine platform and is in a closed state.
If the virtual machine platform also sets the super-matching parameter, the parameter is obtained from the virtual machine platform through the first interface or the second interface, and the physical resource actually allocated to the Pod is determined through resource configuration conversion by combining the information obtained from the virtual machine attribute. For example, if the number of CPUs set in the virtual machine attribute is 4 and the memory is 2GB, and the super-allocation rate obtained from the virtual machine platform is 2, then actually 2 CPUs are allocated to a certain physical machine for the Pod, and the memory is 2GB.
In an optional embodiment, when the information about the expected state attribute is in a closed state, according to the information about the virtual machine attribute in the user-defined resource object, a third interface of the virtual machine platform is called to close a corresponding virtual machine in the virtual machine platform; and deleting the corresponding Pod in the container platform k8s so as to release the physical resources occupied by the Pod.
When the information of the expected state in the user-defined resource object corresponding to one virtual machine is monitored to be the closing state, the corresponding virtual machine in the virtual machine platform is determined according to the information of the virtual machine attribute in the user-defined resource object, and then the virtual machine is closed in the virtual machine platform by calling a third interface of the virtual machine platform. Because the closed virtual machine does not need to use the physical resources for the moment, in order to improve the use efficiency of the physical resources of the cloud platform, for the closed virtual machine, the empty Pod corresponding to the virtual machine can be deleted in the container platform k8s again, so as to release the physical resources occupied by the Pod. Wherein the virtual machine is already present in the virtual machine platform and is in a running state.
In an optional embodiment, when the information about the desired state attribute is a restart state, a fourth interface of the virtual machine platform is called according to the information about the virtual machine attribute in the custom resource object, so as to restart the corresponding virtual machine in the virtual machine platform.
When the information of the expected state in the user-defined resource object corresponding to one virtual machine is monitored to be the restarting state, the corresponding virtual machine in the virtual machine platform is determined according to the information of the virtual machine attribute in the user-defined resource object, and then the virtual machine is restarted in the virtual machine platform by calling the fourth interface of the virtual machine platform. Wherein the virtual machine is already present in the virtual machine platform and is in a running state.
In an optional embodiment, when the information about the expected state attribute is a deletion state, according to the information about the virtual machine attribute in the user-defined resource object, a fifth interface of the virtual machine platform is called to delete the corresponding virtual machine in the virtual machine platform; and deleting the corresponding Pod in the container platform k8s so as to release the physical resources occupied by the Pod and delete the custom resource object.
When the information of the expected state in the user-defined resource object corresponding to one virtual machine is monitored to be a deletion state, the corresponding virtual machine in the virtual machine platform is determined according to the information of the virtual machine attribute in the user-defined resource object, and then the virtual machine is directly deleted in the virtual machine platform by calling a fifth interface of the virtual machine platform. Because the deleted virtual machine does not need to use physical resources, in order to improve the use efficiency of the physical resources of the cloud platform, for the deleted virtual machine, the empty Pod corresponding to the virtual machine can be deleted again in the container platform k8s, so as to release the physical resources occupied by the Pod. Because one custom resource object in the container platform k8s only corresponds to a virtual machine in a virtual machine platform, when a virtual machine in the virtual machine platform is deleted, the corresponding custom resource object should also be deleted in the container platform k8s, so as to better manage the custom resource object. The virtual machine already exists in the virtual machine platform, and may be a running state.
In the above embodiments or optional embodiments, the type of virtual machine platform deployed in the cloud platform 100 is not limited. A CRD resource type corresponding to the virtual machine platform type is created in the container platform k8s according to the virtual machine platform type in the cloud platform 100, and a Controller of the CRD resource type is deployed, wherein a related process and a called interface in the Controller are designed according to the virtual machine platform type.
Optionally, the method in the above embodiment and/or optional embodiments further includes:
s104 (not shown) records the execution result into the custom resource object.
And recording the related execution result into the related custom field of the custom resource object, so that a developer can clearly know the related result executed after the last operation when the developer edits the custom resource object directly or through an upstream application, and the phenomenon that the current operation conflicts with the last operation to influence the stable operation of the virtual machine platform is avoided. The custom fields can be defined in the custom resource object, for example, the condition.type field records an expected state, the condition.status field records flow execution success/failure, and the condition.replay field records flow execution failure information/response information returned successfully, and the fields can be defined to record information such as execution start time, execution completion time, and the like, and can be expanded according to the requirements of the actual application scene. For example, the last time is a creation operation, if the execution result is failure, the condition.type record is creation, and if the condition.status record is failure, the operation only allows the custom resource object to be deleted or created additionally, if the execution result is success, the condition.type record is creation, the condition.status record is success, and the condition.replay record is in virtual machine operation, the operation may be shutdown, restart, deletion, etc.; the last time is a closing operation, if the execution result is failure, the condition.type record is closed, the condition.status record is failure, the condition.replay record is in the virtual machine running, the operation cannot be started, if the execution result is success, the condition.type record is closed, the condition.status record is success, and the condition.replay record is in the virtual machine closing, the operation can be started, deleted and the like.
Optionally, the method in the above embodiment and/or optional embodiments further includes:
s105 (not shown) starting a preset timing task to periodically poll the current state of the virtual machine platform and the information of the expected state attribute in the custom resource object of the container platform k8S and compare the current state of the virtual machine with the expected state attribute;
s106 (not shown) updates the information of the expected state attribute in the custom resource object to the current state of the virtual machine when the current state of the virtual machine is inconsistent with the information of the expected state attribute in the custom resource object corresponding to the virtual machine.
After the virtual machine in the virtual machine platform is scheduled according to the container platform k8s, in the operation process of the virtual machine platform, a state change may occur due to a fault, so that the current state of the virtual machine may be inconsistent with the expected state recorded in the corresponding custom resource object in the container platform k8s, for example, by setting the expected state field of the custom resource object in the container platform k8s to be started, the corresponding virtual machine in the virtual machine platform may be in an operation state after being started, and if the virtual machine is stopped due to a fault, the physical resource allocated to the virtual machine is still occupied, and thus the virtual machine cannot be reused and allocated. The physical resources occupied by the related Pod in the container platform k8s are inconsistent with the physical resources actually used by the virtual machine platform, which results in low use efficiency of the physical resources.
The method comprises the steps that a preset timing task can be started in a cloud platform to periodically poll the current state of each virtual machine of a virtual machine platform and the information of the expected state attribute in a custom resource object of a container platform k8s, and the current state and the expected state attribute are correspondingly compared; when the current state of a virtual machine is inconsistent with the information of the expected state attribute in the self-defined resource object corresponding to the virtual machine, which indicates that the state of the virtual machine is changed due to reasons, the information of the expected state attribute in the self-defined resource object corresponding to the virtual machine can be updated to the current state of the virtual machine. For example, if the current state of the virtual machine is off and the information of the expected state attribute in the corresponding custom resource object is on, the information of the expected state attribute is updated to off. And when the Controller monitors that the user-defined voluntary object is changed through a watch mechanism of the container platform, executing a flow corresponding to a closing state, and tuning a corresponding empty Pod. That is, in the container platform k8s, the empty Pod corresponding to the virtual machine is deleted, so as to release the physical resource occupied by the Pod.
Fig. 2 is a schematic diagram of an apparatus for resource scheduling deployed in a cloud platform, where the cloud platform deploys a virtual machine platform and a container platform k8s simultaneously, according to another aspect of the present application, and the apparatus of an embodiment includes:
a first module 201, configured to create a CRD resource type in the container platform k8s, and deploy a Controller of the CRD resource type;
a second module 202, configured to create a custom resource object in the container platform k8s and edit custom field information therein based on the CRD resource type, or modify custom field information in an existing custom resource object in the container platform k8s, where the custom field includes an expected state attribute and a virtual machine attribute;
a third module 203, configured to execute a corresponding processing procedure according to the information of the expected state attribute in the custom resource object when the Controller monitors that the custom resource object changes based on the watch mechanism of the container platform k8s, so as to schedule, through the container platform k8s, the physical resource of the cloud platform for the virtual machine platform.
The apparatus is deployed in the cloud platform 100 implementing the above method embodiments and/or optional embodiments, and the apparatus may be a software apparatus or a software and hardware combination apparatus.
In this embodiment, the first module 201 of the apparatus creates a CRD resource type in the container platform k8s of the cloud platform 100, and deploys a Controller of the CRD resource type.
Continuing in this embodiment, the second module 202 of the apparatus uses the CRD resource type created in the first module 201 to create a custom resource object of the CRD resource type in the container platform k8s of the cloud platform 100, or modify the existing custom resource object in the container platform k8s. The custom resource object uniquely corresponds to a virtual machine on the virtual machine platform, for example, a mapping relationship may be established between a unique name or identification number (ID) of the custom resource object and a unique identification number of a virtual machine on the virtual machine platform. The information of the relevant custom field of the custom resource object can be edited, for example, the relevant information of the virtual machine includes: the name of the virtual machine, the abstract (or brief description), the required physical resources (such as the amount of CPU, the memory size), the image file used, the password, etc. are written into the custom fields related to the attributes of the virtual machine, and the information related to the operation of the virtual machine, such as: creating, starting, closing, restarting, deleting and the like, only the information of the custom field corresponding to the expected state attribute needs to be modified.
In this embodiment, based on the watch mechanism of the container platform k8s, when the Controller corresponding to the CRD resource type monitors that the custom resource object changes, the third module 203 of the apparatus executes a corresponding processing procedure according to the information of the expected state attribute in the custom resource object, so as to schedule the physical resource of the cloud platform for the virtual machine platform through the container platform k8s in the cloud platform 100.
When monitoring that the information of the expected state attribute in a changed custom resource object is the creation state, creating an empty Pod in a container platform k8s according to the information of the virtual machine attribute in the custom resource object, and allocating physical resources on a certain physical machine node for the Pod by combining the physical resource use condition of each physical machine node of the cloud platform 100; and then calling a first interface of the virtual machine platform to create the virtual machine in the virtual machine platform by adopting the information in the virtual machine attribute based on the physical resource. When monitoring that the information of the expected state attribute in a changed custom resource object is a starting state, establishing an empty Pod in a container platform k8s according to the information of the virtual machine attribute in the custom resource object, allocating physical resources on a certain physical machine node for the Pod by combining the physical resource use condition of each physical machine node of a cloud platform, and determining a corresponding virtual machine in the virtual machine platform; and then, calling a second interface of the virtual machine platform, and using the physical resource in a corresponding virtual machine in the virtual machine platform, wherein the virtual machine exists in the virtual machine platform and is in a closed state. When the fact that the information of the expected state attribute in the user-defined resource object which is changed is in the closed state is monitored, the corresponding virtual machine in the virtual machine platform is determined according to the information of the virtual machine attribute in the user-defined resource object, then the virtual machine is closed in the virtual machine platform by calling a third interface of the virtual machine platform, and the empty Pod corresponding to the virtual machine is deleted in a container platform k8s so as to release the physical resource occupied by the Pod, wherein the virtual machine exists in the virtual machine platform and is in the running state. When the fact that the information of the expected state attribute in the user-defined resource object which changes is the restarting state is monitored, the corresponding virtual machine in the virtual machine platform is determined according to the information of the virtual machine attribute in the user-defined resource object, and then the virtual machine is restarted in the virtual machine platform by calling a fourth interface of the virtual machine platform, wherein the virtual machine exists in the virtual machine platform and is in the running state. When the fact that the information of the expected state attribute in the user-defined resource object which changes is detected to be a deletion state is monitored, a corresponding virtual machine in the virtual machine platform is determined according to the information of the virtual machine attribute in the user-defined resource object, then the virtual machine is directly deleted in the virtual machine platform by calling a fifth interface of the virtual machine platform, an empty Pod corresponding to the virtual machine can be deleted in a container platform k8s so as to release physical resources occupied by the Pod, and then the corresponding user-defined resource object is deleted in the container platform k8s so as to better manage the user-defined resource object. The virtual machine already exists in the virtual machine platform, and may be a running state.
In the above embodiment, the virtual machine platform type deployed in the cloud platform 100 is not limited, and a CRD resource type corresponding to the virtual machine platform type is created in the container platform k8s according to the virtual machine platform type in the cloud platform 100, and a Controller of the CRD resource type is deployed. Wherein, the related flow and the called interface in the Controller should be designed according to the virtual machine platform type.
Optionally, wherein the third module 103 is further configured to: and recording an execution result into the custom resource object.
The third module 103 of the apparatus may further record the relevant execution result into the relevant custom field of the custom resource object, so that when the custom resource object is edited, the relevant result executed after the last operation is known clearly, and the operation of this time is prevented from colliding with the last operation, which affects the stable operation of the virtual machine platform.
Optionally, the apparatus further comprises:
a fourth module 204 (not shown) configured to start a preset timing task, so as to periodically poll information of the current state of the virtual machine platform and the expected state attribute in the custom resource object of the container platform k8s, and perform comparison;
a fifth module 205 (not shown) is configured to update the information of the desired state attribute in the custom resource object to the current state of the virtual machine when the current state of the virtual machine is inconsistent with the information of the desired state attribute in the custom resource object corresponding to the virtual machine.
After the virtual machine in the virtual machine platform is scheduled according to the container platform k8s, state changes may occur in the virtual machine platform operation process due to reasons, so that the current state of the virtual machine may be inconsistent with the expected state recorded in the corresponding custom resource object in the container platform k8s, and the physical resource occupied by the relevant Pod in the container platform k8s may be inconsistent with the physical resource actually used by the virtual machine platform, resulting in low use efficiency of the physical resource.
A preset timing task can be started through a fourth module 204 of the device to periodically poll the current state of each virtual machine of the virtual machine platform and the information of the expected state attribute in the custom resource object of the container platform k8s, and the information is correspondingly compared; according to the comparison result, when the current state of a virtual machine is inconsistent with the information of the expected state attribute in the corresponding custom resource object, which indicates that the virtual machine has changed its state due to a cause, the fifth module 205 of the apparatus may update the information of the expected state attribute in the corresponding custom resource object to the current state of the virtual machine.
In an alternative embodiment of the present application, there is also provided a computer readable medium having stored thereon computer readable instructions executable by a processor to implement the foregoing method embodiments or alternative embodiments.
It is noted that the method embodiments or alternative embodiments in this application may be implemented in software and/or a combination of software and hardware. The software programs referred to in this application may be executed by a processor to implement the steps or functions of the embodiments described above. Also, the software programs (including associated data structures) of the present application may be stored in a computer-readable recording medium.
In addition, some of the present application may be implemented as a computer program product, such as computer program instructions, which when executed by a computer, may invoke or provide methods and/or techniques in accordance with the present application through the operation of the computer. Program instructions which invoke the methods of the present application may be stored on a fixed or removable recording medium and/or transmitted via a data stream on a broadcast or other signal-bearing medium and/or stored within a working memory of a computer device operating in accordance with the program instructions.
In another optional embodiment of the present application, there is further provided an apparatus for resource scheduling, including: a memory storing computer program instructions and a processor for executing the program instructions, wherein the computer program instructions, when executed by the processor, trigger the apparatus to perform operations as described in the foregoing method embodiments and/or alternative embodiments, and/or technical solutions.
It will be evident to those skilled in the art that the application is not limited to the details of the foregoing illustrative embodiments, and that the present application may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the apparatus claims may also be implemented by one unit or means in software and/or hardware. The terms first, second, etc. are used to denote names, but not to denote any particular order.

Claims (13)

1. A method for resource scheduling is applied to a cloud platform, and is characterized in that a virtual machine platform and a container platform k8s are deployed in the cloud platform at the same time, and the method comprises the following steps:
creating a CRD resource type in the container platform k8s, and deploying a Controller of the CRD resource type;
based on the CRD resource type, creating a custom resource object in the container platform k8s and editing custom field information therein, or modifying the custom field information in the existing custom resource object in the container platform k8s, wherein the custom field comprises an expected state attribute and a virtual machine attribute;
based on the fetch mechanism of the container platform k8s, when the Controller monitors that the custom resource object changes, a corresponding processing flow is executed according to the information of the expected state attribute in the custom resource object, so that the physical resources of the cloud platform are scheduled to be used for the virtual machine platform through the container platform k8s.
2. The method according to claim 1, wherein the executing the corresponding processing flow according to the information of the desired state attribute in the custom resource object comprises:
when the information of the desired state attribute is the creation state, then,
creating an empty Pod in the container platform k8s according to the information of the virtual machine attribute in the user-defined resource object, and distributing physical resources for the Pod by combining the use condition of the physical resources of the cloud platform;
and calling a first interface of the virtual machine platform to create a virtual machine based on the physical resources in the virtual machine platform.
3. The method according to claim 1, wherein the executing the corresponding processing flow according to the information of the desired state attribute in the custom resource object comprises:
when the information of the desired state attribute is the startup state, then,
creating an empty Pod in the container platform k8s according to the information of the virtual machine attribute in the user-defined resource object, and distributing physical resources for the Pod by combining the use condition of the physical resources of the cloud platform;
and calling a second interface of the virtual machine platform to start a corresponding virtual machine in the virtual machine platform based on the physical resources.
4. The method according to claim 1, wherein the executing the corresponding processing flow according to the information of the desired state attribute in the custom resource object comprises:
when the information of the desired state attribute is an off state, then,
calling a third interface of the virtual machine platform according to the virtual machine attribute information in the user-defined resource object so as to close the corresponding virtual machine in the virtual machine platform;
and deleting the corresponding Pod in the container platform k8s so as to release the physical resource occupied by the Pod.
5. The method according to claim 1, wherein said executing the corresponding processing flow according to the information of the desired state attribute in the custom resource object comprises:
when the information of the desired state attribute is a restart state, then,
and calling a fourth interface of the virtual machine platform according to the virtual machine attribute information in the user-defined resource object so as to restart the corresponding virtual machine in the virtual machine platform.
6. The method according to claim 1, wherein the executing the corresponding processing flow according to the information of the desired state attribute in the custom resource object comprises:
when the information of the desired state attribute is a deleted state, then,
calling a fifth interface of the virtual machine platform according to the virtual machine attribute information in the user-defined resource object so as to delete the corresponding virtual machine in the virtual machine platform;
and deleting the corresponding Pod in the container platform k8s so as to release the physical resources occupied by the Pod and delete the custom resource object.
7. The method of claim 1, further comprising:
and recording an execution result into the custom resource object.
8. The method of claim 1, further comprising:
starting a preset timing task to periodically poll the current state of the virtual machine platform and the information of the expected state attribute in the custom resource object of the container platform k8s, and comparing the current state of the virtual machine with the expected state attribute;
and when the current state of the virtual machine is inconsistent with the information of the expected state attribute in the self-defined resource object corresponding to the virtual machine, updating the information of the expected state attribute in the self-defined resource object to be the current state of the virtual machine.
9. An apparatus for resource scheduling, deployed in a cloud platform, wherein a virtual machine platform and a container platform k8s are deployed in the cloud platform at the same time, the apparatus comprising:
a first module, configured to create a CRD resource type in the container platform k8s, and deploy a Controller of the CRD resource type;
a second module, configured to create a custom resource object in the container platform k8s and edit custom field information therein based on the CRD resource type, or modify custom field information in an existing custom resource object in the container platform k8s, where the custom field includes an expected state attribute and a virtual machine attribute;
and a third module, configured to execute, based on a watch mechanism of the container platform k8s, a corresponding processing procedure according to information of an expected state attribute in the custom resource object when the Controller monitors that the custom resource object changes, so as to schedule, through the container platform k8s, the physical resource of the cloud platform for the virtual machine platform.
10. The apparatus of claim 9, wherein the third module is further configured to:
and recording an execution result into the custom resource object.
11. The apparatus of claim 9, further comprising:
a fourth module, configured to start a preset timing task, so as to periodically poll information about a current state of a virtual machine of the virtual machine platform and an expected state attribute in a custom resource object of the container platform k8s, and compare the information;
and a fifth module, configured to update the information of the expected state attribute in the custom resource object to the current state of the virtual machine when the current state of the virtual machine is inconsistent with the information of the expected state attribute in the custom resource object corresponding to the virtual machine.
12. A computer-readable medium comprising, in combination,
stored thereon computer readable instructions to be executed by a processor to implement the method of any one of claims 1 to 8.
13. An apparatus for resource scheduling, the apparatus comprising:
one or more processors; and
a memory having computer-readable instructions stored thereon that, when executed, cause the processor to perform the operations of the method of any of claims 1 to 8.
CN202211329279.9A 2022-10-27 2022-10-27 Method, device and equipment for resource scheduling Pending CN115617459A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211329279.9A CN115617459A (en) 2022-10-27 2022-10-27 Method, device and equipment for resource scheduling

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211329279.9A CN115617459A (en) 2022-10-27 2022-10-27 Method, device and equipment for resource scheduling

Publications (1)

Publication Number Publication Date
CN115617459A true CN115617459A (en) 2023-01-17

Family

ID=84876194

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211329279.9A Pending CN115617459A (en) 2022-10-27 2022-10-27 Method, device and equipment for resource scheduling

Country Status (1)

Country Link
CN (1) CN115617459A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117112500A (en) * 2023-10-17 2023-11-24 天津市天河计算机技术有限公司 Resource management method, device, equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117112500A (en) * 2023-10-17 2023-11-24 天津市天河计算机技术有限公司 Resource management method, device, equipment and storage medium
CN117112500B (en) * 2023-10-17 2024-01-26 天津市天河计算机技术有限公司 Resource management method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN107451147B (en) Method and device for dynamically switching kafka clusters
JP5186098B2 (en) Method, system, and computer program for backing up data
US20220283846A1 (en) Pod deployment method and apparatus
CN111831396A (en) Docker software and hardware integration-based delivery method and device
US9983988B1 (en) Resuming testing after a destructive event
CN114706690B (en) Method and system for sharing GPU (graphics processing Unit) by Kubernetes container
CN115617459A (en) Method, device and equipment for resource scheduling
CN114625535A (en) Service deployment method and device for multiple Kubernetes clusters
WO2023160418A1 (en) Resource processing method and resource scheduling method
CN115080309A (en) Data backup system, method, storage medium, and electronic device
CN112564979B (en) Execution method and device of construction task, computer equipment and storage medium
CN114579364A (en) Cloud native database backup method based on hybrid cloud
CN113835625A (en) Data storage method, device, equipment and storage medium based on sub-path
CN114880150A (en) Fault isolation and field protection method and system
CN111858234A (en) Task execution method, device, equipment and medium
US7743244B2 (en) Computer system model generation with tracking of actual computer system configuration
CN110597603A (en) Scheduling method and system of distributed scheduling tasks
CN112187753B (en) Data updating method, device, equipment and readable storage medium
CN116760913B (en) Method and system for issuing k8s cluster protocol conversion platform configuration
CN116578413B (en) Signal-level simulation model clouding method based on cloud+end architecture
WO2023274166A1 (en) Kernel upgrade method and apparatus
US11675678B1 (en) Managing storage domains, service tiers, and failed service tiers
CN117435307A (en) Virtual machine migration method and device
US11663096B1 (en) Managing storage domains, service tiers and failed storage domain
CN114124703B (en) Multi-environment service configuration method, equipment and medium based on Kubernetes

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination