CN116781719A - Container mirror image preheating method, electronic equipment and storage medium - Google Patents

Container mirror image preheating method, electronic equipment and storage medium Download PDF

Info

Publication number
CN116781719A
CN116781719A CN202211371803.9A CN202211371803A CN116781719A CN 116781719 A CN116781719 A CN 116781719A CN 202211371803 A CN202211371803 A CN 202211371803A CN 116781719 A CN116781719 A CN 116781719A
Authority
CN
China
Prior art keywords
target
mirror image
service node
information
image
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211371803.9A
Other languages
Chinese (zh)
Inventor
刘唯一
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Mobile Communications Group Co Ltd
China Mobile Suzhou Software Technology Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
China Mobile Suzhou Software 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 China Mobile Communications Group Co Ltd, China Mobile Suzhou Software Technology Co Ltd filed Critical China Mobile Communications Group Co Ltd
Priority to CN202211371803.9A priority Critical patent/CN116781719A/en
Publication of CN116781719A publication Critical patent/CN116781719A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The application discloses a container mirror image preheating method, electronic equipment and a storage medium, wherein the container mirror image preheating method is applied to a server and comprises the following steps: inquiring at least one preset rule matched with the target image when a pushing event of the target image to be processed is detected; determining target clusters associated with the preset rules, wherein each preset rule is associated with one target cluster; and indicating the client corresponding to the target cluster to pull the target mirror image at the first service node. Therefore, when the pushed target image is received, the preheating pulling of the target image on the service node can be automatically completed, the deployment is not required to be triggered manually, and the image preheating efficiency is improved.

Description

