Component upgrading method and device in K8s cluster and electronic equipment

By using adapter components to process and update the message body in the K8s cluster, the problem of service disconnection caused by POD component upgrade is solved, and normal maintenance of POD state and business continuity is achieved.

CN119512604AActive Publication Date: 2025-02-25CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1

Patent Information

Application Number
CN202411769104.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-02-25
Estimated Expiration
2044-12-04

AI Technical Summary

Technical Problem

When upgrading POD components in K8s clusters, it is easy to cause business disconnection among public cloud users.

Method used

The adapter component receives and processes the target message body set, ensuring that when the POD state changes, the adapter component updates the target message body set and sends the processed message body to the K8s cluster, keeping the POD state in a normal operating state.

Benefits of technology

It effectively avoids business disconnection during POD upgrade, ensuring that the K8s cluster does not trigger the relevant processing process when the POD status has not changed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512604A_ABST
    Figure CN119512604A_ABST
Patent Text Reader

Abstract

The invention provides a component upgrading method and device in a K8s cluster and electronic equipment, and relates to the technical field of cloud computing, and the method comprises the steps: receiving a target message body set through an adapter component under the condition that a component in a first container group POD in the K8s cluster is upgraded; obtaining a first message associated with the first POD from the target message body set through the adapter component; processing and packaging the first message through the adapter component according to the role to which the first POD belongs to obtain a first message body; and updating the target message body set through the adapter component, and sending the updated target message body set to the K8s cluster. According to the embodiment of the invention, when the component in the first POD is in the hot upgrade state, if the first POD is restarted or switched, the state of the first POD in the information acquired by the K8s cluster is not changed, so that the related processing of the K8s cluster on the service cannot be triggered, and the service cannot be disconnected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of cloud computing technology, and in particular to a component upgrading method, device and electronic device in a K8s cluster. Background Art

[0002] In the public cloud scenario, in order to provide better performance and higher service stability, cloud database MySQL is generally deployed in the K8s environment. The cloud MySQL instance ordered by the user is composed of multiple container groups (PODs) of K8s, and the functions of the instance and the database itself are encapsulated in the POD. These PODs are controlled by the custom resource definition (CRD) of the software vendor.

[0003] With the continuous iteration of functions, there is a need to upgrade the management components and some necessary functions in the POD of existing user instances. However, during the POD upgrade process, the POD status changes, resulting in business disconnection for public cloud users. Summary of the invention

[0004] The embodiments of the present application provide a component upgrade method, device and electronic device in a K8s cluster to solve the problem of business disconnection of public cloud users during the POD upgrade process.

[0005] To solve the above technical problems, this application is implemented as follows:

[0006] In a first aspect, an embodiment of the present application provides a component upgrade method in a K8s cluster, the method comprising:

[0007] In the case of a component upgrade in a first container group POD in a K8s cluster, a target message body set is received through an adapter component, wherein the target message body set includes a first message body set sent by the first component to the K8s cluster and a second message body set sent by the K8s cluster to the second component;

[0008] Acquire, by the adapter component, a first message associated with the first POD from the target message body set;

[0009] The first message is processed by the adapter component according to the role to which the first POD belongs, and the processed first message is encapsulated to obtain a first message body, where the first message body is used to indicate that the first POD is in a normal operating state;

[0010] The target message body set is updated through the adapter component, and the updated target message body set is sent to the K8s cluster, wherein the updated target message body set includes the first message body.

[0011] Optionally, receiving the target message body set through the adapter component includes:

[0012] In a case where the destination addressing of the K8s cluster is modified to the adapter component through the destination addressing component, receiving the first message body set sent by the first component to the K8s cluster through the adapter component;

[0013] In the case where the K8s cluster sends the second message body set to the second component, the second message body set hijacked and sent by the hijacking component is received through the adapter component.

[0014] Optionally, before receiving, through the adapter component, the first message body set sent by the first component to the K8s cluster, the method further includes:

[0015] Modify the destination addressing of the K8s cluster to the adapter component through the destination addressing component;

[0016] After updating the target message body set by the adapter component, the method further includes:

[0017] When the component upgrade in the first POD is completed, the destination addressing of the K8s cluster is modified from the adapter component to the K8s cluster through the target addressing component.

[0018] Optionally, before receiving, through the adapter component, the first message body set sent by the first component to the K8s cluster, the method further includes:

[0019] In the case of upgrading a component in a first container group POD in a K8s cluster, if the K8s cluster sends a second message body set to a second component, a hijacking operation is performed on the second message body set through the hijacking component, and the second message body set is sent to the adapter component;

[0020] After updating the target message body set by the adapter component, the method further includes:

[0021] When the component upgrade in the first POD is completed, the hijacking component is controlled to stop the hijacking operation.

[0022] Optionally, the target message body set is a first message body set sent by kubelet to the K8s cluster or a second message body set sent by the K8s cluster to the second component; the processing of the first message by the adapter component according to the role to which the first POD belongs includes any of the following:

[0023] When the role of the first POD is a master library and the first message indicates that the working state of the first POD is in a preset abnormal state, the working state in the first message is modified from the abnormal state to a normal operating state through the adapter component;

