Container resource creation method, apparatus, device, and computer-readable storage medium

By automatically adding node selector attributes to container groups in the Kubernetes cluster, the problem of random resource scheduling for container groups is solved, targeted scheduling of container groups is achieved, and cluster resource utilization and user experience are improved.

CN110221901BActive Publication Date: 2026-01-23WEBANK (CHINA)
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201910494501.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-06-06
Publication Date
2026-01-23
Estimated Expiration
2039-06-06

AI Technical Summary

Technical Problem

When creating container resources in a Kubernetes cluster, the container group does not automatically add node selector attributes, resulting in random resource scheduling and low cluster resource utilization.

Method used

By reading the namespace annotations of container resources, key-value pairs are obtained and injected into the container group definition as node selector attributes, automatically adding node selectors to the container group to achieve targeted scheduling of the container group.

Benefits of technology

It improves the utilization rate of cluster resources, reduces the need for manual operation by users, and enhances the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110221901B_ABST
    Figure CN110221901B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of financial technology, and discloses a container resource creation method, device and equipment and a computer readable storage medium. The method comprises the following steps: when a container resource creation request is received, obtaining a complete definition of a container resource according to the container resource creation request; reading a target namespace from the complete definition, calling a preset interface to read an annotation of the target namespace, and obtaining a key-value pair in the annotation; injecting the key-value pair as a node selector attribute into a container group definition part in the complete definition to obtain an updated complete definition, and creating a corresponding container resource and container group based on the updated complete definition. The application can automatically add a node selector attribute to a container group in a container resource when the container resource is created, so that the container group can be subsequently directed and scheduled to an optimal computing node in a cluster, thereby guaranteeing balanced utilization of cluster resources and improving cluster resource utilization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of financial technology (Fintech), and more particularly to a method, apparatus, device, and computer-readable storage medium for creating container resources. Background Technology

[0002] With the development of computer technology, more and more technologies (big data, distributed systems, blockchain, artificial intelligence, etc.) are being applied in the financial field. The traditional financial industry is gradually transforming into financial technology (Fintech). However, due to the security and real-time requirements of the financial industry, higher demands are also being placed on technology.

[0003] Kubernetes is an open-source platform for managing containerized applications across multiple hosts in a cloud platform. Kubernetes works well with hardware resource management and scheduling for container applications, allowing users to allocate specific containers to specific nodes (compute nodes) according to their needs, thus utilizing the necessary hardware resources. This has led to its widespread adoption, with many internet companies and financial institutions already building container cloud platforms based on Kubernetes in their production environments. However, after creating container resources (such as Deployments), when adding the NodeSelector attribute to a container resource, each Pod (container group) within the container resource is not automatically assigned a NodeSelector. This prevents the use of Node Selectors, resulting in Pods being randomly scheduled to a node during subsequent scheduling, leading to low cluster resource utilization. Summary of the Invention

[0004] The main objective of this invention is to provide a method, apparatus, device, and computer-readable storage medium for creating container resources, which aims to automatically add node selector attributes to container groups in container resources, so as to subsequently schedule container groups to the optimal computing nodes in the cluster, thereby improving the utilization rate of cluster resources.

[0005] To achieve the above objectives, the present invention provides a method for creating container resources, the method comprising:

[0006] Upon receiving a container resource creation request, the complete definition of the container resource is obtained based on the container resource creation request;

[0007] The target namespace is obtained from the complete definition, and the annotations of the target namespace are read by calling the preset interface to obtain the key-value pairs in the annotations;

[0008] The key-value pairs are injected as node selector attributes into the container group definition part of the complete definition to obtain the updated complete definition, and the corresponding container resources and container groups are created based on the updated complete definition.

[0009] Optionally, the step of calling a preset interface to read the annotations of the target namespace and obtaining the key-value pairs in the annotations includes:

[0010] Call the preset interface to read the annotations of the target namespace;

[0011] The annotation is parsed based on the preset annotation keys to obtain the key-value pairs in the annotation.

[0012] Optionally, the step of creating corresponding container resources and container groups based on the updated complete definition includes:

[0013] The updated complete definition is submitted to the open-source container orchestration engine Kubernetes cluster through the preset interface, so that the corresponding container resources can be created through the command-line tools of the Kubernetes cluster;

[0014] A corresponding container copy is created based on the container resource, and a container group is created based on the container copy.

[0015] Optionally, before the step of obtaining the complete definition of the container resource based on the container resource creation request upon receiving the container resource creation request, the container resource creation method further includes:

[0016] Upon receiving an operation request triggered by a user, the system obtains the corresponding request type and operation information based on the operation request, and performs the corresponding operation based on the request type and operation information; wherein, the operation request includes a node tag creation request, a namespace creation request, and a namespace annotation addition request.

[0017] Optionally, after the step of creating the corresponding container resources and container groups based on the updated complete definition, the container resource creation method includes:

[0018] Obtain the node selector attribute of the container group, and obtain the node that matches the node selector attribute based on the preset node label of each node, and record it as the first target node;

[0019] Obtain the idle resource information of the first target node, determine the second target node based on the idle resource information and the preset scheduling rules, and schedule the container group to the second target node.

[0020] Furthermore, to achieve the above objectives, the present invention also provides a container resource creation apparatus, the container resource creation apparatus comprising:

[0021] The definition acquisition module is used to obtain the complete definition of the container resource based on the container resource creation request when a container resource creation request is received.

[0022] The annotation reading module is used to read the target namespace from the complete definition, and call the preset interface to read the annotations of the target namespace to obtain the key-value pairs in the annotations;

[0023] The resource creation module is used to inject the key-value pairs as node selector attributes into the container group definition part of the complete definition to obtain the updated complete definition, and create the corresponding container resources and container groups based on the updated complete definition.

[0024] Optionally, the resource creation module includes:

[0025] The first creation unit is used to submit the updated complete definition to the Kubernetes cluster through the preset interface, so as to create the corresponding container resources through the command line tool of the Kubernetes cluster;

[0026] The second creation unit is used to create a corresponding container copy based on the container resource, so as to create a container group based on the container copy.

[0027] Optionally, the container resource creation apparatus further includes:

[0028] The node acquisition module is used to acquire the node selector attribute of the container group, and acquire the node that matches the node selector attribute based on the preset node label of each node, and denot it as the first target node.

[0029] The container group allocation module is used to obtain the idle resource information of the first target node, determine the second target node according to the idle resource information and the preset scheduling rules, and schedule the container group to the second target node.

[0030] In addition, to achieve the above objectives, the present invention also provides a container resource creation device, the container resource creation device comprising: a memory, a processor, and a container resource creation program stored on the memory and executable on the processor, wherein the container resource creation program, when executed by the processor, implements the steps of the container resource creation method as described above.

[0031] In addition, to achieve the above objectives, the present invention also provides a computer-readable storage medium storing a container resource creation program, which, when executed by a processor, implements the steps of the container resource creation method described above.

[0032] This invention provides a method, apparatus, device, and computer-readable storage medium for creating container resources. Upon receiving a container resource creation request, the method first obtains the user's complete definition of the container resource based on the request. It then reads the target namespace from this complete definition and calls a preset interface to read the annotations of the target namespace, obtaining key-value pairs from the annotations. These key-value pairs are then injected as node selector attributes into the container group definition portion of the complete definition to automatically add node selectors to the container group, resulting in an updated complete definition. Based on this updated complete definition, the corresponding container resource and container group are created. Through this method, this invention automatically adds node selector attributes to container groups within container resources during the creation process, eliminating the need for manual addition by the user and improving user experience. Furthermore, by automatically adding node selector attributes to container groups, it facilitates subsequent targeted scheduling of container groups to the optimal computing nodes in the cluster. Compared to existing technologies that randomly schedule container groups due to the lack of node selectors, this invention ensures balanced utilization of cluster resources and improves cluster resource utilization. Attached Figure Description

[0033] Figure 1 This is a schematic diagram of the device structure of the hardware operating environment involved in the embodiments of the present invention;

[0034] Figure 2 This is a flowchart illustrating the first embodiment of the container resource creation method of the present invention;