Container mirror image preheating method, electronic equipment and storage medium
Technical Field
The disclosure relates to the technical field of network applications, and in particular relates to a container mirror image preheating method, electronic equipment and a storage medium.
Background
In a container resource management (k 8 s) cluster, the creation of a data structure (plain old data structure, pod) is accomplished by pulling a container image. Before formally pulling the mirror image based on service processing, the mirror image can be cached in advance through mirror image preheating, so that mirror image pulling efficiency is improved.
In the current cluster management scheme, the mirror image preheating can be realized by manually configuring event triggering or manual deployment, and complicated manual steps exist, so that the mirror image preheating takes too long time.
Disclosure of Invention
In view of this, the present disclosure provides a container image preheating method, an electronic device, and a storage medium.
The technical scheme of the present disclosure is realized as follows:
in a first aspect, the present disclosure provides a method for preheating a container image, applied to a server, where the method includes:
inquiring at least one preset rule matched with the target image when a pushing event of the target image to be processed is detected;
determining target clusters associated with the preset rules, wherein each preset rule is associated with one target cluster;
and indicating the client corresponding to the target cluster to pull the target mirror image at the first service node.
In one embodiment, the detecting a push event of the target image to be processed includes:
and receiving push event information which is sent by the mirror image warehouse and indicates the target mirror image to be processed.
In one embodiment, the method further comprises:
creating at least one target cluster based on cluster information of at least one container resource management k8s cluster of the image to be preheated;
And generating a preset rule associated with the target cluster based on node information in the target cluster and corresponding mirror image information received from the client.
In one embodiment, the generating the preset rule associated with the target cluster based on the node information and the mirror information in the target cluster received from the client includes:
receiving node information of a second service node which is sent by the client and is used for pulling the mirror image and mirror image information of the second service node which is used for pulling the mirror image;
if a preset rule does not exist between the second service node and the mirror image information, determining a service node set associated with the second service node based on the node information and historical service deployment information;
and generating a preset rule associated with the target cluster based on the service node set and the mirror image information.
In one embodiment, the method further comprises:
if a preset rule exists between the second service node and the mirror image information, determining whether a preset rule exists between the mirror image information and other service nodes except the second service node;
when a preset rule exists between the mirror image information and the other service nodes, acquiring the pulling moment of the last pulling mirror image recorded by the second service node;
If the duration between the pulling time and the current time is greater than a preset value, deleting the preset rule between the mirror image information and the second service node;
and if the time length between the pulling time and the current time is smaller than or equal to a preset value, updating the pulling time of the last pulling mirror image recorded by the second service node.
In one embodiment, the preset rule at least indicates:
one or more target images; the plurality of target images includes: presetting a plurality of target images contained in an image space and/or presetting a plurality of target images related to the images;
in a second aspect, the present disclosure provides a container image preheating method, applied to a client, the method including:
determining a first service node in a target cluster corresponding to the client based on an instruction of the server;
configuring a task resource object based on node information of the first service node;
indicating a task executor on the first service node to pull a target mirror image through the task resource object; and a preset rule exists between the target mirror image and the target cluster.
In one embodiment, the indicating, by the task resource object, the task executor on the first service node to pull the target image includes:
And indicating a task executor on the first service node to pull the target image by using a local application container engine through the task resource object.
In one embodiment, the method further comprises:
monitoring events which are not processed by a local application container engine in the target cluster;
if the mirror image pulling event is monitored, determining node information of a second service node corresponding to the mirror image pulling event and mirror image information of a mirror image pulled by the second service node;
and sending the node information and the mirror image information of the second service node to the server, wherein the node information and the mirror image information of the second service node are at least used for generating a preset rule.
In one embodiment, the preset rule at least indicates:
one or more target images; the plurality of target images includes: the method comprises the steps of presetting a plurality of target images contained in an image space and/or presetting a plurality of target images related by the images.
In a third aspect, the present disclosure provides a container mirror preheating device applied to a server, the device comprising:
the query unit is used for querying at least one preset rule matched with the target image when a pushing event of the target image to be processed is detected;
The first determining unit is used for determining target clusters associated with the preset rules, wherein each preset rule is associated with one target cluster;
the indication unit is used for indicating the client corresponding to the target cluster to pull the target mirror image at the first service node.
In one embodiment, the query unit is specifically configured to:
and inquiring at least one preset rule matched with the target image when receiving push event information which is sent by the image warehouse and indicates the target image to be processed.
In one embodiment, the apparatus further comprises:
the creating unit is used for creating at least one target cluster based on cluster information of at least one container resource management k8s cluster of the image to be preheated; and generating a preset rule associated with the target cluster based on node information in the target cluster and corresponding mirror image information received from the client.
In an embodiment, the creating unit is specifically configured to:
receiving node information of a second service node which is sent by the client and is used for pulling the mirror image and mirror image information of the second service node which is used for pulling the mirror image;
if a preset rule does not exist between the second service node and the mirror image information, determining a service node set associated with the second service node based on the node information and historical service deployment information;
And generating a preset rule associated with the target cluster based on the service node set and the mirror image information.
In one embodiment, the apparatus further comprises:
the processing unit is used for determining whether a preset rule exists between the mirror image information and other service nodes except the second service node if the preset rule exists between the second service node and the mirror image information;
when a preset rule exists between the mirror image information and the other service nodes, acquiring the pulling moment of the last pulling mirror image recorded by the second service node;
if the duration between the pulling time and the current time is greater than a preset value, deleting the preset rule between the mirror image information and the second service node;
and if the time length between the pulling time and the current time is smaller than or equal to a preset value, updating the pulling time of the last pulling mirror image recorded by the second service node.
In one embodiment, the preset rule at least indicates:
one or more target images; the plurality of target images includes: presetting a plurality of target images contained in an image space and/or presetting a plurality of target images related to the images;
In a fourth aspect, the present disclosure provides a container image preheating apparatus, applied to a client, the apparatus comprising:
the second determining unit is used for determining a first service node in a target cluster corresponding to the client based on the indication of the server;
a configuration unit, configured to configure a task resource object based on node information of the first service node;
the pulling unit is used for indicating a task executor on the first service node to pull the target mirror image through the task resource object; and a preset rule exists between the target mirror image and the target cluster.
In one embodiment, the pulling unit is specifically configured to:
and indicating a task executor on the first service node to pull the target image by using a local application container engine through the task resource object.
In one embodiment, the apparatus further comprises:
the monitoring unit is used for monitoring events which are not processed by the local application container engine in the target cluster;
if the mirror image pulling event is monitored, determining node information of a second service node corresponding to the mirror image pulling event and mirror image information of a mirror image pulled by the second service node;
and sending the node information and the mirror image information of the second service node to the server, wherein the node information and the mirror image information of the second service node are at least used for generating a preset rule.
In one embodiment, the preset rule at least indicates:
one or more target images; the plurality of target images includes: the method comprises the steps of presetting a plurality of target images contained in an image space and/or presetting a plurality of target images related by the images.
In a fifth aspect, the present disclosure provides an electronic device comprising: a processor and a memory for storing a computer program capable of running on the processor;
the processor, when executing the computer program, performs the steps of the method of one or more of the preceding claims.
In a sixth aspect, the present disclosure provides a computer-readable storage medium having stored thereon computer-executable instructions; the computer-executable instructions, when executed by the processor, are capable of performing the method of one or more of the foregoing aspects.
The container mirror image preheating method provided by the disclosure is applied to a server and comprises the following steps: inquiring at least one preset rule matched with the target image when a pushing event of the target image to be processed is detected; determining target clusters associated with the preset rules, wherein each preset rule is associated with one target cluster; and indicating the client corresponding to the target cluster to pull the target mirror image at the first service node. Therefore, when the pushed target image is received, the preheating pulling of the target image on the service node can be automatically completed, manual triggering or manual deployment is not needed, and the time for completing the preheating of the image is shortened. And the mirror image preheating control of a single cluster or multiple clusters can be completed aiming at least one target cluster corresponding to at least one preset rule, so that the mirror image preheating efficiency is further improved.
Drawings
FIG. 1 is a schematic flow chart of a method for preheating a container image according to an embodiment of the disclosure;
FIG. 2 is a schematic flow chart of a method for preheating a container image according to an embodiment of the disclosure;
FIG. 3 is a schematic flow chart of a method for preheating a container image according to an embodiment of the disclosure;
FIG. 4 is a schematic flow chart of a method for preheating a container image according to an embodiment of the disclosure;
FIG. 5 is a schematic flow chart of a method for preheating a container image according to an embodiment of the disclosure;
FIG. 6 is a flow chart of a method for preheating a container image according to an embodiment of the present disclosure;
FIG. 7 is a schematic flow chart of a method for preheating a container image according to an embodiment of the disclosure;
FIG. 8 is a schematic diagram of a container mirror preheating device according to an embodiment of the present disclosure;
fig. 9 is a schematic structural diagram of a container mirror preheating device according to an embodiment of the present disclosure.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present disclosure more apparent, the present disclosure will be further described in detail with reference to the accompanying drawings, and the described embodiments should not be construed as limiting the present disclosure, and all other embodiments obtained by those skilled in the art without making inventive efforts are within the scope of protection of the present disclosure.
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is to be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments and can be combined with one another without conflict.
In the following description, the terms "first", "second", "third" and the like are merely used to distinguish similar objects and do not represent a particular ordering of the objects, it being understood that the "first", "second", "third" may be interchanged with a particular order or sequence, as permitted, to enable embodiments of the disclosure described herein to be practiced otherwise than as illustrated or described herein.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure belongs. The terminology used herein is for the purpose of describing embodiments of the present disclosure only and is not intended to be limiting of the present disclosure.
As shown in fig. 1, an embodiment of the present disclosure provides a container image preheating method, which is applied to a server, and the method includes:
s110: inquiring at least one preset rule matched with the target image when a pushing event of the target image to be processed is detected;
S120: determining target clusters associated with the preset rules, wherein each preset rule is associated with one target cluster;
s130: and indicating the client corresponding to the target cluster to pull the target mirror image at the first service node.
In the embodiment of the disclosure, the container mirror is an object required for creating a pod in a k8s cluster, and the creating a pod process often requires the steps of volume mount, network allocation of a container network interface (Container Network Interface, cni), pulling the container mirror, and starting the container. The mirror image preheating is to pre-cache the mirror image for quick pulling in order to improve the mirror image pulling efficiency before formally pulling the mirror image based on the application service requirement.
In one embodiment, the server may be the end for controlling the management image warm-up process, e.g., may interface with the front-end interface, and be available for an administrator to operate. The target image to be processed may be a container image, such as a service change image, to be preheated to a service node in the target cluster. The target cluster may be a user cluster such as a k8s cluster to be preheated, and a client (agent) may be deployed in the target cluster, for example, the client may be deployed on a master running (master) node of the target cluster.
The client is deployed in the target cluster in a preset Deployment mode (default), and can also establish connection with the server through a node port (nodeport) of the client as a service port for the server to call and access.
In one embodiment, the push event of the target image to be processed may be pushing the service change image to be processed for the user, for example, pushing to a server or an image repository (hardor), etc.
In one embodiment, detecting a push event for a target image to be processed may include: and receiving push event information which is sent by the mirror image warehouse and indicates the target mirror image to be processed. For example, when the user pushes the image information of the target image to be processed to the image repository, for example, the image tag (tag) is "registry. Example/test/test1:v1", the push event information sent by the image repository may be information informing the server that the target image is pushed, for example, the push event information may include the image tag of the target image, which is used to instruct the server to perform image preheating on the target image. Here, the push event information may be event processing application (webhook) information or the like.
In one embodiment, the preset rule matching the target image may be a preset rule bound to the target image and the target cluster, and the preset rule is used to indicate a preheating rule for preheating the target image to the target cluster. The target mirror image and the target cluster are bound, and can be bound with a first service node in the target mirror image and the target cluster, and the target mirror image and the target cluster are used for indicating a preheating rule for preheating the target mirror image to the first service node.
In an embodiment, the target cluster associated with the preset rule may be a target cluster to which the preset rule belongs, or a target cluster corresponding to cluster information recorded in the preset rule, and the like. The preset rule may indicate or record the mirror information of the bound target mirror image and the cluster information of the target cluster, and may also indicate or record the node information of the bound first service node, etc.
In one embodiment, step S130 may include: and generating a mirror image preheating task, and issuing the mirror image preheating task to a client corresponding to the target cluster, wherein the mirror image preheating task indicates that the target mirror image is pulled at the first service node.
In one embodiment, at least one preset rule may correspond to at least one target cluster, and the server may instruct the clients of the multiple target clusters to pull the target image, thereby implementing the image preheating process under multiple clusters.
In one embodiment, the instructing the client corresponding to the target cluster to pull the target image at the first service node may include instructing the client corresponding to the target cluster to pull the target image at the first service node through a task executor (task-executor).
In one embodiment, the task executor may be a component deployed on a service node, for example in the form of a daemon set (daemon).
In one embodiment, the indicating, by the task executor, the client corresponding to the target cluster to pull the target image at the first service node may include: and indicating the client corresponding to the target cluster to pull the target mirror image at the first service node through a local application container engine (dock) of the task executor.
In one embodiment, the method may further comprise: and receiving a mirror image preheating result sent by the client, and outputting the mirror image preheating result to a front-end interface for display.
In one embodiment, the method may further comprise: receiving node update information sent by a client; and updating the node information in the stored cluster information based on the node updating information. The node update information may include, among other things, node addition or deletion information of the nodes in the cluster, which may include, for example, added or deleted node names and/or node internet protocol (Internet Protocol, IP) addresses.
Therefore, when the pushed target image is received, the preheating pulling of the target image on the service node can be automatically completed, manual triggering or manual deployment is not needed, and the time for completing the preheating of the image is shortened. And the mirror image preheating control of a single cluster or multiple clusters can be completed aiming at least one target cluster corresponding to at least one preset rule, so that the mirror image preheating efficiency is further improved. On the basis, the target mirror image can be directly preheated to the service node, and the fact that the actual pulling time is still longer due to preheating to the super node or the mirror image warehouse is avoided.
In some embodiments, as shown in fig. 2, the method may further comprise:
s101: creating at least one target cluster based on cluster information of at least one container resource management k8s cluster of the image to be preheated;
s102: and generating a preset rule associated with the target cluster based on node information in the target cluster and corresponding mirror image information received from the client.
In the embodiment of the disclosure, the cluster information of the k8s cluster to be pre-heated image may be input to the server by an administrator or the like. At least one target cluster is created, and at least one k8s cluster to be preheated mirror image can be marked as the target cluster, for example, the at least one k8s cluster is marked by preset identification.
In one embodiment, the node information in the target cluster received from the client may be a service node in the target cluster where a mirror pulling event occurs, and the corresponding mirror information may be mirror information corresponding to the node information, for example, mirror information of a mirror pulled by the service node.
In one embodiment, a service node in the target cluster where a mirror pull event occurs may be determined for a client by listening for an event object (event) of the target cluster. The mirror image pulling event in the event information of the monitoring target cluster may be a mirror image pulling event that is not executed by the local dock of the task executor. Therefore, other mirror image pulling events which do not execute the mirror image preheating through the container mirror image preheating method in the embodiment of the disclosure can be bound with the nodes to generate the preset rule.
In some embodiments, as shown in fig. 3, the S102 may include:
s1021: receiving node information of a second service node which is sent by the client and is used for pulling the mirror image and mirror image information of the second service node which is used for pulling the mirror image;
s1022: if a preset rule does not exist between the second service node and the mirror image information, determining a service node set associated with the second service node based on the node information and historical service deployment information;
s1023: and generating a preset rule associated with the target cluster based on the service node set and the mirror image information.
In the embodiment of the present disclosure, the second service node that has pulled the mirror may be a service node that has not pulled the mirror through the local dock of the task executor. The node information may be a node tag or a node ID, etc., and the mirror information may be a mirror tag or a mirror ID, etc.
In one embodiment, after receiving the node information and the mirror image information of the second service node, it may be queried whether a preset rule has been established for a mirror image corresponding to the mirror image information of the second service node, i.e. whether a preset rule exists between the second service node and the mirror image information.
In one embodiment, if the preset rule does not exist, the preset rule for binding the second service node and the mirror information may be generated based on the second service node and the mirror information. Wherein, can include: based on the history habit of user service deployment, a preset rule for binding the second service node with the mirror image information is generated by combining the second service node with the mirror image information.
In one embodiment, the historical habits of the user's service deployment may be historical habits of the user's service deployment at one or more service nodes, such as may be determined based on historical service deployment information. The historical service deployment information can be acquired from a target cluster or a second service node.
In one embodiment, the service node set associated with the second service node may include at least one service node for processing a service processed by the second service node or a service currently to be processed by the second service node, and/or at least one service node having a preset association relationship with a service processed by the second service node or a service currently to be processed by the second service node.
The preset association relationship may be a service node required for executing a service or a service node depending on the preset association relationship.
Thus, the preheating rule can be automatically created, and the time consumption for manually creating the preheating rule is saved. In addition, the preheating rule can be established according to the historical service deployment information, so that the accuracy of establishing the preset rule is improved.
In some embodiments, the method may further comprise:
if a preset rule exists between the second service node and the mirror image information, determining whether a preset rule exists between the mirror image information and other service nodes except the second service node;
When a preset rule exists between the mirror image information and the other service nodes, acquiring the pulling moment of the last pulling mirror image recorded by the second service node;
if the duration between the pulling time and the current time is greater than a preset value, deleting the preset rule between the mirror image information and the second service node;
and if the time length between the pulling time and the current time is smaller than or equal to a preset value, updating the pulling time of the last pulling mirror image recorded by the second service node.
In the embodiment of the present disclosure, if a preset rule is established between the second service node and the mirror image information, it may be determined whether the preset rule is not updated for a long time, for example, according to an interval between a time of last pulling the mirror image recorded by the second service node and a current time.
In one embodiment, as shown in fig. 4, when a preset rule exists between the mirror information and the other service nodes, it may be determined that the mirror is currently bound with other preset rules, and then updating may be performed according to the mirror pulling time. The method may further comprise: and when the preset rule does not exist between the mirror image information and the other service nodes, keeping the current preset rule between the second service node and the mirror image information unchanged.
In an embodiment, if the duration between the pulling time and the current time is greater than a preset value, or if the second service node does not pull other images in a preset period before the current time, which indicates that a time interval from the last time of pulling the images is long, a preset rule between the image information and the second service node is deleted. The preset period and the preset value may indicate a predetermined update period or iteration period.
In one embodiment, if the duration between the pulling time and the current time is less than or equal to a preset value, a current preset rule between the second service node and the mirror image information is reserved, and the pulling time of the last pulling mirror image of the second service node is updated to be the mirror image pulling time corresponding to the mirror image information.
Thus, the preset rules which are not updated for a long time can be deleted in time, so that unnecessary invalid preheating is avoided, and excessive unnecessary images are stored on the nodes.
In some embodiments, the preset rules at least indicate:
one or more target images; the plurality of target images includes: presetting a plurality of target images contained in an image space and/or presetting a plurality of target images related to the images;
In the embodiment of the disclosure, the preset rule may include an automatic mirror image preheating rule or a manual mirror image preheating rule. Wherein the manual mirroring warm-up rule may indicate one or more first service nodes, including: all service nodes in the target cluster or one or more first service nodes manually designated by a user, for example, a first service node corresponding to designated node information or a first service node with a designated node label, etc.
In one embodiment, the preset rule may further indicate one or more target images, wherein the plurality of target images may include: if the preset image space includes multiple target images, for example, the preset image space is designated as "test", one or more images under the preset image space may be used as target images to be preheated, for example, images whose image tag is "region. Sample/test/test 2:v1" or "region. Sample/test 2/test2:v2" may be used as target images, so as to reduce the operation of manually selecting the preheated images.
In one embodiment, the preset rule may further indicate one or more target images, wherein the plurality of target images may include: the multiple target images associated with the preset image, for example, multiple target images belonging to the image level corresponding to the preset image. For example, the image tag of the preset image may be designated as "registry. Example/test/test2", and the associated plurality of target images may be "registry. Example/test/test2:v1", "registry. Example/test/test2:v2" …, etc. belonging to the image level thereof.
In one embodiment, the preset rule may further indicate one or more target images, wherein one target image may include: one target image specified by the user, for example, a target image corresponding to one image tag specified by the user.
As shown in fig. 5, an embodiment of the present disclosure provides a container image preheating method, applied to a client, including:
s210: determining a first service node in a target cluster corresponding to the client based on an instruction of the server;
s220: configuring a task resource object based on node information of the first service node;
s230: indicating a task executor on the first service node to pull a target mirror image through the task resource object; and a preset rule exists between the target mirror image and the target cluster.
In the embodiment of the present disclosure, the target image to be processed may be a container image, such as a service change image, to be preheated onto a service node in the target cluster. The target cluster may be a user cluster such as a k8s cluster to be preheated, and a client (agent) may be deployed in the target cluster, for example, the client may be deployed on a master running (master) node of the target cluster.
The client is deployed in the target cluster in a preset Deployment mode (default), and can also establish connection with the server through a node port (nodeport) of the client as a service port for the server to call and access.
In one embodiment, the indication of the server may be a mirror preheat task issued by the server. The mirror image preheating task indicates that a target mirror image is pulled at the first service node. The mirror image preheating task can carry node information of the first service node.
In one embodiment, the task resource object (configmap) configured based on the node information of the first service node may include at least one of the following: based on node information of the first service node, cluster information of a target cluster where the first service node is located, mirror image information of a target mirror image, an address for receiving a preheating result, a service port for uploading the preheating result, and the like.
In one embodiment, the task resource object indicates, through the task resource object, that the task executor on the first service node pulls the target image, which may be for sending the task resource object to the first service node, or may be issued and then accessed by all service nodes in the target cluster. After the service nodes in the cluster access the task resource object, whether the service nodes are the first service node to be preheated or not can be determined based on the node information recorded in the task resource object.
In one embodiment, the method may further comprise: monitoring node events in a target cluster; if the node update event is monitored, node update information is sent to the server based on the node update condition. Wherein the node update event may include: node add events and/or node delete events. The node update information may include node addition or deletion information for the nodes in the cluster, which may include, for example, added or deleted node names and/or node IP addresses.
In one embodiment, the method may further comprise: and responding to the state checking request of the server, and checking the running state of the server.
In one embodiment, the method may further comprise: and deleting the task resource object within a preset time window after the task resource object is configured. For example, if the task resource object is not used or the number or frequency of use is lower than a preset threshold value within a predetermined time window after the completion of configuration, the task resource object is deleted.
In some embodiments, as shown in fig. 6, step S230 may include:
s231: and indicating a task executor on the first service node to pull the target image by using a local application container engine through the task resource object.
In the embodiment of the disclosure, the client may issue a task configmap for the service node to determine whether it is the first service node. The task executor of the first service node may be instructed to pull the target image through the local dock.
In some embodiments, the method further comprises:
monitoring events which are not processed by a local application container engine in the target cluster;
if the mirror image pulling event is monitored, determining node information of a second service node corresponding to the mirror image pulling event and mirror image information of a mirror image pulled by the second service node;
and sending the node information and the mirror image information of the second service node to the server, wherein the node information and the mirror image information of the second service node are at least used for generating a preset rule.
In the embodiment of the present disclosure, as shown in fig. 7, the event in the listening target cluster that is not processed by the local application container engine may be a pod resource object and/or an event object (event) in the listening target cluster. Monitoring for mirror pull events may include: when a new event is monitored, whether the event is a mirror pull event is determined.
Illustratively, event objects (event) are stored in a distributed key-value pair storage system (distributed etc directory, etcd) that record various events that occur as the cluster is operated upon, including mirrored pull events.
In one embodiment, determining the node information of the second service node corresponding to the mirror pull event and the mirror information of the second service node pull mirror may be based on the pod information corresponding to the mirror pull event, for example, based on a nodeName field of a pod information record, to obtain the node information (node name and/or node IP) of the second service node.
In one embodiment, sending node information and mirror information of the second service node to the server may include: and sending node information, mirror image information and cluster information of the cluster where the mirror image information is located of the second service node to the server.
In some embodiments, the preset rules at least indicate:
one or more target images; the plurality of target images includes: the method comprises the steps of presetting a plurality of target images contained in an image space and/or presetting a plurality of target images related by the images.
In the embodiment of the disclosure, the preset rule may include an automatic mirror image preheating rule or a manual mirror image preheating rule. Wherein the manual mirroring warm-up rule may indicate one or more first service nodes, including: all service nodes in the target cluster or one or more first service nodes manually designated by a user, for example, a first service node corresponding to designated node information or a first service node with a designated node label, etc.
In one embodiment, the preset rule may further indicate one or more target images, wherein the plurality of target images may include: if the preset image space includes multiple target images, for example, the preset image space is designated as "test", one or more images under the preset image space may be used as target images to be preheated, for example, images whose image tag is "region. Sample/test/test 2:v1" or "region. Sample/test 2/test2:v2" may be used as target images, so as to reduce the operation of manually selecting the preheated images.
In one embodiment, the preset rule may further indicate one or more target images, wherein the plurality of target images may include: the multiple target images associated with the preset image, for example, multiple target images belonging to the image level corresponding to the preset image. For example, the image tag of the preset image may be designated as "registry. Example/test/test2", and the associated plurality of target images may be "registry. Example/test/test2:v1", "registry. Example/test/test2:v2" …, etc. belonging to the image level thereof.
In one embodiment, the preset rule may further indicate one or more target images, wherein one target image may include: one target image specified by the user, for example, a target image corresponding to one image tag specified by the user.
As shown in fig. 8, an embodiment of the present disclosure provides a container mirror preheating device, which is applied to a server, and the device includes:
a query unit 110, configured to query at least one preset rule matching with a target image to be processed when a push event of the target image is detected;
a first determining unit 120, configured to determine target clusters associated with the preset rules, where each preset rule is associated with one target cluster;
and the indicating unit 130 is configured to instruct the client corresponding to the target cluster to pull the target image at the first service node.
In one embodiment, the query unit 110 is specifically configured to:
and inquiring at least one preset rule matched with the target image when receiving push event information which is sent by the image warehouse and indicates the target image to be processed.
In one embodiment, the apparatus further comprises:
the creating unit is used for creating at least one target cluster based on cluster information of at least one container resource management k8s cluster of the image to be preheated; and generating a preset rule associated with the target cluster based on node information in the target cluster and corresponding mirror image information received from the client.
In an embodiment, the creating unit is specifically configured to:
receiving node information of a second service node which is sent by the client and is used for pulling the mirror image and mirror image information of the second service node which is used for pulling the mirror image;
if a preset rule does not exist between the second service node and the mirror image information, determining a service node set associated with the second service node based on the node information and historical service deployment information;
and generating a preset rule associated with the target cluster based on the service node set and the mirror image information.
In one embodiment, the apparatus further comprises:
the processing unit is used for determining whether a preset rule exists between the mirror image information and other service nodes except the second service node if the preset rule exists between the second service node and the mirror image information;
when a preset rule exists between the mirror image information and the other service nodes, acquiring the pulling moment of the last pulling mirror image recorded by the second service node;
if the duration between the pulling time and the current time is greater than a preset value, deleting the preset rule between the mirror image information and the second service node;
And if the time length between the pulling time and the current time is smaller than or equal to a preset value, updating the pulling time of the last pulling mirror image recorded by the second service node.
In one embodiment, the preset rule at least indicates:
one or more target images; the plurality of target images includes: presetting a plurality of target images contained in an image space and/or presetting a plurality of target images related to the images;
as shown in fig. 9, an embodiment of the present disclosure provides a container image preheating device, applied to a client, including:
a second determining unit 210, configured to determine, based on an indication of a server, a first service node in a target cluster corresponding to the client;
a configuration unit 220, configured to configure a task resource object based on node information of the first service node;
a pulling unit 230, configured to instruct, through the task resource object, a task executor on the first service node to pull a target image; and a preset rule exists between the target mirror image and the target cluster.
In one embodiment, the pulling unit 230 is specifically configured to:
and indicating a task executor on the first service node to pull the target image by using a local application container engine through the task resource object.
In one embodiment, the apparatus further comprises:
the monitoring unit is used for monitoring events which are not processed by the local application container engine in the target cluster;
if the mirror image pulling event is monitored, determining node information of a second service node corresponding to the mirror image pulling event and mirror image information of a mirror image pulled by the second service node;
and sending the node information and the mirror image information of the second service node to the server, wherein the node information and the mirror image information of the second service node are at least used for generating a preset rule.
In one embodiment, the preset rule at least indicates:
one or more target images; the plurality of target images includes: the method comprises the steps of presetting a plurality of target images contained in an image space and/or presetting a plurality of target images related by the images.
The embodiment of the disclosure also provides an electronic device, which includes: a processor and a memory for storing a computer program capable of running on the processor, which when run performs the steps of the method of one or more of the preceding claims.
Embodiments of the present disclosure also provide a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, enable implementation of the method according to one or more of the foregoing technical solutions.
The computer storage medium provided in this embodiment may be a non-transitory storage medium.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above described device embodiments are only illustrative, e.g. the division of the units is only one logical function division, and there may be other divisions in practice, such as: multiple units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed. In addition, the various components shown or discussed may be coupled or directly coupled or communicatively coupled to each other via some interface, whether indirectly coupled or communicatively coupled to devices or units, whether electrically, mechanically, or otherwise.
The units described as separate units may or may not be physically separate, and units displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units; some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present disclosure may be integrated in one processing module, or each unit may be separately used as one unit, or two or more units may be integrated in one unit; the integrated units may be implemented in hardware or in hardware plus software functional units.
In some cases, the two technical features do not conflict, and a new method technical scheme can be combined.
In some cases, the above two technical features may be combined into a new device technical scheme without any conflict.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the above method embodiments may be implemented by hardware associated with program instructions, where the foregoing program may be stored in a computer readable storage medium, and when executed, the program performs steps including the above method embodiments; and the aforementioned storage medium includes: a mobile storage device, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk or an optical disk, or the like, which can store program codes.
The foregoing is merely specific embodiments of the disclosure, but the protection scope of the disclosure is not limited thereto, and any person skilled in the art can easily think about changes or substitutions within the technical scope of the disclosure, and it is intended to cover the scope of the disclosure. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.