[0024] In a case where the role of the first POD is a standby database and the first POD includes a primary database tag, the first message is deleted from the target message body set through the adapter component.

[0025] Optionally, the target message body set is a first message body set sent by kubelet to the K8s cluster; after receiving the target message body set through the adapter component, the method further includes:

[0026] Acquire a second message associated with a second POD from the target message body set through the adapter component, where the second POD is a POD other than the first POD in the K8s cluster;

[0027] The adapter component encapsulates the second message according to the role of the second POD to obtain a second message body, where the second message body is used to indicate that the second POD is in a normal operating state;

[0028] The target message body set is updated through an adapter component, and the updated target message body set is sent to the K8s cluster, wherein the updated target message body set includes the second message body.

[0029] Optionally, the target message body set is a first message body set sent by the first POD to the K8s cluster; and the processing of the first message by the adapter component according to the role to which the first POD belongs includes:

[0030] In a case where the role of the first POD is the master library and the first message requests to maintain the state of the first POD as the master library state, the master library state of the first POD is updated through the adapter component.

[0031] Optionally, after updating the master library status of the first POD through the adapter component, the method further includes:

[0032] A response message for maintaining the state of the master library is sent to the first POD through the adapter component.

[0033] Optionally, the target message body set is a first message body set sent by the first POD to the K8s cluster; the method further includes:

[0034] When the role of the first POD is a standby database and the first message requests to switch the state of the first POD from a standby database state to a primary database state, a response message indicating that the request failed is sent to the first POD through the adapter component.

[0035] Optionally, before receiving the target message body set through the adapter component, the method further includes:

[0036] Acquire, through the adapter component, information of a target POD corresponding to the cloud database service information, where the target POD includes the first POD and the second POD;

[0037] A mapping relationship between the cloud database service information, the target POD information and the role to which the target POD belongs is established through the adapter component, and the role includes a primary database or a backup database.

[0038] In a second aspect, an embodiment of the present application provides a component upgrade device in a K8s cluster, the device comprising:

[0039] A receiving module, used for receiving a target message body set through an adapter component when a component in a first container group POD in a K8s cluster is upgraded, wherein the target message body set includes a first message body set sent by the first component to the K8s cluster and a second message body set sent by the K8s cluster to the second component;

[0040] A first acquisition module, configured to acquire a first message associated with the first POD from the target message body set through the adapter component;

[0041] a processing module, configured to process the first message according to the role to which the first POD belongs through the adapter component, and encapsulate the processed first message to obtain a first message body, wherein the first message body is used to indicate that the first POD is in a normal operating state;

[0042] The first sending module is used to update the target message body set through the adapter component and send the updated target message body set to the K8s cluster, wherein the updated target message body set includes the first message body.

[0043] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a memory, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, the steps of the component upgrade method in the K8s cluster described in the first aspect are implemented.

[0044] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the component upgrade method in the K8s cluster described in the first aspect are implemented.

[0045] In a fifth aspect, a computer program product is provided, comprising computer instructions, which, when executed by a processor, implement the steps of the component upgrade method in the K8s cluster as described in the first aspect.

[0046] In an embodiment of the present application, when a component in the first POD is in a hot upgrade state, if the first POD is restarted or the state is switched, since the state of the first POD in the information obtained by the K8s cluster has not changed, the K8s cluster will not be triggered to process the business, and thus the business will not be disconnected. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0048] Figure 1 It is a flowchart of a component upgrade method in a K8s cluster provided in an embodiment of the present application;

[0049] Figure 2 This is one of the flow diagrams during a component upgrade process in a K8s cluster provided in an embodiment of the present application;

[0050] Figure 3 This is the second flow diagram of a component upgrade process in a K8s cluster provided in an embodiment of the present application;

[0051] Figure 4 This is a flow diagram after a component upgrade in a K8s cluster is completed, provided in an embodiment of the present application;

[0052] Figure 5 It is a structural diagram of a component upgrading device in a K8s cluster provided in an embodiment of the present application;

[0053] Figure 6 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0054] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0055] Currently, there is a semi-synchronous replication solution for MySQL. It is not a cluster solution. It divides the database process into two roles: the master database and the standby database. The standby database starts an input / output process (IO) to pull binlogs from the master database to the local relay log file of the standby database through binlog dump. At the same time, it starts a slave process to replay the transactions in these binlogs. This solution assumes that the data consistency of the standby database is guaranteed as long as the IO process is completed synchronously. However, in the event of an abnormality in the master database, the user needs to specify the transaction replay progress of the standby database, and the switching operation can be completed only after the standby database replay is completed. Based on this, in order to achieve hot upgrade of cloud MySQL, it is necessary to ensure that the master and standby roles of cloud MySQL do not change.

[0056] The embodiments of the present application provide a component upgrade method, device and electronic device in a K8s cluster to solve the problem of business disconnection of public cloud users during the POD upgrade process.

[0057] See also Figure 1 , Figure 1 This is a flowchart of a component upgrade method in a K8s cluster provided in an embodiment of the present application. Figure 1 As shown, the method comprises the following steps:

[0058] Step 101: When a component in a first container group (POD) in a K8s cluster is upgraded, a target message body set is received through an adapter component, wherein the target message body set includes a first message body set sent by the first component to the K8s cluster and a second message body set sent by the K8s cluster to the second component;

[0059] Step 102: Obtain a first message associated with the first POD from the target message body set through the adapter component;

[0060] Step 103: Process the first message according to the role of the first POD through the adapter component, and encapsulate the processed first message to obtain a first message body, where the first message body is used to indicate that the first POD is in a normal operating state;

[0061] Step 104: Update the target message body set through the adapter component, and send the updated target message body set to the K8s cluster, wherein the updated target message body set includes the first message body.

[0062] The interaction between the Kubernetes (K8s for short) cluster and its components can be found in Figure 2 and Figure 3 As shown, Figure 2 It shows that the kubelet component and the components where the active and standby MySQL processes are located send messages to the K8s cluster. Figure 3 It shows that the kubelet component sends a message to the K8s cluster.

[0063] In some embodiments, during the component upgrade process in the first container group POD in the K8s cluster, the destination addressing of the K8s cluster is modified to the adapter component, so that the message sent by the first component (the kubelet component and the component where the master and standby MySQL processes are located) to the K8s cluster will be sent to the adapter component.

[0064] In other implementations, it can also be implemented in other ways. For example, during the upgrade of the first POD, the first component sends the message to be sent to the K8s cluster to the adapter component and the K8s cluster respectively according to the message type.

[0065] At the same time, if the K8s cluster sends a message to the second component (kubelet component), the message is hijacked by the traffic hijacking component and sent to the adapter component.

[0066] In the above manner, if the first component sends a first message body set to the K8s cluster, these messages are received by the adapter component; the second message body set sent by the K8s cluster to the second component is also received by the adapter component. The message body set may include multiple message bodies, which may include messages related to the first POD being upgraded, messages related to the second POD that is not in an upgraded state, and other messages that do not involve the first POD and the second POD.

[0067] After receiving the message body collection, the adapter obtains the message related to the first POD in the message body collection, and processes the message according to the primary and backup roles of the first POD. For example, if the message involves the first POD being upgraded, and if it indicates that the first POD is the primary library and is in an abnormal state, the message is processed so that the processed message indicates that the first POD is in normal operating state. In this way, when the first POD is hot upgraded and the high-availability component container is restarted, for the K8s cluster, the state of the first POD has not changed, and the K8s cluster's related processing procedures for the service and pod controller will not be triggered, thereby ensuring the normal processing of the business.

[0068] Optionally, in some embodiments, receiving the target message body set through the adapter component includes:

[0069] In a case where the destination addressing of the K8s cluster is modified to the adapter component through the destination addressing component, receiving the first message body set sent by the first component to the K8s cluster through the adapter component;

[0070] In the case where the K8s cluster sends the second message body set to the second component, the second message body set hijacked and sent by the hijacking component is received through the adapter component.

[0071] After the destination addressing of the K8s cluster is modified to the adapter component, when the first component sends a message to the K8s cluster, the adapter component receives the message.

[0072] When the K8s cluster sends a message to the second component, the traffic hijacking component hijacks the message and sends it to the adapter component.

[0073] In the above manner, the adapter component can receive messages between the K8s cluster and the first component and the second component.

[0074] Optionally, in some embodiments, before receiving, by the adapter component, the first message body set sent by the first component to the K8s cluster, the method further includes:

[0075] Modify the destination addressing of the K8s cluster to the adapter component through the destination addressing component;

[0076] After updating the target message body set by the adapter component, the method further includes:

[0077] When the component upgrade in the first POD is completed, the destination addressing of the K8s cluster is modified from the adapter component to the K8s cluster through the target addressing component.

[0078] When the component in the first POD is being upgraded or is about to be upgraded, the destination addressing of the K8s cluster is modified to the adapter component through the destination addressing component. After the upgrade is completed, the destination addressing of the K8s cluster is modified to the K8s cluster through the destination addressing component. In this way, during the upgrade process, the adapter component processes the message, so that the state of the first POD obtained by the K8s cluster is normal. After the upgrade is completed, the K8s cluster can communicate normally with the first component, such as Figure 4 shown.

[0079] Optionally, in some embodiments, before receiving, by the adapter component, the first message body set sent by the first component to the K8s cluster, the method further includes:

[0080] In the case of upgrading a component in a first container group POD in a K8s cluster, if the K8s cluster sends a second message body set to a second component, a hijacking operation is performed on the second message body set through the hijacking component, and the second message body set is sent to the adapter component;

[0081] After updating the target message body set by the adapter component, the method further includes:

[0082] When the component upgrade in the first POD is completed, the hijacking component is controlled to stop the hijacking operation.

[0083] When the component in the first POD is being upgraded, the hijacking component hijacks the second message body set sent by the K8s cluster to the second component and sends it to the adapter component. In this way, during the upgrade process, the adapter component processes the message, so that the state of the first POD obtained by the K8s cluster is normal. After the upgrade is completed, the hijacking component is controlled to stop hijacking, so that the K8s cluster can communicate normally with the first component. Figure 4 shown.