[0035] Figure 3 This is a timing diagram of the processing steps involved in the container resource creation method of the present invention;

[0036] Figure 4 This is a schematic diagram of the functional modules of the first embodiment of the container resource creation device of the present invention.

[0037] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0038] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0039] Reference Figure 1 , Figure 1 This is a schematic diagram of the device structure of the hardware operating environment involved in the embodiments of the present invention.

[0040] The container resource creation device in this embodiment of the invention can be a smartphone, or a PC (Personal Computer), tablet computer, portable computer, or other terminal device.

[0041] like Figure 1 As shown, the container resource creation device may include: a processor 1001, such as a CPU; a communication bus 1002; a user interface 1003; a network interface 1004; and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen or an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be high-speed RAM or non-volatile memory, such as disk storage. Optionally, the memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0042] Those skilled in the art will understand that Figure 1 The container resource creation device structure shown does not constitute a limitation on the container resource creation device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0043] like Figure 1 As shown, the memory 1005, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a container resource creation program.

[0044] exist Figure 1 In the terminal shown, network interface 1004 is mainly used to connect to the backend server and communicate data with it; user interface 1003 is mainly used to connect to the client and communicate data with it; while processor 1001 can be used to call the container resource creation program stored in memory 1005 and perform the following operations:

[0045] Upon receiving a container resource creation request, the complete definition of the container resource is obtained based on the container resource creation request;

[0046] The target namespace is obtained from the complete definition, and the annotations of the target namespace are read by calling the preset interface to obtain the key-value pairs in the annotations;

[0047] The key-value pairs are injected as node selector attributes into the container group definition part of the complete definition to obtain the updated complete definition, and the corresponding container resources and container groups are created based on the updated complete definition.

[0048] Furthermore, the processor 1001 can invoke the container resource creation program stored in the memory 1005 and also perform the following operations:

[0049] Call the preset interface to read the annotations of the target namespace;

[0050] The annotation is parsed based on the preset annotation keys to obtain the key-value pairs in the annotation.

[0051] Furthermore, the processor 1001 can invoke the container resource creation program stored in the memory 1005 and also perform the following operations:

[0052] The updated complete definition is submitted to the open-source container orchestration engine Kubernetes cluster through the preset interface, so that the corresponding container resources can be created through the command-line tools of the Kubernetes cluster;

[0053] A corresponding container copy is created based on the container resource, and a container group is created based on the container copy.

[0054] Furthermore, the processor 1001 can invoke the container resource creation program stored in the memory 1005 and also perform the following operations:

[0055] Upon receiving an operation request triggered by a user, the system obtains the corresponding request type and operation information based on the operation request, and performs the corresponding operation based on the request type and operation information; wherein, the operation request includes a node tag creation request, a namespace creation request, and a namespace annotation addition request.

[0056] Furthermore, the processor 1001 can invoke the container resource creation program stored in the memory 1005 and also perform the following operations:

[0057] Obtain the node selector attribute of the container group, and obtain the node that matches the node selector attribute based on the preset node label of each node, and record it as the first target node;

[0058] Obtain the idle resource information of the first target node, determine the second target node based on the idle resource information and the preset scheduling rules, and schedule the container group to the second target node.

[0059] Based on the above hardware structure, various embodiments of the container resource creation method of the present invention are proposed.

[0060] This invention provides a method for creating container resources.

[0061] Reference Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the container resource creation method of the present invention.

[0062] In this embodiment, the container resource creation method includes:

[0063] Step S10: Upon receiving a container resource creation request, obtain the complete definition of the container resource based on the container resource creation request;

[0064] The container resource creation method in this embodiment is implemented by a container resource creation device, which is described using a server as an example. When a user needs to create a container resource, they can click the container resource creation option through the corresponding software or program on the terminal. After entering relevant information (such as the type of container resource, the namespace to which the container resource belongs, the number of Pods in the container group, etc.), a container resource creation request can be triggered. At this time, when the server receives the container resource creation request, it first obtains the complete definition of the container resource by the user based on the container resource creation request and caches it in memory. The container resource can be a Deployment, a StatefulSet, a DaemonSet, etc. In this embodiment, the creation of a Deployment is used as an example. A Deployment is one of the units in which a container application runs in a Kubernetes cluster, and it contains several container groups (Pods).