Claims (12)

1. A method for preheating a container image, applied to a server, the method comprising:
inquiring at least one preset rule matched with the target image when a pushing event of the target image to be processed is detected;
determining target clusters associated with the preset rules, wherein each preset rule is associated with one target cluster;
and indicating the client corresponding to the target cluster to pull the target mirror image at the first service node.
2. The method of claim 1, wherein detecting a push event for a target image to be processed comprises:
and receiving push event information which is sent by the mirror image warehouse and indicates the target mirror image to be processed.
3. The method according to claim 1, wherein the method further comprises:
Creating at least one target cluster based on cluster information of at least one container resource management k8s cluster of the image to be preheated;
and generating a preset rule associated with the target cluster based on node information in the target cluster and corresponding mirror image information received from the client.
4. The method of claim 3, wherein the generating a preset rule associated with the target cluster based on node information in the target cluster received from the client and corresponding mirror information comprises:
receiving node information of a second service node which is sent by the client and is used for pulling the mirror image and mirror image information of the second service node which is used for pulling the mirror image;
if a preset rule does not exist between the second service node and the mirror image information, determining a service node set associated with the second service node based on the node information and historical service deployment information;
and generating a preset rule associated with the target cluster based on the service node set and the mirror image information.
5. The method according to claim 4, wherein the method further comprises:
if a preset rule exists between the second service node and the mirror image information, determining whether a preset rule exists between the mirror image information and other service nodes except the second service node;
When a preset rule exists between the mirror image information and the other service nodes, acquiring the pulling moment of the last pulling mirror image recorded by the second service node;
if the duration between the pulling time and the current time is greater than a preset value, deleting the preset rule between the mirror image information and the second service node;
and if the time length between the pulling time and the current time is smaller than or equal to a preset value, updating the pulling time of the last pulling mirror image recorded by the second service node.
6. The method of claim 1, wherein the preset rule indicates at least:
one or more target images; the plurality of target images includes: the method comprises the steps of presetting a plurality of target images contained in an image space and/or presetting a plurality of target images related by the images.
7. A method for preheating a container image, the method comprising:
determining a first service node in a target cluster corresponding to the client based on an instruction of the server;
configuring a task resource object based on node information of the first service node;
indicating a task executor on the first service node to pull a target mirror image through the task resource object; and a preset rule exists between the target mirror image and the target cluster.
8. The method of claim 7, wherein the indicating, by the task resource object, that the task executor on the first service node pulls the target image comprises:
and indicating a task executor on the first service node to pull the target image by using a local application container engine through the task resource object.
9. The method of claim 8, wherein the method further comprises:
monitoring events which are not processed by a local application container engine in the target cluster;
if the mirror image pulling event is monitored, determining node information of a second service node corresponding to the mirror image pulling event and mirror image information of a mirror image pulled by the second service node;
and sending the node information and the mirror image information of the second service node to the server, wherein the node information and the mirror image information of the second service node are at least used for generating a preset rule.
10. The method of claim 7, wherein the preset rule indicates at least:
one or more target images; the plurality of target images includes: the method comprises the steps of presetting a plurality of target images contained in an image space and/or presetting a plurality of target images related by the images.
11. An electronic device, the electronic device comprising: a processor and a memory for storing a computer program capable of running on the processor; wherein, the liquid crystal display device comprises a liquid crystal display device,
the processor, when running the computer program, performs the steps of the container image preheating method according to any one of claims 1 to 10.
12. A computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions; the computer executable instructions, when executed by a processor, are capable of implementing the container image warming method of any one of claims 1 to 10.
CN202211371803.9A 2022-11-03 2022-11-03 Container mirror image preheating method, electronic equipment and storage medium Pending CN116781719A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211371803.9A CN116781719A (en) 2022-11-03 2022-11-03 Container mirror image preheating method, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211371803.9A CN116781719A (en) 2022-11-03 2022-11-03 Container mirror image preheating method, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116781719A true CN116781719A (en) 2023-09-19