[0084] Optionally, in some embodiments, the target message body set is a first message body set sent by kubelet to the K8s cluster or a second message body set sent by the K8s cluster to the second component; the processing of the first message by the adapter component according to the role to which the first POD belongs includes any of the following:

[0085] When the role of the first POD is a master library and the first message indicates that the working state of the first POD is in a preset abnormal state, the working state in the first message is modified from the abnormal state to a normal operating state through the adapter component;

[0086] In the case where the role of the first POD is a standby database and the first POD includes a primary database tag, the first message is deleted from the target message body set through the adapter component.

[0087] If the role of the first POD involved in the first message is the main library, and the first message indicates that the working state of the first POD is an abnormal state. Among them, the preset abnormal state can be a state that may occur during the upgrade process, such as role state switching, restart, etc., and one or more abnormal states can be set according to actual conditions. For example, during the upgrade of the first POD, a high-availability component container (Container) will restart. When the restart occurs, an abnormal state will be indicated. The abnormal state in the first message is modified to a normal operating state through the adapter component.

[0088] If the role of the first POD involved in the first message is a backup database, and the first POD includes a master database tag, it means that the role of the first POD will be upgraded from a backup database to a master database. The adapter component is deleted from the target message body set, so that the role of the first POD will not be switched during the component upgrade process.

[0089] Optionally, in some embodiments, the target message body set is a first message body set sent by kubelet to the K8s cluster; after receiving the target message body set through the adapter component, the method further includes:

[0090] Acquire a second message associated with a second POD from the target message body set through the adapter component, where the second POD is a POD other than the first POD in the K8s cluster;

[0091] The adapter component encapsulates the second message according to the role of the second POD to obtain a second message body, where the second message body is used to indicate that the second POD is in a normal operating state;

[0092] The target message body set is updated through an adapter component, and the updated target message body set is sent to the K8s cluster, wherein the updated target message body set includes the second message body.

[0093] The adapter component obtains a second message from the target message body collection. The second message involves a second POD, and the second POD is a POD that is not in a hot upgrade state.

[0094] For the second message sent by kubelet to the K8s cluster, the second POD involved, the corresponding request is encapsulated according to the master and backup roles, forwarded to the K8s cluster, reports the normal status and normal status maintenance operations, and returns the request result of the K8s cluster to kubelet.

[0095] In this way, the second message of the POD not involved in the hot upgrade can report the normal status and will not affect the business.

[0096] Optionally, in some embodiments, the target message body set is a first message body set sent by the first POD to the K8s cluster; and the processing of the first message according to the role of the first POD by the adapter component includes:

[0097] In a case where the role of the first POD is the master library and the first message requests to maintain the state of the first POD as the master library state, the master library state of the first POD is updated through the adapter component.

[0098] In this way, it is possible to prevent state switching due to failure of the master database state maintenance logic.

[0099] Optionally, in some embodiments, after updating the master library status of the first POD through the adapter component, the method further includes:

[0100] A response message for maintaining the state of the master library is sent to the first POD through the adapter component.

[0101] While or after the adapter component maintains the information of the main database status, it can send a response message to the first POD to maintain the main database status, and send a message to the K8s cluster to maintain the main database status.

[0102] Optionally, in some embodiments, the target message body set is a first message body set sent by the first POD to the K8s cluster; the method further includes:

[0103] When the role of the first POD is a standby database and the first message requests to switch the state of the first POD from a standby database state to a primary database state, a response message indicating that the request failed is sent to the first POD through the adapter component.

[0104] When the first POD requests to switch the role of the first POD from the standby database to the primary database, the adapter component sends a response message of request failure to the first POD so that the first POD does not switch status during the upgrade process, thereby maintaining normal operation of the business.

[0105] Optionally, in some embodiments, before receiving the target message body set through the adapter component, the method further includes:

[0106] Acquire, through the adapter component, information of a target POD corresponding to the cloud database service information, where the target POD includes the first POD and the second POD;

[0107] A mapping relationship between the cloud database service information, the target POD information and the role to which the target POD belongs is established through the adapter component, and the role includes a primary database or a backup database.

[0108] For example, assuming that the name of the cloud MySQL instance is test, its primary POD is test-0, and its backup POD is test-1, based on the above information, the mapping relationship can be established as test-0->primary and test-1->backup.

[0109] In order to facilitate the understanding of the above embodiments, the embodiments of the present application are illustrated by means of specific embodiments below.

[0110] A high-availability component image hot upgrade solution in a k8 environment, which is based on the design of an adapter component and processes the K8s control layer of the instance POD based on the adapter. Among them, the adapter component is a self-developed role-based control adapter with the following functions.

[0111] (1) Subscribe to the POD information of the K8s cluster in real time and update it to the local queue of the adapter component.

[0112] (2) According to the information of the cloud MySQL instance, determine the POD to which it belongs and its role, and determine the mapping relationship between the POD name and the role. For example, suppose the cloud MySQL instance is named test, its primary POD is test-0, and its backup POD is test-1; go to (3)