[0065] Step S20: Read the target namespace from the complete definition, and call the preset interface to read the annotation of the target namespace to obtain the key-value pairs in the annotation;

[0066] After obtaining the user's complete definition of the container resource, the target namespace is read from the complete definition. It should be noted that the namespace is the logical isolation unit of resources in the Kubernetes cluster, and each container resource must belong to a certain namespace.

[0067] After reading the target namespace, a preset interface is called to read the annotations of that namespace and obtain the key-value pairs from the annotations. This preset interface can be the Kubernetes API (Application Programming Interface). The Kubernetes API is a crucial component of the cluster system. Data from various resources (objects) in Kubernetes is submitted to the backend persistent storage through this API. The various components in the Kubernetes cluster are decoupled through this API. Furthermore, kubectl, an important and convenient management tool in the Kubernetes cluster, also achieves its powerful management functions by accessing this API.

[0068] The step "calling a preset interface to read the annotations of the target namespace and obtain the key-value pairs in the annotations" includes:

[0069] Step a1: Call the preset interface to read the annotations of the target namespace;

[0070] Step a2: Parse the annotation based on the preset annotation keys to obtain the key-value pairs in the annotation.

[0071] First, the Kubernetes API is called to read the annotations of the target namespace. Then, the annotations are parsed based on the preset annotation keys to obtain the key-value pairs in the annotations. The annotation keys are set by the user when adding the namespace annotation; for example, in the following embodiment, they can be set to "scheduler.alpha.kubernetes.io / node-selector" to facilitate the identification and retrieval of key-value pairs in the annotations.

[0072] Step S30: Inject the key-value pair as a node selector attribute into the container group definition part of the complete definition to obtain the updated complete definition, and create the corresponding container resources and container groups based on the updated complete definition.

[0073] After obtaining the key-value pairs from the annotations, these pairs are injected as Node Selector attributes into the Pod definition section of the complete definition, resulting in an updated complete definition. By injecting key-value pairs as Node Selector attributes into the Pod definition section of the complete definition, the Node Selector attribute is automatically added to the Pod, eliminating the need for manual addition. Finally, the corresponding container resources and container groups are created based on the updated complete definition.

[0074] The step "creating corresponding container resources and container groups based on the updated complete definition" includes:

[0075] Step b1: Submit the updated complete definition to the open-source container orchestration engine Kubernetes cluster through the preset interface, so as to create the corresponding container resources through the command line tools of the Kubernetes cluster;

[0076] After obtaining the updated complete definition, it is submitted to the Kubernetes cluster via a predefined interface (Kubernetes API) to create corresponding container resources, such as Deployments, using the Kubernetes cluster's command-line tools. Kubernetes is an open-source container orchestration engine from Google that supports automated deployment, large-scale scalability, and containerized application management. The Kubernetes cluster's command-line tool is kubectl, which allows for cluster management and the installation and deployment of containerized applications.

[0077] Step b2: Create a corresponding container copy based on the container resource, and create a container group based on the container copy.

[0078] Then, a corresponding container replica (Replcasset) is created based on the container resources, and a container group (Pod) is created based on the container replica (Replcasset). The specific creation process of the above container resources is as follows: Figure 3 As shown.

[0079] In the creation of container resources for financial institutions such as banks, this invention, upon receiving a container creation request, first obtains the user's complete definition of the container resource, then reads the target namespace, and injects the key-value pairs from the target namespace annotations as node selector attributes into the container group definition section of the complete definition. Based on the updated complete definition, the corresponding container resource and container group are then created. This invention automatically adds node selector attributes to container groups, eliminating the need for manual addition and reducing labor costs for financial institutions such as banks. Furthermore, this invention facilitates the subsequent targeted scheduling of container groups to the optimal computing nodes in the cluster. Compared to existing technologies that randomly schedule container groups due to the lack of node selectors, this invention ensures balanced utilization of cluster resources for financial institutions such as banks, improving cluster resource utilization.