Family

ID=88008762

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211371803.9A Pending CN116781719A (en) 2022-11-03 2022-11-03 Container mirror image preheating method, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116781719A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117033325A (en) * 2023-10-08 2023-11-10 恒生电子股份有限公司 Mirror image file preheating and pulling method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117033325A (en) * 2023-10-08 2023-11-10 恒生电子股份有限公司 Mirror image file preheating and pulling method and device
CN117033325B (en) * 2023-10-08 2023-12-26 恒生电子股份有限公司 Mirror image file preheating and pulling method and device

Similar Documents

Publication Publication Date Title
US9965188B2 (en) Memory cleaning method and apparatus, and terminal device
CN107943594B (en) Data acquisition method and device
CN112087494B (en) Method for processing request, system on chip and public cloud management component
US9465603B2 (en) Application management apparatus, application management system, application management method, and non-transitory computer readable medium
CN116781719A (en) Container mirror image preheating method, electronic equipment and storage medium
US10320744B2 (en) Systems, devices, and methods for dynamic allocation of domain name acquisition resources
CN105871568B (en) Software upgrading method and system
CN114844879A (en) Mirror image management method, electronic device and storage medium
CN111625264B (en) Method, device, equipment and medium for upgrading multi-level management system
CN110798358B (en) Distributed service identification method and device, computer readable medium and electronic equipment
CN110381081B (en) Network access method and device and electronic equipment
CN109582487B (en) Method and apparatus for transmitting information
CN111126604A (en) Model training method, device, server and storage medium
CN110955460A (en) Service process starting method and device, electronic equipment and storage medium
CN115981670A (en) Container cluster service deployment method, device, server and storage medium
JP6439987B2 (en) Electronic device system and firmware update management program
CN110321251B (en) Data backup method, device, equipment and storage medium based on network block equipment
JP6320073B2 (en) Information processing apparatus, information processing method, and program
CN112685613A (en) Resource packet query method and device and information processing system
CN113438095A (en) Method, device and equipment for managing configuration data and storage medium
CN112804371B (en) Domain name resolution processing method and device
CN115514806B (en) Perception discovery method and system for discrete service cluster
CN114827127B (en) File management method, system, cloud server and terminal equipment
CN111339736B (en) Method for adding prefix name, configuration acquisition method, device and electronic equipment
CN113703866B (en) Configuration center information synchronization method and system

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