[0113] (3) The adapter component initializes a memory mapping table that stores the mapping relationship between instance PODs and roles. For example, based on the above assumptions, the memory mapping table will store two pieces of data: test-0->master and test-1->backup.

[0114] (4) Determine and execute corresponding processing based on the received message body set.

[0115] If it comes from kubelet, go through all the contents one by one and handle them differently according to the PODs involved in the message body:

[0116] If the POD involved is an instance in the management component hot upgrade state, go to (5).

[0117] If the POD involved is not an instance in the management component hot upgrade state, go to (9);

[0118] If it does not come from kubelet, go to (6).

[0119] (5) This part of the content is processed based on the current active / standby role of the POD, and then encapsulated and added to the message body collection.

[0120] If the POD involved in the message body is the primary library, and the POD status in the kubelet information is abnormal or in a state change, modify this part of the message, change its status to normal, and then put it back into the message body collection. If the POD involved in the message body is the backup library, check whether there is a message in the message that adds the primary library tag to the backup library POD. If so, remove this part of the content and put it back into the message body collection. If not, do not process it.

[0121] For example, based on the assumption in (2) above, the corresponding POD information related to the cloud MySQL instance test in kubelet will be searched. If the message is test-0, it is determined that it belongs to the main database according to the memory mapping table. Then check whether the status report of test-0 has changed. If there is a change, remove the change, set its status to normal operation, and put it back to the message body collection after the role is still the main database. If the message is test-1, it can also be concluded that it is a backup database. At this time, it is necessary to check whether it has the main database logic message body. If so, remove it, modify it and put it back to the message body collection; go to (9)

[0122] (6) If the content of this part of the message body comes from POD, then traverse this part of the message body and perform different processing according to the different PODs in the content:

[0123] If the POD information is an instance in the management component hot upgrade state, go to (8);

[0124] If the POD information is not an instance in the management component hot upgrade state, go to (10);

[0125] If this part of the message body content does not come from POD, go to (7).

[0126] (7) If this part of the message body comes from the K8s cluster control layer outside the node, then this part comes from the communication between the K8s cluster and the kubelet. This part also encapsulates the message body according to different PODs and returns it to the K8s cluster. For specific logic, refer to (5).

[0127] (8) If the POD involved in the message body is the master database, the master database status maintenance logic requested by it returns a successful update to prevent the state switching due to the failure of the master database status maintenance logic, and synchronize the corresponding state maintenance operation to the K8s cluster. If it is a backup database, all the request logics for switching to the master database role return failure to prevent the original backup database role from being upgraded to the master database and being written by user business. No other processing is done; go to (11)

[0128] (9) Forward the corresponding component's request to the K8s cluster according to the role-encapsulated message body, report its normal status and normal status maintenance operations, and return the K8s cluster's request results to kubelet.

[0129] (10) This part of the message body is transparently transmitted to the K8s cluster, and the normal result of the K8s cluster is returned to the instance POD, completing the normal interaction between the non-upgraded instance POD and the K8s cluster.

[0130] (11) The processed results are returned to the instance POD being upgraded.

[0131] In addition, a traffic hijacking component is used to hijack the K8s control traffic outside the instance POD node and forward it to the adapter component to complete part (7) of the above functions;

[0132] The destination addressing modification component is used to modify the destination addressing of the communication between the node where the instance POD is located and K8s to the adapter component address. This ensures that the communication between the node and the K8s cluster is processed by the adapter and proceeds as expected.

[0133] See also Figure 2 and Figure 3 The client is the link that the user connects to, usually through the service. The client normally connects to the cloud MySQL master database process. During the hot upgrade process, the following operations are performed:

[0134] (1) The adapter component synchronizes data in the K8s cluster;

[0135] (2) Through the traffic hijacking component and the destination addressing component, all the traffic and message bodies at the K8s control layer on the node are forwarded to the adapter component for processing. The processing flow is as described in the functions (2)-(11) of the adapter component above. The core point is that at this time, all the traffic of the instance POD passes through the adapter component and is processed based on its role, so that the status and role of the POD in K8s are maintained unchanged during the entire upgrade process.

[0136] (3) Upgrade the image version of the high-availability component in the active and standby cloud MySQL POD. During this process, the high-availability component container will be restarted. However, for the K8s cluster, the status of the entire POD does not change, and the K8s cluster will not trigger the related processing flow of the service and pod controller.

[0137] (4) After the image version of the high-availability component in the active and standby cloud MySQL POD is upgraded, the traffic hijacking component and the destination addressing component will release the traffic hijacking, thereby converting the K8s control layer interaction link to a normal path; at this time, since client-go will reuse the existing connection, the K8s control layer interaction still goes through the adapter component.

[0138] (5) The adapter component actively releases the connection. Relying on the reconnection mechanism of client-go, the high-availability management component in the cloud MySQL instance POD communicates normally with the K8s cluster and begins to be managed by the K8s cluster again.

[0139] After the upgrade is complete, the cloud MySQL instance returns to normal status, and its network traffic is as follows Figure 4 shown.

