CN114461399A - Resource allocation method and device, storage medium and electronic device - Google Patents

Resource allocation method and device, storage medium and electronic device Download PDF

Info

Publication number
CN114461399A
CN114461399A CN202210130578.3A CN202210130578A CN114461399A CN 114461399 A CN114461399 A CN 114461399A CN 202210130578 A CN202210130578 A CN 202210130578A CN 114461399 A CN114461399 A CN 114461399A
Authority
CN
China
Prior art keywords
file
component
deployed
markup language
resource
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.)
Granted
Application number
CN202210130578.3A
Other languages
Chinese (zh)
Other versions
CN114461399B (en
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.)
Zhejiang Dahua Technology Co Ltd
Original Assignee
Zhejiang Dahua 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 Zhejiang Dahua Technology Co Ltd filed Critical Zhejiang Dahua Technology Co Ltd
Priority to CN202210130578.3A priority Critical patent/CN114461399B/en
Publication of CN114461399A publication Critical patent/CN114461399A/en
Application granted granted Critical
Publication of CN114461399B publication Critical patent/CN114461399B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • G06F8/63Image based installation; Cloning; Build to order
    • 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/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a resource allocation method and device, a storage medium and an electronic device, wherein the method comprises the following steps: acquiring a first image file of a resource package of a component to be deployed and a first file address of the first image file, and updating a value of a first field of a first markup language file in the resource package according to the first file address of the first image file to obtain a second markup language file; acquiring a configuration file of a resource package of the component to be deployed, and updating the value of a second field in a second markup language file according to the configuration file to obtain a third markup language file; the method comprises the steps of obtaining a first image file according to the value of a first field in a third markup language file, deploying the component to be deployed according to the first image file in a cloud platform, determining a first resource quota allowed to be allocated to the component to be deployed according to the value of a second field in the third markup language file, and allocating corresponding resources to the component to be deployed according to the first resource quota in the cloud platform.

Description

