Container mirror image preheating method, system and equipment and storage medium

By introducing PreloadimageJobcrD and Controller in the Kubernetes cluster, the automatic container mirror preheating is realized, the container mirroring takes longer, and the container startup speed is significantly increased.

CN119336446AActive Publication Date: 2025-01-21CHINA ASEAN INFORMATION PORT CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411373124.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2025-01-21
Estimated Expiration
2044-09-29

AI Technical Summary

Technical Problem

In Kubernetes cloud native clusters, container image pulling takes longer, resulting in a longer container startup time, and the prior art lacks automated and simplified mirror warm-up methods.

Method used

By introducing PreloadImageJobCRD and the corresponding controller, automated container image preheating is achieved. Specific steps include loading api-server in the Kubernetes cluster, adding resource controllers and agents, monitoring PreloadImageJob resources, selecting nodes based on workloadSelector, and performing image pull operations through agent interaction with CRI.

Benefits of technology

It realizes automatic image preheating, simplifies user operations, significantly reduces container startup time, and optimizes the image pulling time by more than 70%.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119336446A_ABST
    Figure CN119336446A_ABST
Patent Text Reader

Abstract

The invention discloses a container mirror image preheating method, a container mirror image preheating system, container mirror image preheating equipment and a storage medium, belongs to the technical field of running control of software application, and solves the technical problem that the operation is relatively tedious by manually running mirror image pulling work on nodes in advance. The method comprises the following steps: loading and running api-server in a Kubernetes cloud native cluster for receiving a control request; the method comprises the following steps: newly adding a resource controller in a Kubernetes cloud native cluster so as to monitor a PreloadImage Job resource; adding an agent on each node so as to realize a specific mirror image pulling operation; the method comprises the following steps of: identifying a workloadSelector field of a newly created PreloadImageJob resource to obtain a Kind field and a name field which are included in the workloadSelector field, and identifying the workloadSelector field of the newly created PreloadImageJob resource according to the Kind field and the name field of the newly created PreloadImageJob resource, carrying out node selection, and writing all obtained possible node names into a status.node field; and monitoring a status.node field of the PreloadImageJob, and according to a spec.image field in the PreloadImageJob resource, pulling a corresponding mirror image, and according to the status.node field in the PreloadImageJob resource, obtaining the mirror image according to the status.node field in the PreloadImageJob resource.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software application operation control, and more specifically, to a container image preheating method, system, device and storage medium. Background Art

[0002] In a Kubernetes cloud-native cluster, after the container group resources are created, they will be scheduled, mounted, and allocated to the network before the image is officially pulled. This means that the key to optimizing the startup time of a container group lies in optimizing two parts of time: one is the configuration time of storage and network, and the other is the time for pulling the image. If the image of the sidecar container and the basic image of the business container can be pulled on the node in advance, the Pod (container group) creation process can be greatly shortened, and the time spent on pulling the image can even be optimized by more than 70%.

[0003] In the current Kubernetes cloud-native cluster, Kubernetes itself does not provide any image-oriented operation capabilities. The only way to solve the problem of slow container startup caused by time-consuming image pulling is to manually run the image pulling work on the node in advance.

[0004] In the current standard Kubernetes cluster, if you want to preheat the image of some workloads to the corresponding nodes in advance, you need to first extract the workload's nodeselector (node ​​selector) and nodename (node ​​name) fields, determine the possible running nodes, and then log in to the corresponding node to run the image pull operation. This set of operations is relatively cumbersome and cannot be combined with the CICD (continuous integration, continuous deployment) system to achieve the purpose of rapid preheating. Summary of the invention

[0005] The technical problem to be solved by the present invention is to address the above-mentioned deficiencies in the prior art. The first purpose of the present invention is to provide a container image preheating method, which can automatically and quickly preheat the image to the node corresponding to the workload, simplifying the user operation, and achieving the purpose of pulling the image on the node in advance, greatly reducing the startup time of the container.

[0006] A second objective of the present invention is to provide a container image preheating system.

[0007] A third object of the present invention is to provide a computer device.

[0008] A fourth objective of the present invention is to provide a computer storage medium.

[0009] In order to achieve the above-mentioned first objective, the present invention provides a container image preheating method, comprising the following steps:

[0010] Step 1. Load and run the api-server in the Kubernetes cloud-native cluster, set the api-server as the control entry of the Kubernetes cloud-native cluster, and accept control requests through the api-server;

[0011] Step 2. Add a new resource controller in the Kubernetes cloud native cluster, listen to the PreloadImageJob resource through the controller, and fill the status field according to the specific configuration of the PreloadImageJob resource; add a new agent on each node, which can interact with CRI to implement specific image pulling operations;

[0012] Step 3. After the api-server receives a creation request of the PreloadImageJob type and monitors the creation of a PreloadImageJob resource through the controller, it identifies the workloadSelector field of the PreloadImageJob resource and obtains the kind and name fields contained in the workloadSelector field;

[0013] Step 4. Select the corresponding workload based on the kind and name fields. The controller extracts the nodeSelector, affinity, and tolerances fields of the workload to select the node, and writes all possible node names obtained into the status.node field.

[0014] Step 5. The agent on the selected node monitors the status.node field of PreloadImageJob. If a corresponding node is written, the image pull operation is performed. Specifically, the corresponding image is pulled according to the spec.image field in the PreloadImageJob resource.

[0015] As a further improvement, the Master Node is used as the control node. The control node is not responsible for running the workload, but is responsible for running the api-server, Controller Manager, and Scheduler. The Worker Node is used as the working node, and each working node runs the Kubelet component and multiple container groups as workloads.

[0016] Furthermore, the api-server is connected to the distributed database etcd for various resource configurations and state storage within the cluster.

[0017] Furthermore, each node contains the Kubelet component, which serves as an agent for communication between the node and the Kubernetes cloud-native cluster, and as a management component for the workload container group on the management node; among them, the api-server, as the control component of the Kubernetes cloud-native cluster, can receive requests for adding, modifying, deleting, and monitoring Node-type resources, and reflect the modifications in etcd.

[0018] In order to achieve the above-mentioned second objective, the present invention provides a container image preheating system, comprising:

[0019] The startup module is used to load and run the api-server in the Kubernetes cloud-native cluster, use the api-server as the control entry of the Kubernetes cloud-native cluster, and accept control requests through the api-server;

[0020] A new module is added to add a new resource controller in the Kubernetes cloud native cluster. The controller listens to the PreloadImageJob resource and fills the status field according to the specific configuration of the PreloadImageJob resource. A new agent is added on each node, which can interact with CRI to implement specific image pulling operations.

[0021] The field identification module is used to identify the workloadSelector field of the PreloadImageJob resource after the api-server receives a creation request of the PreloadImageJob type and monitors the creation of the PreloadImageJob resource through the controller, and obtain the kind and name fields contained in the workloadSelector field;

[0022] The node selection module is used to select the corresponding workload according to the kind and name fields. The controller extracts the nodeSelector, affinity, and tolerances fields of the workload to select the node, and writes all possible node names obtained into the status.node field.

[0023] The pull module is used to monitor the status.node field of PreloadImageJob through the agent on the selected node. If a corresponding node is written, the image pull operation is performed, specifically, the corresponding image is pulled according to the spec.image field in the PreloadImageJob resource.

[0024] In order to achieve the third objective above, the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned container image preheating method when executing the computer program.

[0025] In order to achieve the fourth objective above, the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the above-mentioned container image preheating method is implemented.

[0026] Beneficial Effects

[0027] Compared with the prior art, the present invention has the following advantages:

[0028] 1. The present invention can automate image preheating. By introducing PreloadImageJobCRD and the corresponding controller, the automation of the image preheating process is realized. The user only needs to create a PreloadImageJob resource, and the system can automatically preheat the image on the relevant node, which greatly simplifies the operation process.

[0029] 2. The present invention uses the workloadSelector mechanism, and users can flexibly select the workload that needs to be preheated, which is applicable to various complex deployment scenarios.

[0030] 3. The present invention can improve the startup speed of the container. By pulling the image on the node that may run the workload in advance, the present invention significantly reduces the image pulling time when the container is started, and can optimize the image pulling time by more than 70%, greatly improving the startup speed of the container. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 An architectural diagram for preheating container images based on Kubernetes cloud native clusters;