[0140] Based on the above steps, during the upgrade of the entire cloud MySQL high-availability management component image, K8s will not perceive any abnormalities, so the user business data link will not change and will have no impact on user business.

[0141] In some hot upgrade methods, the image hot upgrade method of kruise defines a set of crds customized by the software, hijacks the processing flow of the crd through the informer mechanism and the K8s crd controller tuning technology, realizes the control of this type of crd and the POD resources it controls, and realizes the in-place upgrade of the POD image. To use this software, the crd that the product itself depends on must be the crd of the software. In this way, the product needs to be modified accordingly so that its corresponding crd can be perceived by kruise, which is invasive to the product architecture itself. Since the corresponding crd of kruise needs to be adapted, it means that the crd dependency of cloud MySQL needs to be changed accordingly. These modifications involve POD restarts, which fundamentally cannot complete the hot upgrade operation of the existing instance. In this method, kruise is implemented by tuning a specific crd, which is not applicable to the current cloud MySQL scenario. In addition, the container image upgrade in the kruise solution will cause the user service link to be disconnected, which is partly determined by the endpoint controller mechanism in the K8s controller manager.

[0142] In some hot upgrade methods, the virtual switch, as a network device, starts two virtual machine switch processes of different versions at the same time, and realizes the hot upgrade of the virtual machine switch by ensuring the backup of the data flow table and the flow transfer between the two versions. This method mainly realizes the synchronization of flow forwarding and routing. During the forwarding process, it is not guaranteed that the request of the lower version can be seamlessly switched to the upgraded process. There are upgrade disconnection operations during the upgrade process, which still have an impact on user services.

[0143] In other hot upgrade methods, the subsystems and dependent methods that the current kernel system depends on are replaced and upgraded independently. During the upgrade process, the entire kernel system is guaranteed to provide external services. When the subsystem upgrade is completed, the kernel subsystem is re-registered to achieve the upgrade of the kernel system. It is applied to scenarios where subsystem upgrades will not cause problems in the kernel system. It is mainly used in the upgrade process of eBPF type subsystems. These subsystems mainly implement scenarios that are unrelated to user business.

[0144] Since Cloud MySQL is deployed in the K8s environment, users access the instance master POD in the form of a service, and the high-availability management component runs in the user instance POD in the form of a sidercar. If you only upgrade the Cloud MySQL POD image version in situ, the master POD will change its state and the user will be aware of it by K8s. Further, K8s will be prompted to modify the service link, which will affect the user's business.

[0145] In the embodiment of the present application, during the upgrade process of the cloud MySQL high-availability management component image, the adapter component will encapsulate the message into a corresponding palindrome corresponding to the corresponding role and return it to the K8s cluster according to the role of the instance POD, so as to realize self-maintenance of the instance POD status during the hot upgrade of the management component, temporarily break away from the K8s control perception, and prevent the user service link from being disconnected.

[0146] In addition, this application also provides some processing methods to ensure that user service disconnection will not be affected during the upgrade of high-availability components.

[0147] For example, for cloud database instances running on K8s, their lifecycle management, including active-standby switching and high availability, does not use the informer mechanism. Instead, it uses direct API calls to achieve user-unawareness by calling scripts, thus not affecting user business.

[0148] For example, by cloning the POD of the high-version management component of the newly created instance, at the moment of POD switching, the middleware is used to implement functions such as partial database transaction migration to achieve low user business perception (short disconnection time). This solution is aware of user business and requires user business to implement thread pools or automatic connection disconnection and reconnection mechanisms.

[0149] See also Figure 5 , Figure 5 is a structural diagram of a component upgrade device in a K8s cluster provided in an embodiment of the present application, such as Figure 5 As shown, the component upgrade device 500 in the K8s cluster includes:

[0150] A receiving module 501 is used to receive a target message body set through an adapter component when a component in a first container group POD in a K8s cluster is upgraded, wherein the target message body set includes a first message body set sent by the first component to the K8s cluster and a second message body set sent by the K8s cluster to the second component;

[0151] A first acquisition module 502, configured to acquire a first message associated with the first POD from the target message body set through the adapter component;

[0152] The processing module 503 is used to process the first message according to the role of the first POD through the adapter component, and encapsulate the processed first message to obtain a first message body, where the first message body is used to indicate that the first POD is in a normal operating state;

[0153] The first sending module 504 is used to update the target message body set through the adapter component and send the updated target message body set to the K8s cluster, wherein the updated target message body set includes the first message body.

[0154] Optionally, the receiving module 501 includes:

[0155] A first receiving submodule is used for receiving, through the adapter component, the first message body set sent by the first component to the K8s cluster when the destination addressing of the K8s cluster is modified to the adapter component through the destination addressing component;

[0156] The second receiving submodule is used to receive the second message body set hijacked and sent by the hijacking component through the adapter component when the K8s cluster sends the second message body set to the second component.

[0157] Optionally, the device further comprises:

[0158] A first modification module, used to modify the destination addressing of the K8s cluster to the adapter component through the destination addressing component;