[0080] This invention provides a method for creating container resources. Upon receiving a container resource creation request, the method first obtains the user's complete definition of the container resource based on the request. The target namespace is then read from this complete definition, and a preset interface is called to read the annotations of the target namespace, obtaining key-value pairs from the annotations. These key-value pairs are then injected as node selector attributes into the container group definition portion of the complete definition to automatically add node selectors to the container group, resulting in an updated complete definition. Based on this updated complete definition, the corresponding container resource and container group are created. Through this method, this invention can automatically add node selector attributes to container groups within container resources during the creation process, eliminating the need for manual addition by the user and improving user experience. Furthermore, automatically adding node selector attributes to container groups facilitates subsequent targeted scheduling of container groups to the optimal computing nodes in the cluster. Compared to the prior art where container groups are randomly scheduled due to the lack of node selectors, this invention ensures balanced utilization of cluster resources and improves cluster resource utilization.

[0081] Furthermore, based on Figure 2 The first embodiment shown presents a second embodiment of the container resource creation method of the present invention.

[0082] In this embodiment, prior to step S10, the container resource creation method further includes:

[0083] Upon receiving an operation request triggered by a user, the system obtains the corresponding request type and operation information based on the operation request, and performs the corresponding operation based on the request type and operation information; wherein, the operation request includes a node tag creation request, a namespace creation request, and a namespace annotation addition request.

[0084] In this embodiment, users can trigger various operation requests in advance to perform various operations, such as creating a NodeLabel, creating a Namespace, and adding a Namespace annotation. When the server receives an operation request triggered by the user, it obtains the corresponding request type and operation information based on the request, and executes the corresponding operation according to the request type and operation information. The operation requests include node label creation requests, namespace creation requests, and namespace annotation addition requests. Specifically, when the operation request is a node label creation request, the operation information may include the target node and its corresponding node label, and the operation is to create the corresponding Node Label for the target node. When the operation request is a namespace creation request, the operation information may include the number of the namespace to be created, and the operation is to create the corresponding Namespace. When the operation request is a namespace annotation addition request, the operation information may include the number of the namespace to be added and the annotation to be added, and the operation is to find the corresponding Namespace based on the number of the namespace to be added, and then add the annotation to it. The specific processing procedure for the above requests is as follows: Figure 3 As shown.

[0085] For example, users can add custom Node Labels to each Node via the Kubernetes API. These Labels exist in key-value pairs (x = y). A Node Label is a logical tag for a compute node in a Kubernetes cluster, used to identify different Nodes and their resources. Labels can be added and modified for each Node via the Kubernetes API and stored in the cluster's data repository. Specifically, users assign specific Node Labels to Nodes by calling the K8s API. For example, consider the following Nodes:

[0086] a.32C CPU / 256GB RAM / 8C Tesla V100 GPU

[0087] b. 64C CPU / 128GB RAM / 8C Tesla V100 GPU

[0088] c.32C CPU / 128GB RAM / 16C Tesla V100 GPU

[0089] Users can create the following Node Labels for them:

[0090] a.node-cpu=32C, node-memory=256G, node-gpu=8C, node-gpu-model=V100

[0091] b.node-cpu=64C, node-memory=128G, node-gpu=8C, node-gpu-model=V100

[0092] c.node-cpu=32C, node-memory=128G, node-gpu=16C, node-gpu-model=V100

[0093] For example, after a user creates a custom namespace, they can add annotations to the namespace via the Kubernetes API. If a user wants to assign container groups requiring large amounts of memory to the first Node, container groups requiring high CPU computing power to the second Node, and container groups requiring high GPU performance to the third Node, they can configure the annotation values ​​for the three namespaces as follows (consistent with the Node Labels mentioned above):

[0094] a.node-cpu=32C, node-memory=256G, node-gpu=8C, node-gpu-model=V100

[0095] b.node-cpu=64C, node-memory=128G, node-gpu=8C, node-gpu-model=V100

[0096] c.node-cpu=32C, node-memory=128G, node-gpu=16C, node-gpu-model=V100