[0032] Figure 2 This is an architectural diagram of the control node and the working node. DETAILED DESCRIPTION

[0033] The present invention will be further described below with reference to the specific embodiments in the accompanying drawings.

[0034] See also Figure 1-2 , a container image preheating method, comprising the following steps:

[0035] Step 1. Load and run the api-server (application interface server) in the Kubernetes cloud native cluster, set the api-server as the control entry of the Kubernetes cloud native cluster, and accept control requests through the api-server;

[0036] Step 2. Add a new resource controller in the Kubernetes cloud native cluster, listen to the PreloadImageJob resource through the controller, and fill the status field according to the specific configuration of the PreloadImageJob resource; add a new agent on each node, which can interact with CRI (Container Runtime Interface) to implement specific image pulling operations;

[0037] Step 3. After the api-server receives a creation request of the PreloadImageJob type and monitors the creation of a PreloadImageJob resource through the controller, it identifies the workloadSelector field of the PreloadImageJob resource and obtains the kind and name fields contained in the workloadSelector field;

[0038] Step 4. Select the corresponding workload based on the kind and name fields. The controller extracts the nodeSelector, affinity, and tolerances fields of the workload to select the node, and writes all possible node names obtained into the status.node field.

[0039] Step 5. The agent on the selected node monitors the status.node field of PreloadImageJob. If a corresponding node is written, the image pull operation is performed. Specifically, the corresponding image is pulled according to the spec.image field in the PreloadImageJob resource. That is, the agent interacts with CRI (Container Runtime Interface) to implement the specific image pull operation.

[0040] like Figure 1 , Figure 2As shown in the figure, three Master Nodes are used as control nodes, and the control nodes are not responsible for running workloads. The control nodes are responsible for running the api-server, Controller Manager, and Scheduler. N Worker Nodes are used as working nodes, and each worker node runs the Kubelet component and multiple container groups as workloads.

[0041] The api-server on each Master Node is connected to the distributed database etcd for various resource configuration and status storage within the cluster.

[0042] Each node contains the Kubelet component, which serves as an agent for communication between the node and the Kubernetes cloud-native cluster, and as a management component for the workload container group on the management node; among them, the api-server, as the control component of the Kubernetes cloud-native cluster, can receive requests for adding, modifying, deleting, and monitoring Node-type resources, and reflect the changes in etcd.

[0043] In this embodiment, if Figure 1 As shown, for example, a PreloadImageJob resource is submitted to the api-server to specify the corresponding workload, which is Deployment-0 in this embodiment, and the names of the images that need to be preheated, which are image-0 and image-1.

[0044] The controller listens to the creation of the PreloadImageJob resource and obtains the nodeSelector field from the specified workload Deployment-0:

[0045] kubernetes.io / hostname:node-0, after matching with the node label, writes the possible running node name of the workload, node-0, into the status field of PreloadImageJob.

[0046] When the agent component on node-0 detects that the status of the PreloadImageJob resource is updated, it obtains the status.node field as node-0, which matches the name of this node.

[0047] The agent component on node-0 obtains the spec.image of PreloadImageJob as image-0 and image-1, and sends a request to CRI to pull the images image-0 and image-1.

[0048] The corresponding runtime will implement the CRI image pulling interface and perform the image pulling operation. At this point, the preheating of images image-0 and image-1 is completed on node node-0.

[0049] A container image preheating system, comprising:

[0050] The startup module is used to load and run the api-server in the Kubernetes cloud-native cluster, use the api-server as the control entry of the Kubernetes cloud-native cluster, and accept control requests through the api-server;

[0051] A new module is added to add a new resource controller in the Kubernetes cloud native cluster. The controller listens to the PreloadImageJob resource and fills the status field according to the specific configuration of the PreloadImageJob resource. A new agent is added on each node, which can interact with CRI to implement specific image pulling operations.

[0052] The field identification module is used to identify the workloadSelector field of the PreloadImageJob resource after the api-server receives a creation request of the PreloadImageJob type and monitors the creation of the PreloadImageJob resource through the controller, and obtain the kind and name fields contained in the workloadSelector field;