[0159] The device also includes:

[0160] The second modification module is used to modify the destination addressing of the K8s cluster from the adapter component to the K8s cluster through the target addressing component when the component upgrade in the first POD is completed.

[0161] Optionally, the device further comprises:

[0162] A hijacking module, used for, when a component in a first container group POD in a K8s cluster is upgraded, if the K8s cluster sends a second message body set to a second component, performing a hijacking operation on the second message body set through the hijacking component, and sending the second message body set to the adapter component;

[0163] The device also includes:

[0164] The control module is used to control the hijacking component to stop the hijacking operation when the component upgrade in the first POD is completed.

[0165] Optionally, the target message body set is a first message body set sent by kubelet to the K8s cluster or a second message body set sent by the K8s cluster to the second component; the processing module 503 includes any one of the following:

[0166] a modification submodule, configured to modify the working state in the first message from the abnormal state to a normal operating state through the adapter component when the role of the first POD is a master library and the first message indicates that the working state of the first POD is in a preset abnormal state;

[0167] The deletion submodule is used to delete the first message from the target message body set through the adapter component when the role of the first POD is a backup library and the first POD includes a primary library tag.

[0168] Optionally, the target message body set is a first message body set sent by kubelet to the K8s cluster; the device further includes:

[0169] A second acquisition module is used to acquire a second message associated with a second POD from the target message body set through the adapter component, where the second POD is a POD in the K8s cluster other than the first POD;

[0170] an encapsulation module, configured to encapsulate the second message through the adapter component according to the role to which the second POD belongs to obtain a second message body, wherein the second message body is used to indicate that the second POD is in a normal operating state;

[0171] The second sending module is used to update the target message body set through the adapter component, and send the updated target message body set to the K8s cluster, wherein the updated target message body set includes the second message body.

[0172] Optionally, the target message body set is a first message body set sent by the first POD to the K8s cluster; the processing module 503 is specifically used to:

[0173] In a case where the role of the first POD is the master library and the first message requests to maintain the state of the first POD as the master library state, the master library state of the first POD is updated through the adapter component.

[0174] Optionally, the device further comprises:

[0175] The third sending module is used to send a response message for maintaining the state of the main library to the first POD through the adapter component.

[0176] Optionally, the target message body set is a first message body set sent by the first POD to the K8s cluster; the device further includes:

[0177] The fourth sending module is used to send a response message of request failure to the first POD through the adapter component when the role of the first POD is a backup database and the first message requests to switch the state of the first POD from a backup database state to a primary database state.

[0178] Optionally, the device further comprises:

[0179] A third acquisition module is used to acquire information of a target POD corresponding to the cloud database service information through the adapter component, where the target POD includes the first POD and the second POD;

[0180] An establishment module is used to establish a mapping relationship between the cloud database service information, the target POD information and the role to which the target POD belongs through the adapter component, and the role includes a primary database or a backup database.

[0181] The component upgrade device in the K8s cluster can be implemented Figure 1 The various processes implemented in the method embodiment can achieve the same technical effect, and to avoid repetition, they will not be described again here.

[0182] The component upgrade device in the K8s cluster in the embodiment of the present application can be an electronic device, or a component in an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or it can be other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, etc., and can also be a server, a network attached storage (NAS), a personal computer (PC), etc., which is not specifically limited in the embodiment of the present application.

[0183] like Figure 6 As shown, an embodiment of the present application also provides an electronic device 600, including: a processor 601, a memory 602, and a program stored in the memory 602 and executable on the processor 601. When the program is executed by the processor 601, each process of the component upgrade method embodiment in the above-mentioned K8s cluster is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0184] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the component upgrade method embodiment in the above-mentioned K8s cluster is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. Among them, the computer-readable storage medium, such as read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0185] The present application also provides a computer program product, including computer instructions, which, when executed by a processor, implement the above Figure 1 The various processes of the method embodiment shown can achieve the same technical effect, and will not be described again here to avoid repetition.

[0186] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0187] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0188] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A component upgrade method in a K8s cluster, characterized in that: include: In the case of a component upgrade in a first container group POD in a K8s cluster, a target message body set is received through an adapter component, wherein the target message body set includes a first message body set sent by the first component to the K8s cluster and a second message body set sent by the K8s cluster to the second component; Acquire, by the adapter component, a first message associated with the first POD from the target message body set; The first message is processed by the adapter component according to the role to which the first POD belongs, and the processed first message is encapsulated to obtain a first message body, where the first message body is used to indicate that the first POD is in a normal operating state; The target message body set is updated through the adapter component, and the updated target message body set is sent to the K8s cluster, wherein the updated target message body set includes the first message body.

2. The method according to claim 1, characterized in that The receiving of the target message body set through the adapter component includes: In a case where the destination addressing of the K8s cluster is modified to the adapter component through the destination addressing component, receiving the first message body set sent by the first component to the K8s cluster through the adapter component; In the case where the K8s cluster sends the second message body set to the second component, the second message body set hijacked and sent by the hijacking component is received through the adapter component.