[0097] It should be noted that during the annotation addition process, users can customize the annotation key for easy identification. For example, the annotation key can be set to "scheduler.alpha.kubernetes.io / node-selector" so that the corresponding key-value pair can be found and parsed in the annotation later.

[0098] Furthermore, based on Figure 2 The first embodiment shown presents a third embodiment of the container resource creation method of the present invention.

[0099] In this embodiment, after step S30 described above, the container resource creation method further includes:

[0100] Step A: Obtain the node selector attribute of the container group, and obtain the node that matches the node selector attribute based on the preset node label of each node, and record it as the first target node;

[0101] In this embodiment, since the Node Selector attribute has been added to the container group in the above steps, the Kubernetes scheduler will identify and adjust the Node on which the Pod runs according to the instructions. Specifically, after creating the container resources and container group, the node selector attribute of the container group can be obtained, and the node matching the node selector attribute can be obtained based on the preset node label of each node, denoted as the first target node. The node label of each node is pre-created by the user; the specific node label creation method can be referred to the second embodiment above. When obtaining the node matching the node selector attribute, the Node containing the Node Label in the Node Selector attribute is searched according to the preset node label of each node.

[0102] Step B: Obtain the idle resource information of the first target node, determine the second target node based on the idle resource information and the preset scheduling rules, and schedule the container group to the second target node.

[0103] After obtaining the first target node, scheduling is required based on its idle resource information. Specifically, the idle resource information of the first target node is first obtained, including the idle / remaining information of resources such as CPU (Central Processing Unit), GPU (Graphics Processing Unit), and memory. Then, the second target node is determined based on the idle resource information and preset scheduling rules, and the container group is scheduled to the second target node. The preset scheduling rules can be pre-set according to the user's actual needs. For example, it can be set to a scheduling rule that selects the node with the most idle CPU resources, or it can be set to a scheduling rule that comprehensively scores the idle status of various resources, such as scoring each resource based on its idle status, summing the scores of each resource to obtain the total score of each node, and selecting the node with the highest total score as the second target node. The above preset scheduling rules are for illustrative purposes only and are not intended to limit the invention.

[0104] The present invention also provides a container resource creation apparatus.

[0105] Reference Figure 4 , Figure 4 This is a schematic diagram of the functional modules of the first embodiment of the container resource creation device of the present invention.

[0106] like Figure 4 As shown, the container resource creation device includes:

[0107] The definition acquisition module 10 is used to obtain the complete definition of the container resource according to the container resource creation request when a container resource creation request is received;

[0108] Annotation reading module 20 is used to read the target namespace from the complete definition, and call a preset interface to read the annotations of the target namespace to obtain the key-value pairs in the annotations;

[0109] The resource creation module 30 is used to inject the key-value pair as a node selector attribute into the container group definition part of the complete definition to obtain the updated complete definition, and create the corresponding container resources and container groups based on the updated complete definition.

[0110] Furthermore, the annotation reading module 20 includes:

[0111] Annotation reading unit, used to call a preset interface to read annotations of the target namespace;

[0112] The key-value pair acquisition unit is used to parse the annotation based on the preset key pairs of the annotation to obtain the key-value pairs in the annotation.

[0113] Furthermore, the resource creation module 30 includes:

[0114] The first creation unit is used to submit the updated complete definition to the Kubernetes cluster through the preset interface, so as to create the corresponding container resources through the command line tool of the Kubernetes cluster;

[0115] The second creation unit is used to create a corresponding container copy based on the container resource, so as to create a container group based on the container copy.

[0116] Furthermore, the container resource creation apparatus further includes:

[0117] The operation execution module is used to, upon receiving an operation request triggered by a user, obtain the corresponding request type and operation information based on the operation request, and execute the corresponding operation based on the request type and the operation information; wherein, the operation request includes a node tag creation request, a namespace creation request, and a namespace annotation addition request.

[0118] Furthermore, the container resource creation apparatus further includes:

[0119] The node acquisition module is used to acquire the node selector attribute of the container group, and acquire the node that matches the node selector attribute based on the preset node label of each node, and denot it as the first target node.

[0120] The container group scheduling module is used to obtain the idle resource information of the first target node, determine the second target node according to the idle resource information and the preset scheduling rules, and schedule the container group to the second target node.