[0053] The node selection module is used to select the corresponding workload according to the kind and name fields. The controller extracts the nodeSelector, affinity, and tolerances fields of the workload to select the node, and writes all possible node names obtained into the status.node field.

[0054] The pull module is used to monitor the status.node field of PreloadImageJob through the agent on the selected node. If a corresponding node is written, the image pull operation is performed, specifically, the corresponding image is pulled according to the spec.image field in the PreloadImageJob resource.

[0055] A computer device includes a memory and a processor. The memory stores a computer program. When the processor executes the computer program, the above-mentioned container image preheating method is implemented.

[0056] A computer-readable storage medium stores a computer program, which implements the above-mentioned container image preheating method when executed by a processor.

[0057] The above are only preferred embodiments of the present invention. It should be pointed out that for those skilled in the art, several modifications and improvements can be made without departing from the structure of the present invention, which will not affect the effect of the implementation of the present invention and the practicality of the patent.

Claims

1. A container image preheating method, characterized in that: The following steps are involved: Step 1. Load and run the api-server in the Kubernetes cloud-native cluster, set the api-server as the control entry of the Kubernetes cloud-native cluster, and accept control requests through the api-server; Step 2. Add a new resource controller in the Kubernetes cloud native cluster, listen to the PreloadImageJob resource through the controller, and fill the status field according to the specific configuration of the PreloadImageJob resource; add a new agent on each node, which can interact with CRI to implement specific image pulling operations; Step 3. After the api-server receives a creation request of the PreloadImageJob type and monitors the creation of a PreloadImageJob resource through the controller, it identifies the workloadSelector field of the PreloadImageJob resource and obtains the kind and name fields contained in the workloadSelector field; Step 4. Select the corresponding workload based on the kind and name fields. The controller extracts the nodeSelector, affinity, and tolerances fields of the workload to select the node, and writes all possible node names obtained into the status.node field. Step 5. The agent on the selected node monitors the status.node field of PreloadImageJob. If a corresponding node is written, the image pull operation is performed. Specifically, the corresponding image is pulled according to the spec.image field in the PreloadImageJob resource.

2. A container image preheating method according to claim 1, characterized in that: The Master Node is used as the control node. The control node is not responsible for running the workload. The control node is responsible for running the api-server, ControllerManager, and Scheduler. The Worker Node is used as the working node. Each working node runs the Kubelet component and multiple container groups as workloads.

3. A container image preheating method according to claim 1, characterized in that: The api-server is connected to the distributed database etcd for various resource configuration and status storage within the cluster.

4. A container image preheating method according to claim 3, characterized in that: Each node contains the Kubelet component, which serves as an agent for communication between the node and the Kubernetes cloud-native cluster, and as a management component for the workload container group on the management node; among them, the api-server, as the control component of the Kubernetes cloud-native cluster, can receive requests for adding, modifying, deleting, and monitoring Node-type resources, and reflect the changes in etcd.

5. A container image preheating system, characterized in that: include: The startup module is used to load and run the api-server in the Kubernetes cloud-native cluster, use the api-server as the control entry of the Kubernetes cloud-native cluster, and accept control requests through the api-server; A new module is added to add a new resource controller in the Kubernetes cloud native cluster. The controller listens to the PreloadImageJob resource and fills the status field according to the specific configuration of the PreloadImageJob resource. A new agent is added on each node, which can interact with CRI to implement specific image pulling operations. The field identification module is used to identify the workloadSelector field of the PreloadImageJob resource after the api-server receives a creation request of the PreloadImageJob type and monitors the creation of the PreloadImageJob resource through the controller, and obtain the kind and name fields contained in the workloadSelector field; The node selection module is used to select the corresponding workload according to the kind and name fields. The controller extracts the nodeSelector, affinity, and tolerances fields of the workload to select the node, and writes all possible node names obtained into the status.node field. The pull module is used to monitor the status.node field of PreloadImageJob through the agent on the selected node. If a corresponding node is written, the image pull operation is performed, specifically, the corresponding image is pulled according to the spec.image field in the PreloadImageJob resource.

6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the container image preheating method according to any one of claims 1 to 4 is implemented.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the container image preheating method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Container mirror image preheating method, electronic equipment and storage medium

    CN116781719A

  • Service-managed containers for container orchestration service

    US11392422B1