Resource allocation method and device, storage medium and electronic device
Technical Field
The present invention relates to the field of communications, and in particular, to a resource allocation method and apparatus, a storage medium, and an electronic apparatus.
Background
The container technology is an emerging virtualization technology and plays an important role in the field of cloud computing and container cloud. The container technology can pack programs of the components to be deployed into container images, rapid deployment and operation of the components can be achieved in different environments, and development efficiency and performance are improved.
In the deployment scheme provided by the k8s authority, a kubel and a kubel are installed, image files of components such as an apiserver, a kube-controller-manager and a coredns are imported, and then the components are installed under the guidance of the kubel, but the current business requirements cannot be realized by the native technology, when a business scenario is that a single node is deployed with k8s, and then other services are deployed on the node through k8s, not only the resource quotas of the other services need to be managed, but also the resource quotas of the components such as the apiserver and the kube-controller-manager which are built in the k8s need to be managed.
Aiming at the problems that the management of resource quotas cannot be carried out on the components deployed on the cloud platform in the related technology, and the like, an effective solution is not provided yet.
Disclosure of Invention
The embodiment of the invention provides a resource allocation method and device, a storage medium and an electronic device, and at least solves the problems that in the related art, management of resource quotas cannot be performed on components deployed on a cloud platform and the like.
According to an embodiment of the present invention, a resource allocation method is provided, including: acquiring a first image file of a resource package of a component to be deployed and a first file address of the first image file, and updating a value of a first field of a first markup language file in the resource package according to the first file address of the first image file to obtain a second markup language file, wherein the value of the first field is used for indicating the first file address of the first image file; acquiring a configuration file of a resource package of the component to be deployed, and updating a value of a second field in the second markup language file according to the configuration file to obtain a third markup language file, wherein the configuration file comprises resource quota configuration information, the resource quota configuration information is used for indicating a first resource quota allowed to be allocated to the component to be deployed, and the value of the second field in the second markup language file is used for indicating a second resource quota allowed to be allocated to the component to be deployed; the method comprises the steps of obtaining a first image file according to the value of a first field in a third markup language file, deploying the component to be deployed according to the first image file in a cloud platform, determining a first resource quota allowed to be allocated to the component to be deployed according to the value of a second field in the third markup language file, and allocating corresponding resources to the component to be deployed according to the first resource quota in the cloud platform.
In an exemplary embodiment, the obtaining a first image file of a resource package of a component to be deployed includes: determining whether the resource package has a dependency relationship with the component code of the component to be deployed; under the condition that the resource package and the component code of the component to be deployed do not have a dependency relationship, acquiring an original image file in the resource package, and taking the original image file as the first image file; and compiling the component code to obtain a code image file under the condition that the resource package has a dependency relationship with the component code of the component to be deployed, and taking the code image file as the first image file.
In an exemplary embodiment, the updating, according to the first file address of the first image file, a value of a first field of a first markup language file in the resource package to obtain a second markup language file includes: under the condition that the resource package and the component code of the component to be deployed do not have a dependency relationship, acquiring an original file address of the original image file, and updating the value of the first field of the first markup language file in the resource package to the original file address; and under the condition that the resource package and the component code of the component to be deployed have a dependency relationship, acquiring a code file address of the code image file, and updating the value of the first field of the first markup language file in the resource package into the code file address.
In an exemplary embodiment, the updating, according to the configuration file, the value of the second field in the second markup language file to obtain a third markup language file includes: generating a rendering value of the resource package according to the resource quota configuration information in the configuration file, wherein the rendering value is used for indicating that the first resource quota allocated to the component to be deployed is allowed; and updating the value of the second field in the second markup language file to the rendering value to obtain the third markup language file.
In an exemplary embodiment, after the updating, according to the configuration file, the value of the second field in the second markup language file to obtain a third markup language file, the method further includes at least one of: storing the third markup language file into a target directory of the cloud platform when the component to be deployed is a native component in the cloud platform; and under the condition that the component to be deployed is an external plug-in the cloud platform, sending the third markup language file to an interface service of the cloud platform, so that the interface service acquires the first image file according to the value of the first field in the third markup language file, and deploying the component to be deployed in the cloud platform according to the first image file.
In an exemplary embodiment, deploying the component to be deployed according to the first image file in the cloud platform includes: pulling the first image file through an application container engine, and opening a target container according to the first image file; and acquiring the binary file of the first image file in the target container, and deploying the component to be deployed in the cloud platform according to the binary file.
In an exemplary embodiment, the obtaining the configuration file of the resource package of the component to be deployed includes: saving the resource package to a target repository in the cloud platform if the first markup language file in the resource package is updated to the second markup language file; and acquiring a network address of the resource package, and acquiring a configuration file of the resource package of the component to be deployed in the target warehouse according to the network address, wherein the network address is used for indicating an address of the resource package in the target warehouse.
According to another embodiment of the present invention, there is also provided a resource allocation apparatus, including: the system comprises a first acquisition module, a second acquisition module and a first storage module, wherein the first acquisition module is used for acquiring a first image file of a resource package of a component to be deployed and a first file address of the first image file, and updating a value of a first field of a first markup language file in the resource package according to the first file address of the first image file to obtain a second markup language file, and the value of the first field is used for indicating the first file address of the first image file; a second obtaining module, configured to obtain a configuration file of a resource package of the component to be deployed, and update a value of a second field in the second markup language file according to the configuration file to obtain a third markup language file, where the configuration file includes resource quota configuration information, the resource quota configuration information is used to indicate a first resource quota allowed to be allocated to the component to be deployed, and the value of the second field in the second markup language file is used to indicate a second resource quota allowed to be allocated to the component to be deployed; the allocation module is configured to acquire the first image file according to a value of the first field in the third markup language file, deploy the component to be deployed in the cloud platform according to the first image file, determine the first resource quota allowed to be allocated to the component to be deployed according to a value of the second field in the third markup language file, and allocate corresponding resources to the component to be deployed in the cloud platform according to the first resource quota.
According to still another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned resource allocation method when running.
According to another aspect of the embodiments of the present invention, there is provided an electronic apparatus, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the method for allocating resources by using the computer program.
In the embodiment of the invention, a first image file of a resource package of a component to be deployed and a first file address of the first image file are obtained, and a value of a first field of a first markup language file in the resource package is updated according to the first file address of the first image file to obtain a second markup language file, wherein the value of the first field is used for indicating the first file address of the first image file; acquiring a configuration file of a resource package of the component to be deployed, and updating a value of a second field in the second markup language file according to the configuration file to obtain a third markup language file, wherein the configuration file comprises resource quota configuration information, the resource quota configuration information is used for indicating a first resource quota allowed to be allocated to the component to be deployed, and the value of the second field in the second markup language file is used for indicating a second resource quota allowed to be allocated to the component to be deployed; acquiring the first image file according to the value of the first field in the third markup language file, deploying the component to be deployed according to the first image file in a cloud platform, determining the first resource quota allowed to be allocated to the component to be deployed according to the value of the second field in the third markup language file, and allocating corresponding resources to the component to be deployed in the cloud platform according to the first resource quota; by adopting the technical scheme, the problems that the resource quota management cannot be performed on the components deployed on the cloud platform and the like are solved, the adaptive deployment scheme is constructed through the resource package product, the current service requirement is solved, the resource package is used as the deployment entry of the components instead of the mirror image file, the resource quota of the components can be limited, and the small-scale deployment is facilitated.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
fig. 1 is a block diagram of a hardware configuration of a computer terminal of a resource allocation method according to an embodiment of the present invention;
FIG. 2 is a flow chart of a method of allocating resources according to an embodiment of the present invention;
FIG. 3 is a container cloud installation deployment flow diagram in accordance with an alternative embodiment of the present invention;
fig. 4 is a resource quota graph of each component to be deployed in the resource allocation method according to an alternative embodiment of the present invention;
FIG. 5 is a flow chart of a method of allocating resources according to an alternative embodiment of the present invention;
fig. 6 is a block diagram of an apparatus for allocating resources according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The method provided by the embodiment of the application can be executed in a mobile terminal, a computer terminal or a similar operation device. Taking an example of the method running on a computer terminal, fig. 1 is a block diagram of a hardware structure of the computer terminal of a resource allocation method according to an embodiment of the present invention. As shown in fig. 1, the computer terminal may include one or more (only one shown in fig. 1) processors 102 (the processors 102 may include, but are not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, and in an exemplary embodiment, may also include a transmission device 106 for communication functions and an input-output device 108. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration and is not intended to limit the structure of the computer terminal. For example, a computer terminal may also include more or fewer components than shown in FIG. 1, or have a different configuration with equivalent functionality to that shown in FIG. 1 or more functionality than that shown in FIG. 1.
The memory 104 may be used to store computer programs, for example, software programs and modules of application software, such as computer programs corresponding to the resource allocation method in the embodiment of the present invention, and the processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, so as to implement the above-mentioned method. The memory 104 may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to a computer terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 106 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the computer terminal. In one example, the transmission device 106 includes a Network adapter (NIC), which can be connected to other Network devices through a base station so as to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
In this embodiment, a resource allocation method is provided, which is applied to the computer terminal described above, and fig. 2 is a flowchart of a resource allocation method according to an embodiment of the present invention, where the flowchart includes the following steps:
step S202, a first image file of a resource package of a component to be deployed and a first file address of the first image file are obtained, and a value of a first field of a first markup language file in the resource package is updated according to the first file address of the first image file, so that a second markup language file is obtained, wherein the value of the first field is used for indicating the first file address of the first image file;
step S204, obtaining a configuration file of a resource package of the component to be deployed, and updating a value of a second field in the second markup language file according to the configuration file to obtain a third markup language file, wherein the configuration file includes resource quota configuration information, the resource quota configuration information is used for indicating a first resource quota allowed to be allocated to the component to be deployed, and the value of the second field in the second markup language file is used for indicating a second resource quota allowed to be allocated to the component to be deployed;
step S206, obtaining the first image file according to the value of the first field in the third markup language file, deploying the component to be deployed in the cloud platform according to the first image file, determining the first resource quota allowed to be allocated to the component to be deployed according to the value of the second field in the third markup language file, and allocating corresponding resources to the component to be deployed in the cloud platform according to the first resource quota.
Through the steps, a first image file of a resource package of a component to be deployed and a first file address of the first image file are obtained, and the value of a first field of a first markup language file in the resource package is updated according to the first file address of the first image file, so that a second markup language file is obtained, wherein the value of the first field is used for indicating the first file address of the first image file; acquiring a configuration file of a resource package of the component to be deployed, and updating a value of a second field in the second markup language file according to the configuration file to obtain a third markup language file, wherein the configuration file comprises resource quota configuration information, the resource quota configuration information is used for indicating a first resource quota allowed to be allocated to the component to be deployed, and the value of the second field in the second markup language file is used for indicating a second resource quota allowed to be allocated to the component to be deployed; the method comprises the steps of obtaining a first image file according to the value of a first field in a third markup language file, deploying the component to be deployed in a cloud platform according to the first image file, determining a first resource quota allowed to be allocated to the component to be deployed according to the value of a second field in the third markup language file, and allocating corresponding resources to the component to be deployed in the cloud platform according to the first resource quota, so that the problems that in the related art, the management of the resource quota cannot be performed on the component deployed on the cloud platform and the like are solved, an adaptive deployment scheme is further constructed through a resource package product, the current service requirement is solved, a resource package is used as a deployment entry of the component instead of the image file, the resource quota of the component can be limited, and small-scale deployment is facilitated.
In one exemplary embodiment, the first image file is obtained by: determining whether the resource package has a dependency relationship with the component code of the component to be deployed; under the condition that the resource package and the component code of the component to be deployed do not have a dependency relationship, acquiring an original image file in the resource package, and taking the original image file as the first image file; and compiling the component code to obtain a code image file under the condition that the resource package has a dependency relationship with the component code of the component to be deployed, and taking the code image file as the first image file.
Specifically, a resource package (e.g., a chart package) of the component to be deployed is constructed, the resource package is divided into two types, namely a code-dependent resource package and a code-independent resource package, an original image file in the code-independent resource package (i.e., the resource package and the component code of the component to be deployed do not have a dependency relationship) is fixed, and a value of a first field of a first markup language file in the resource package is fixed; the image file in the resource package with code dependence (i.e. the resource package and the component code of the component to be deployed have a dependence relationship) is not fixed, and the component code of the component to be deployed needs to be compiled to obtain a code image file, and the code image file replaces the original image file in the resource package. Under the condition that a resource package of a component to be deployed is constructed, acquiring a corresponding first image file according to the type of the resource package of the component to be deployed, namely acquiring a code image file under the condition that the type of the resource package is a code dependent type, and taking the code image file as the first image file; and under the condition that the type of the resource package is a code-independent type, acquiring an original image file, and taking the original image file as a first image file.
In an exemplary embodiment, the specific method of step S202 is as follows: under the condition that the resource package and the component code of the component to be deployed do not have a dependency relationship, acquiring an original file address of the original image file, and updating the value of the first field of the first markup language file in the resource package to the original file address; and under the condition that the resource package and the component code of the component to be deployed have a dependency relationship, acquiring a code file address of the code image file, and updating the value of the first field of the first markup language file in the resource package into the code file address.
That is to say, under the condition that the resource package does not have a dependency relationship with the component code of the component to be deployed, the value of the first field of the first markup language file in the resource package is the original file address of the original image file; under the condition that the resource package and the component code of the component to be deployed have a dependency relationship, the value of the first field of the first markup language file in the resource package is the code file address of the code image file, so that under the condition that the component to be deployed is deployed, the code image file or the original image file is obtained according to the value of the first field, and the component to be deployed is deployed through the code image file or the original image file.
In an exemplary embodiment, the updating, according to the configuration file, the value of the second field in the second markup language file to obtain a third markup language file includes: generating a rendering value of the resource package according to the resource quota configuration information in the configuration file, wherein the rendering value is used for indicating that the first resource quota allocated to the component to be deployed is allowed; and updating the value of the second field in the second markup language file to the rendering value to obtain the third markup language file.
That is, a rendering value of the resource package, for example, a value in the form of map, is generated according to the configuration file, and the rendering value renders the resource package by means of the rendering function of the native resource package of the package manager helm, and updates the value of the second field in the resource package. And finally, obtaining a markup language file of each component which accords with the deployment specification of the cloud platform k8s, and using the markup language file to deploy the component to be deployed.
In an exemplary embodiment, in the case that the component to be deployed is a native component in the cloud platform, storing the third markup language file into a target directory of the cloud platform; and under the condition that the component to be deployed is an external plug-in the cloud platform, sending the third markup language file to an interface service of the cloud platform, so that the interface service acquires the first image file according to the value of the first field in the third markup language file, and deploying the component to be deployed in the cloud platform according to the first image file.
The components to be deployed are divided into: the method comprises the steps that under the condition that a component to be deployed is a native component of a cloud platform, an obtained third markup language file is stored in a target directory, so that the component to be deployed is deployed on the cloud platform as a static container group (POD), and under the condition that the component to be deployed is an external plug-in of the cloud platform, the obtained third markup language file is sent to an interface service (for example, apiserver) corresponding to the cloud platform, so that the interface service deploys the external plug-in on the cloud platform according to a first image file.
In an exemplary embodiment, deploying the component to be deployed according to the first image file in the cloud platform includes: pulling the first image file through an application container engine, and opening a target container according to the first image file; and acquiring the binary file of the first image file in the target container, and deploying the component to be deployed in the cloud platform according to the binary file.
Specifically, a resource package of a related plug-in of k8s is obtained, and guided deployment of the resource package is realized through a customized kubeeadm, and the resource package comprises keepalive, nginx, etcd high-availability cluster, apiserver, kube-scheduler, kube-controller-manager, kube-proxy, crd and roll resources, and a calico, coredns, palm, chartmum plug-in. As the entries in the deployment process are unified into the resource package, the binary files of kubecect and kubecelet are placed into the image file in advance, the image is pulled up through the component image engine docker during deployment, the binary file corresponding to the image file is obtained from the image container, and then the image container is closed. In the process, a CA related self-signed certificate is generated, and then public keys and private keys used for bidirectional communication by components such as apiserver, etcd and the like are generated according to the CA certificate.
In an exemplary embodiment, the obtaining the configuration file of the resource package of the component to be deployed includes: saving the resource package to a target repository in the cloud platform if the first markup language file in the resource package is updated to the second markup language file; and acquiring a network address of the resource package, and acquiring a configuration file of the resource package of the component to be deployed in the target warehouse according to the network address, wherein the network address is used for indicating an address of the resource package in the target warehouse.
That is to say, after the helm replay add adds a target warehouse (e.g., a chart warehouse), the helm package packs the resource package, the helm push uploads the resource package to the target warehouse, and when the component to be deployed needs to be deployed on the cloud platform, the network address of the resource package in the target warehouse is acquired, so as to acquire the resource package of the component to be deployed and the configuration file of the resource package according to the network address in the target warehouse.
In order to better understand the process of the resource allocation method, the following describes a flow of the implementation method of the resource allocation with reference to an optional embodiment, but the flow is not limited to the technical solution of the embodiment of the present invention.
In this embodiment, a resource allocation method is provided, and fig. 3 is a flowchart of installation and deployment of a container cloud according to an optional embodiment of the present invention, as shown in fig. 3, a specific flow is as follows:
PXE installation: the installation of the nodes is completed based on a PXE template, the dependence solidification of basic components of an operating system is completed, the basic components comprise an automatic operation and maintenance tool, an application container engine docker, a wsagent, a manager ipvsadm of an IP virtual server and the like, and some functions are customized in the operating system, including firewall closing, postfix closing, systemd-journald configuration and the like.
Configuring a host: configuring node information, and adding harbor warehouse information in/etc/hosts, for pulling a chart packet (equivalent to the resource packet in the above embodiment) required when the component is deployed. And mounting mysql and etcd is realized.
Start time synchronization server ntp: and time synchronization among the nodes is realized.
Deployment of k8s and related plug-ins: acquiring a chart package of a k8s component and related plug-ins, and realizing guided deployment of the chart package through self-defined kubemdm, wherein the chart package comprises keepalived, nginx, etcd high-availability cluster, apiserver, kube-scheduler, kube-controller-manager, kube-proxy, crd and role resources, and a calico, coredns, palm and chartmum plug-in. As the entries in the deployment process are unified into a chat packet, the binaries of kubecect and kubecelet are placed into the mirror image in advance, the mirror image file is pulled up through a docker during deployment, the binary file corresponding to the mirror image file is obtained from the mirror image container, and then the mirror image container is stopped. In the process, a CA related self-signed certificate is generated, and then public keys and private keys used for bidirectional communication by components such as apiserver, etcd and the like are generated according to the CA certificate.
Deploying a management plane service component and a self-research component: after the k8s cluster is successfully deployed, management plane service components are also deployed, so that visual management of resources is facilitated, the service components are deployed by taking a chat packet as an entry and performing unified deployment through HelmRequest resources, and the service components comprise k8s expansion components such as ipsection and topolvm, promemeus and vm resource monitoring alarm components, promtail and loki log acquisition components, databases and middleware components such as mysql and redis, web components facilitating visual operation and local hardor warehouse components.
Self-defining apiserver and kube-controller-manager waits for a chart package of the deployment component, wherein resources attributes are used for managing resource quotas, the resource quotas comprise specific resource requirements (requests) and limits (limits), and the main managed resources are resources of a Central Processing Unit (CPU) and a memory. As shown in fig. 4, fig. 4 is a resource quota graph of each component to be deployed in the resource allocation method according to the alternative embodiment of the present invention.
An embodiment of the present invention provides a resource allocation method, and fig. 5 is a flowchart of a resource allocation method according to an alternative embodiment of the present invention, as shown in fig. 5, the specific steps are as follows:
step S501: customizing a chart packet of a component to be deployed, and setting resource quota information for the component to be deployed in a configuration file in the chart packet;
step S502: uploading the chart package to a chart warehouse through one-way construction, wherein the chart warehouse is used as the chart warehouse in the embodiment of the invention;
step S503: the method comprises the steps of obtaining a network address url of a chart packet, obtaining a configuration file of the chart packet according to a network address chart warehouse, and generating a rendering value-val in a map form of the chart packet according to the configuration file, wherein the network address url is used for indicating an address of the chart packet in the chart warehouse;
step S504: rendering the chart packet by using val as a rendering value through a chart packet rendering function native to the palm, and updating a value of value.yaml in the chart packet (which is equivalent to the value of the second field in the above embodiment). Finally, obtaining yaml files (equivalent to the third markup language files in the above embodiments) of each component conforming to the deployment specification of k8s, for deploying the components to be deployed;
step S505: determining whether to deploy the component to be deployed corresponding to the yaml file as a static Pod or submit the component to the apiserver (equivalent to the interface service in the above embodiment), deploying the component to be deployed by the apiserver, and executing step S506 if determining that the component to be deployed corresponding to the yaml file is deployed as the static Pod, otherwise executing step S507;
step S506: when the component to be deployed belongs to a k8s component (equivalent to the native component in the above embodiment), for example, apiserver, kube-proxy, etc., the component is deployed as a static Pod, and yaml files are copied to the/etc/kubernets/requirements directory (equivalent to the target directory in the above embodiment);
step S507: when the component to be deployed belongs to a plug-in (equivalent to the plug-in the above embodiment) of k8s, for example, a calico, a helm-captain, or the like, the yaml file is submitted to the api server, and the component to be deployed is deployed through a kubecect application.
According to the embodiment of the invention, an adaptive deployment scheme is constructed by the chat packet product arranged by the helm to solve the current service requirement, and the resource quota of the component can be limited by taking the chat packet instead of a mirror image as a deployment entrance, so that small-scale deployment is facilitated; the native capability does not satisfy business development.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
In this embodiment, a resource allocation apparatus is further provided, and the resource allocation apparatus is used to implement the foregoing embodiments and preferred embodiments, and details of which have been already described are omitted. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
Fig. 6 is a block diagram of a resource allocation apparatus according to an embodiment of the present invention; as shown in fig. 6, includes:
a first obtaining module 62, configured to obtain a first image file of a resource package of a component to be deployed and a first file address of the first image file, and update a value of a first field of a first markup language file in the resource package according to the first file address of the first image file, to obtain a second markup language file, where the value of the first field is used to indicate the first file address of the first image file;
a second obtaining module 64, configured to obtain a configuration file of the resource package of the component to be deployed, and update a value of a second field in the second markup language file according to the configuration file to obtain a third markup language file, where the configuration file includes resource quota configuration information, the resource quota configuration information is used to indicate a first resource quota allowed to be allocated to the component to be deployed, and the value of the second field in the second markup language file is used to indicate a second resource quota allowed to be allocated to the component to be deployed;
an allocating module 66, configured to obtain the first image file according to a value of the first field in the third markup language file, deploy the component to be deployed in the cloud platform according to the first image file, determine the first resource quota allowed to be allocated to the component to be deployed according to a value of the second field in the third markup language file, and allocate, in the cloud platform, a corresponding resource to the component to be deployed according to the first resource quota.
By the device, a first image file of a resource package of a component to be deployed and a first file address of the first image file are obtained, and a value of a first field of a first markup language file in the resource package is updated according to the first file address of the first image file to obtain a second markup language file, wherein the value of the first field is used for indicating the first file address of the first image file; acquiring a configuration file of a resource package of the component to be deployed, and updating a value of a second field in the second markup language file according to the configuration file to obtain a third markup language file, wherein the configuration file comprises resource quota configuration information, the resource quota configuration information is used for indicating a first resource quota allowed to be allocated to the component to be deployed, and the value of the second field in the second markup language file is used for indicating a second resource quota allowed to be allocated to the component to be deployed; the method comprises the steps of obtaining a first image file according to the value of a first field in a third markup language file, deploying the component to be deployed in a cloud platform according to the first image file, determining a first resource quota allowed to be allocated to the component to be deployed according to the value of a second field in the third markup language file, and allocating corresponding resources to the component to be deployed in the cloud platform according to the first resource quota, so that the problems that in the related art, the management of the resource quota cannot be performed on the component deployed on the cloud platform and the like are solved, an adaptive deployment scheme is further constructed through a resource package product, the current service requirement is solved, a resource package is used as a deployment entry of the component instead of the image file, the resource quota of the component can be limited, and small-scale deployment is facilitated.
In an exemplary embodiment, the first obtaining module 62 is further configured to determine whether a dependency exists between the resource package and the component code of the component to be deployed; under the condition that the resource package and the component code of the component to be deployed do not have a dependency relationship, acquiring an original image file in the resource package, and taking the original image file as the first image file; and compiling the component code to obtain a code image file under the condition that the resource package has a dependency relationship with the component code of the component to be deployed, and taking the code image file as the first image file.
In an exemplary embodiment, the first obtaining module 62 is further configured to, when the resource package does not have a dependency relationship with the component code of the component to be deployed, obtain an original file address of the original image file, and update a value of the first field of the first markup language file in the resource package to the original file address; and under the condition that the resource package and the component code of the component to be deployed have a dependency relationship, acquiring a code file address of the code image file, and updating the value of the first field of the first markup language file in the resource package into the code file address.
In an exemplary embodiment, the second obtaining module 64 is further configured to generate a rendering value of the resource package according to the resource quota configuration information in the configuration file, where the rendering value is used to indicate that the first resource quota allocated to the component to be deployed is allowed; and updating the value of the second field in the second markup language file to the rendering value to obtain the third markup language file.
In an exemplary embodiment, the allocating module 66 is further configured to, in a case that the component to be deployed is a native component in the cloud platform, store the third markup language file into a target directory of the cloud platform; and under the condition that the component to be deployed is an external plug-in the cloud platform, sending the third markup language file to an interface service of the cloud platform, so that the interface service acquires the first image file according to the value of the first field in the third markup language file, and deploys the component to be deployed in the cloud platform according to the first image file.
In an exemplary embodiment, the allocating module 66 is further configured to pull the first image file through the application container engine, and open the target container according to the first image file; and acquiring the binary file of the first image file in the target container, and deploying the component to be deployed in the cloud platform according to the binary file.
In an exemplary embodiment, the second obtaining module 64 is further configured to, in a case that the first markup language file in the resource package is updated to the second markup language file, save the resource package to a target repository in the cloud platform; and acquiring a network address of the resource package, and acquiring a configuration file of the resource package of the component to be deployed in the target warehouse according to the network address, wherein the network address is used for indicating an address of the resource package in the target warehouse.
An embodiment of the present invention further provides a storage medium including a stored program, wherein the program executes any one of the methods described above.
Alternatively, in the present embodiment, the storage medium may be configured to store program codes for performing the following steps:
s1, acquiring a first image file of a resource package of a component to be deployed and a first file address of the first image file, and updating a value of a first field of a first markup language file in the resource package according to the first file address of the first image file to obtain a second markup language file, wherein the value of the first field is used for indicating the first file address of the first image file;
s2, obtaining a configuration file of the resource package of the component to be deployed, and updating a value of a second field in the second markup language file according to the configuration file to obtain a third markup language file, where the configuration file includes resource quota configuration information, the resource quota configuration information is used to indicate a first resource quota allowed to be allocated to the component to be deployed, and the value of the second field in the second markup language file is used to indicate a second resource quota allowed to be allocated to the component to be deployed;
s3, obtaining the first image file according to the value of the first field in the third markup language file, deploying the component to be deployed in the cloud platform according to the first image file, determining the first resource quota allowed to be allocated to the component to be deployed according to the value of the second field in the third markup language file, and allocating corresponding resources to the component to be deployed in the cloud platform according to the first resource quota.
Embodiments of the present invention also provide an electronic device comprising a memory having a computer program stored therein and a processor arranged to run the computer program to perform the steps of any of the above method embodiments.
Optionally, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s1, acquiring a first image file of a resource package of a component to be deployed and a first file address of the first image file, and updating a value of a first field of a first markup language file in the resource package according to the first file address of the first image file to obtain a second markup language file, wherein the value of the first field is used for indicating the first file address of the first image file;
s2, obtaining a configuration file of the resource package of the component to be deployed, and updating a value of a second field in the second markup language file according to the configuration file to obtain a third markup language file, where the configuration file includes resource quota configuration information, the resource quota configuration information is used to indicate a first resource quota allowed to be allocated to the component to be deployed, and the value of the second field in the second markup language file is used to indicate a second resource quota allowed to be allocated to the component to be deployed;
s3, obtaining the first image file according to the value of the first field in the third markup language file, deploying the component to be deployed in the cloud platform according to the first image file, determining the first resource quota allowed to be allocated to the component to be deployed according to the value of the second field in the third markup language file, and allocating corresponding resources to the component to be deployed in the cloud platform according to the first resource quota.
Optionally, in this embodiment, the storage medium may include, but is not limited to: various media capable of storing program codes, such as a usb disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.
Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation manners, and this embodiment is not described herein again.
It will be apparent to those skilled in the art that the modules or steps of the present invention described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of multiple computing devices, and alternatively, they may be implemented by program code executable by a computing device, such that they may be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for allocating resources, comprising:
acquiring a first image file of a resource package of a component to be deployed and a first file address of the first image file, and updating a value of a first field of a first markup language file in the resource package according to the first file address of the first image file to obtain a second markup language file, wherein the value of the first field is used for indicating the first file address of the first image file;
acquiring a configuration file of a resource package of the component to be deployed, and updating a value of a second field in the second markup language file according to the configuration file to obtain a third markup language file, wherein the configuration file comprises resource quota configuration information, the resource quota configuration information is used for indicating a first resource quota allowed to be allocated to the component to be deployed, and the value of the second field in the second markup language file is used for indicating a second resource quota allowed to be allocated to the component to be deployed;
the method comprises the steps of obtaining a first image file according to the value of a first field in a third markup language file, deploying the component to be deployed according to the first image file in a cloud platform, determining a first resource quota allowed to be allocated to the component to be deployed according to the value of a second field in the third markup language file, and allocating corresponding resources to the component to be deployed according to the first resource quota in the cloud platform.
2. The method according to claim 1, wherein the obtaining the first image file of the resource package of the component to be deployed includes:
determining whether the resource package has a dependency relationship with the component code of the component to be deployed;
under the condition that the resource package does not have a dependency relationship with the component code of the component to be deployed, acquiring an original image file in the resource package, and taking the original image file as the first image file;
and compiling the component code to obtain a code image file under the condition that the resource package has a dependency relationship with the component code of the component to be deployed, and taking the code image file as the first image file.
3. The method according to claim 2, wherein the updating, according to the first file address of the first image file, a value of a first field of a first markup language file in the resource package to obtain a second markup language file comprises:
under the condition that the resource package does not have a dependency relationship with the component code of the component to be deployed, acquiring an original file address of the original image file, and updating the value of the first field of the first markup language file in the resource package to the original file address;
and under the condition that the resource package and the component code of the component to be deployed have a dependency relationship, acquiring a code file address of the code image file, and updating the value of the first field of the first markup language file in the resource package into the code file address.
4. The method according to claim 1, wherein the updating the value of the second field in the second markup language file according to the configuration file to obtain a third markup language file comprises:
generating a rendering value of the resource package according to the resource quota configuration information in the configuration file, wherein the rendering value is used for indicating that the first resource quota allocated to the component to be deployed is allowed;
and updating the value of the second field in the second markup language file to the rendering value to obtain the third markup language file.
5. The method according to claim 1, wherein after the updating the value of the second field in the second markup language file according to the configuration file to obtain a third markup language file, the method further comprises at least one of:
storing the third markup language file into a target directory of the cloud platform when the component to be deployed is a native component in the cloud platform;
and under the condition that the component to be deployed is an external plug-in the cloud platform, sending the third markup language file to an interface service of the cloud platform, so that the interface service acquires the first image file according to the value of the first field in the third markup language file, and deploying the component to be deployed in the cloud platform according to the first image file.
6. The resource allocation method according to claim 1, wherein deploying the component to be deployed according to the first image file in a cloud platform comprises:
pulling the first image file through an application container engine, and opening a target container according to the first image file;
and acquiring the binary file of the first image file in the target container, and deploying the component to be deployed in the cloud platform according to the binary file.
7. The method according to claim 1, wherein the obtaining the configuration file of the resource package of the component to be deployed includes:
saving the resource package to a target repository in the cloud platform if the first markup language file in the resource package is updated to the second markup language file;
and acquiring a network address of the resource package, and acquiring a configuration file of the resource package of the component to be deployed in the target warehouse according to the network address, wherein the network address is used for indicating an address of the resource package in the target warehouse.
8. An apparatus for allocating resources, comprising:
the system comprises a first acquisition module, a second acquisition module and a first storage module, wherein the first acquisition module is used for acquiring a first image file of a resource package of a component to be deployed and a first file address of the first image file, and updating a value of a first field of a first markup language file in the resource package according to the first file address of the first image file to obtain a second markup language file, and the value of the first field is used for indicating the first file address of the first image file;
a second obtaining module, configured to obtain a configuration file of a resource package of the component to be deployed, and update a value of a second field in the second markup language file according to the configuration file to obtain a third markup language file, where the configuration file includes resource quota configuration information, the resource quota configuration information is used to indicate a first resource quota allowed to be allocated to the component to be deployed, and the value of the second field in the second markup language file is used to indicate a second resource quota allowed to be allocated to the component to be deployed;
the allocation module is configured to acquire the first image file according to a value of the first field in the third markup language file, deploy the component to be deployed in the cloud platform according to the first image file, determine the first resource quota allowed to be allocated to the component to be deployed according to a value of the second field in the third markup language file, and allocate corresponding resources to the component to be deployed in the cloud platform according to the first resource quota.
9. A computer-readable storage medium, comprising a stored program, wherein the program is operable to perform the method of any one of claims 1 to 7.
10. An electronic device comprising a memory and a processor, characterized in that the memory has stored therein a computer program, the processor being arranged to execute the method of any of claims 1 to 7 by means of the computer program.
CN202210130578.3A 2022-02-11 2022-02-11 Resource allocation method and device, storage medium and electronic device Active CN114461399B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210130578.3A CN114461399B (en) 2022-02-11 2022-02-11 Resource allocation method and device, storage medium and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210130578.3A CN114461399B (en) 2022-02-11 2022-02-11 Resource allocation method and device, storage medium and electronic device

Publications (2)

Publication Number Publication Date
CN114461399A true CN114461399A (en) 2022-05-10
CN114461399B CN114461399B (en) 2024-07-02

Family

ID=81413635

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210130578.3A Active CN114461399B (en) 2022-02-11 2022-02-11 Resource allocation method and device, storage medium and electronic device

Country Status (1)

Country Link
CN (1) CN114461399B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114938257A (en) * 2022-05-11 2022-08-23 浪潮云信息技术股份公司 Time synchronization method and system for container cloud cluster nodes

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104572202A (en) * 2015-01-08 2015-04-29 浪潮电子信息产业股份有限公司 Method for allocating enterprise-level application software under cloud computing
US9678683B1 (en) * 2016-11-01 2017-06-13 Red Hat, Inc. Lazy persistent storage volume provisioning
CN107526639A (en) * 2017-08-16 2017-12-29 杭州朗和科技有限公司 Method, medium, device and the computing device of resource layout
CN108958927A (en) * 2018-05-31 2018-12-07 康键信息技术(深圳)有限公司 Dispositions method, device, computer equipment and the storage medium of container application
CN111459668A (en) * 2020-03-30 2020-07-28 中科边缘智慧信息科技(苏州)有限公司 Lightweight resource virtualization method and device for server
CN112256439A (en) * 2020-12-08 2021-01-22 富通云腾科技有限公司 Service directory dynamic updating system and method based on cloud computing resource pool
CN113031971A (en) * 2019-12-25 2021-06-25 北京世纪好未来教育科技有限公司 Software deployment method, system and computer storage medium
US20210279102A1 (en) * 2020-03-04 2021-09-09 Dell Products L.P. Method and system for deployment of a workload using resource devices in a compasable infrastructure

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104572202A (en) * 2015-01-08 2015-04-29 浪潮电子信息产业股份有限公司 Method for allocating enterprise-level application software under cloud computing
US9678683B1 (en) * 2016-11-01 2017-06-13 Red Hat, Inc. Lazy persistent storage volume provisioning
CN107526639A (en) * 2017-08-16 2017-12-29 杭州朗和科技有限公司 Method, medium, device and the computing device of resource layout
CN108958927A (en) * 2018-05-31 2018-12-07 康键信息技术(深圳)有限公司 Dispositions method, device, computer equipment and the storage medium of container application
CN113031971A (en) * 2019-12-25 2021-06-25 北京世纪好未来教育科技有限公司 Software deployment method, system and computer storage medium
US20210279102A1 (en) * 2020-03-04 2021-09-09 Dell Products L.P. Method and system for deployment of a workload using resource devices in a compasable infrastructure
CN111459668A (en) * 2020-03-30 2020-07-28 中科边缘智慧信息科技(苏州)有限公司 Lightweight resource virtualization method and device for server
CN112256439A (en) * 2020-12-08 2021-01-22 富通云腾科技有限公司 Service directory dynamic updating system and method based on cloud computing resource pool

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
MARKO S. EREMIJA: ""Identity provider deployment based on container technology"", 《2017 25TH TELECOMMUNICATION FORUM (TELFOR)》, 8 January 2018 (2018-01-08), pages 1 - 4 *
徐江生: ""容器云平台的设计与实现"", 《中国优秀硕士学位论文全文数据库 信息科技辑》, no. 2018, 15 March 2018 (2018-03-15), pages 139 - 253 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114938257A (en) * 2022-05-11 2022-08-23 浪潮云信息技术股份公司 Time synchronization method and system for container cloud cluster nodes

Also Published As

Publication number Publication date
CN114461399B (en) 2024-07-02

Similar Documents

Publication Publication Date Title
CN114208124B (en) System and method for selectively implementing services on virtual machines and containers
CN108809722B (en) Method, device and storage medium for deploying Kubernetes cluster
CN109104318B (en) Method for realizing cluster self-adaptive deployment
CN106844137B (en) Server monitoring method and device
CN110447208B (en) Network slice management method, unit and system
US20190188014A1 (en) Virtual appliances
US20200252908A1 (en) Resource allocation method and orchestrator for network slicing in the wireless access network
CN111245634B (en) Virtualization management method and device
US20240031432A1 (en) High Availability and High Utilization Cloud Data Center Architecture for Supporting Telecommunications Services
CN109525590B (en) Data packet transmission method and device
EP3687112A1 (en) Communication method and communication device
WO2016115896A1 (en) Method and device for management of virtual network function (vnf)
CN115733746B (en) Deployment method, device and equipment of service grid unit and storage medium
CN114064206A (en) Pod method, system, equipment and storage medium for accessing edge node
CN110061857B (en) Method and system for opening and sharing multiple MEC (Multi-media Engineer) capabilities
Wiranata et al. Automation of virtualized 5g infrastructure using mosaic 5g operator over kubernetes supporting network slicing
CN114461399B (en) Resource allocation method and device, storage medium and electronic device
CN113419813B (en) Method and device for deploying bare engine management service based on container platform
CN112087311B (en) Virtual network function VNF deployment method and device
CN106341353B (en) Resource processing method and device
CN114911577A (en) Method, device, equipment and storage medium for setting network isolation rule
CN114662102A (en) File processing method and device and storage medium
US12022385B2 (en) Systems and methods for modeling container-based network functions
US20240028368A1 (en) Remote edge virtualization management
US20240291716A1 (en) Systems and methods for orchestration of network functions

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
GR01 Patent grant