3. The method according to claim 2, characterized in that Before receiving, by the adapter component, the first message body set sent by the first component to the K8s cluster, the method further includes: Modify the destination addressing of the K8s cluster to the adapter component through the destination addressing component; After updating the target message body set by the adapter component, the method further includes: When the component upgrade in the first POD is completed, the destination addressing of the K8s cluster is modified from the adapter component to the K8s cluster through the target addressing component.

4. The method according to claim 2, characterized in that: Before receiving, by the adapter component, the first message body set sent by the first component to the K8s cluster, the method further includes: In the case of upgrading a component in a first container group POD in a K8s cluster, if the K8s cluster sends a second message body set to a second component, a hijacking operation is performed on the second message body set through the hijacking component, and the second message body set is sent to the adapter component; After updating the target message body set by the adapter component, the method further includes: When the component upgrade in the first POD is completed, the hijacking component is controlled to stop the hijacking operation.

5. The method according to any one of claims 1 to 4, characterized in that The target message body set is a first message body set sent by kubelet to the K8s cluster or a second message body set sent by the K8s cluster to the second component; the processing of the first message by the adapter component according to the role to which the first POD belongs includes any of the following: When the role of the first POD is a master library and the first message indicates that the working state of the first POD is in a preset abnormal state, the working state in the first message is modified from the abnormal state to a normal operating state through the adapter component; In a case where the role of the first POD is a standby database and the first POD includes a primary database tag, the first message is deleted from the target message body set through the adapter component.

6. The method according to any one of claims 1 to 4, characterized in that The target message body set is the first message body set sent by kubelet to the K8s cluster; After receiving the target message body set through the adapter component, the method further includes: Acquire a second message associated with a second POD from the target message body set through the adapter component, where the second POD is a POD other than the first POD in the K8s cluster; The adapter component encapsulates the second message according to the role of the second POD to obtain a second message body, where the second message body is used to indicate that the second POD is in a normal operating state; The target message body set is updated through an adapter component, and the updated target message body set is sent to the K8s cluster, wherein the updated target message body set includes the second message body.

7. The method according to any one of claims 1 to 4, characterized in that The target message body set is a first message body set sent by the first POD to the K8s cluster; The processing of the first message according to the role of the first POD by the adapter component includes: In a case where the role of the first POD is the master library and the first message requests to maintain the state of the first POD as the master library state, the master library state of the first POD is updated through the adapter component.

8. The method according to claim 5, characterized in that After updating the master library state of the first POD by the adapter component, the method further includes: A response message for maintaining the state of the master library is sent to the first POD through the adapter component.

9. The method according to any one of claims 1 to 4, characterized in that The target message body set is a first message body set sent by the first POD to the K8s cluster; the method further includes: When the role of the first POD is a standby database and the first message requests to switch the state of the first POD from a standby database state to a primary database state, a response message indicating that the request failed is sent to the first POD through the adapter component.

10. The method according to any one of claims 1 to 4, characterized in that Before receiving the target message body set through the adapter component, the method further includes: Acquire, through the adapter component, information of a target POD corresponding to the cloud database service information, where the target POD includes the first POD and the second POD; A mapping relationship between the cloud database service information, the target POD information and the role to which the target POD belongs is established through the adapter component, and the role includes a primary database or a backup database.

11. A component upgrade device in a K8s cluster, characterized in that: include: A receiving module, used for receiving a target message body set through an adapter component when a component in a first container group POD in a K8s cluster is upgraded, wherein the target message body set includes a first message body set sent by the first component to the K8s cluster and a second message body set sent by the K8s cluster to the second component; A first acquisition module, configured to acquire a first message associated with the first POD from the target message body set through the adapter component; a processing module, configured to process the first message according to the role to which the first POD belongs through the adapter component, and encapsulate the processed first message to obtain a first message body, wherein the first message body is used to indicate that the first POD is in a normal operating state; The first sending module is used to update the target message body set through the adapter component and send the updated target message body set to the K8s cluster, wherein the updated target message body set includes the first message body.

12. An electronic device, characterized in that: include: A processor, a memory, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, the steps of the component upgrade method in the K8s cluster as described in any one of claims 1 to 10 are implemented.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the component upgrade method in the K8s cluster as described in any one of claims 1 to 10.

14. A computer program product, characterized in that It includes computer instructions, which, when executed by a processor, implement the steps of the component upgrading method in the K8s cluster as described in any one of claims 1 to 10.

Citation Information

Patent Citations

  • Application updating method and apparatus used for host cluster and server device

    CN105975295A

  • A task processing method and apparatus

    CN109408220A

  • Task state updating method and device, equipment and medium

    CN113010385A

  • Component upgrading method and device in OpenStack, computer storage medium and system

    CN114610362A

  • Container information processing method and device, storage medium and electronic equipment

    CN116610691A

Cited By

  • Cross-platform scheduling method for heterogeneous privacy computing platform algorithm

    CN121029313A

  • A cross-platform scheduling method of heterogeneous privacy computing platform algorithms

    CN121029313B

  • Upgrade method and apparatus for components in k8s cluster, electronic device, storage medium, and computer program product

    WO2026118840A1