[0121] The functions of each module in the container resource creation device correspond to the steps in the container resource creation method embodiment, and their functions and implementation processes will not be described in detail here.

[0122] The present invention also provides a computer-readable storage medium storing a container resource creation program, which, when executed by a processor, implements the steps of the container resource creation method as described in any of the above embodiments.

[0123] The specific embodiments of the computer-readable storage medium of the present invention are basically the same as the embodiments of the container resource creation method described above, and will not be repeated here.

[0124] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.

[0125] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0126] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0127] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.

Claims

1. A method for creating container resources, characterized in that, The container resource creation method includes: Upon receiving a container resource creation request, the complete definition of the container resource is obtained based on the container resource creation request; The target namespace is obtained from the complete definition, and the annotations of the target namespace are read by calling the preset interface to obtain the key-value pairs in the annotations; The key-value pairs are injected as node selector attributes into the container group definition part of the complete definition to obtain the updated complete definition, and the corresponding container resources and container groups are created based on the updated complete definition; The container resource creation method includes: Obtain the node selector attribute of the container group, and obtain the node that matches the node selector attribute based on the preset node label of each node, and record it as the first target node; Obtain the idle resource information of the first target node, determine the second target node based on the idle resource information and the preset scheduling rules, and schedule the container group to the second target node.

2. The container resource creation method as described in claim 1, characterized in that, The step of calling a preset interface to read the annotations of the target namespace and obtaining the key-value pairs in the annotations includes: Call the preset interface to read the annotations of the target namespace; The annotation is parsed based on the preset annotation keys to obtain the key-value pairs in the annotation.

3. The container resource creation method as described in claim 1, characterized in that, The steps for creating corresponding container resources and container groups based on the updated complete definition include: The updated complete definition is submitted to the open-source container orchestration engine Kubernetes cluster through the preset interface, so that the corresponding container resources can be created through the command-line tools of the Kubernetes cluster; A corresponding container copy is created based on the container resource, and a container group is created based on the container copy.

4. The container resource creation method according to any one of claims 1 to 3, characterized in that, Before the step of obtaining the complete definition of the container resource based on the container resource creation request upon receiving the container resource creation request, the container resource creation method further includes: Upon receiving an operation request triggered by a user, the system obtains the corresponding request type and operation information based on the operation request, and performs the corresponding operation based on the request type and operation information; wherein, the operation request includes a node tag creation request, a namespace creation request, and a namespace annotation addition request.

5. A container resource creation device, characterized in that, The container resource creation device includes: The definition acquisition module is used to obtain the complete definition of the container resource based on the container resource creation request when a container resource creation request is received. The annotation reading module is used to read the target namespace from the complete definition, and call the preset interface to read the annotations of the target namespace to obtain the key-value pairs in the annotations; The resource creation module is used to inject the key-value pairs as node selector attributes into the container group definition part of the complete definition to obtain the updated complete definition, and create the corresponding container resources and container groups based on the updated complete definition; The node acquisition module is used to acquire the node selector attribute of the container group, and acquire the node that matches the node selector attribute based on the preset node label of each node, and denot it as the first target node. The container group allocation module is used to obtain the idle resource information of the first target node, determine the second target node according to the idle resource information and the preset scheduling rules, and schedule the container group to the second target node.

6. The container resource creation apparatus as described in claim 5, characterized in that, The resource creation module includes: The first creation unit is used to submit the updated complete definition to the Kubernetes cluster through the preset interface, so as to create the corresponding container resources through the command line tool of the Kubernetes cluster; The second creation unit is used to create a corresponding container copy based on the container resource, so as to create a container group based on the container copy.

7. A container resource creation device, characterized in that, The container resource creation device includes: a memory, a processor, and a container resource creation program stored on the memory and executable on the processor, wherein when the container resource creation program is executed by the processor, it implements the steps of the container resource creation method as described in any one of claims 1 to 4.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a container resource creation program, which, when executed by a processor, implements the steps of the container resource creation method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Container cluster intelligent life cycle management method and device

    CN109032758A