Message middleware storage method, computer program product and electronic device

By building container images of message middleware and local persistent storage volumes in Kubernetes environment, data loss caused by node drift is solved, and data persistence and consistency are achieved.

CN119557120APending Publication Date: 2025-03-04中国邮政储蓄银行股份有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411675272.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-03-04

AI Technical Summary

Technical Problem

In Kubernetes environment, message middleware node drift leads to data loss and mismatch.

Method used

By building container images of message middleware and creating local persistent storage volumes and stateful sets in Kubernetes clusters, ensure that the data of message middleware is stored in local persistent storage to avoid data loss.

Benefits of technology

It realizes the persistence and consistency of data when the message middleware node drifts, avoiding data loss and mismatch.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119557120A_ABST
    Figure CN119557120A_ABST
Patent Text Reader

Abstract

The invention provides a message middleware storage method, a computer program product and electronic equipment, and the method comprises the steps: constructing a container mirror image corresponding to message middleware, and obtaining a target container mirror image; the method comprises the following steps: creating a local persistent storage volume in a Kubernetes cluster to obtain a PV, and binding the PV with a working node in the Kubernetes cluster; according to the target container mirror image and the local persistent storage volume, a stateful set is created in a Kubernetes cluster, a PVC and a Pod instance are obtained, the PVC is bound with the Pod instance, the PVC is bound with the PV, the message middleware is stored in the local persistent storage volume, and the stateful set is used for deploying stateful application programs needing to be started in order. According to the method and the device, the problem of data loss and disorder caused by message middleware node drift in a Kubernetes environment in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of message middleware storage, and in particular to a storage method of message middleware, a computer-readable storage medium, a computer program product, and an electronic device. Background Art

[0002] Message middleware plays an important role in distributed systems. It can decouple the dependencies between different systems and improve the scalability and reliability of the system. Kubernetes is an open source container orchestration platform that can provide efficient, scalable and flexible solutions to meet the ever-changing application needs. With the development of enterprise business, deploying message middleware on Kubernetes and forming a Kubernetes cluster with other applications has gradually become a mainstream choice.

[0003] Message middleware needs to store business data, and the business data stored in each group of message middleware is not the same. As a stateful application, Kubernetes provides a stateful deployment (stateful set) method for message middleware. The node allocation strategy corresponding to the Pod is random. When the Pod application is scaled up or down, the application is redeployed, or restarted, the node where the Pod node is located will be reallocated, and node drift will occur. The business data, logs, and configuration files of the message middleware will be lost or disordered, and the message middleware Pod data involved will be lost and unable to provide services.

[0004] In the prior art, network file storage deployment, management and maintenance of Ceph, NFS (Network File System) and other network file storage systems are often used. In high-concurrency scenarios, the performance of the message middleware of some network file storage systems (HDFS (Hadoop Distributed File System), FastDFS (Fast Distributed File System), etc.) depends on the network bandwidth, which is not suitable for the low-latency message access requirements of the message middleware. Summary of the invention

[0005] The main purpose of the present application is to provide a storage method, a computer-readable storage medium, a computer program product and an electronic device for a message middleware, so as to at least solve the problem of data loss and confusion caused by message middleware node drift in a Kubernetes environment in the prior art.

[0006] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a storage method for a message middleware is provided, including: building a container image corresponding to the message middleware to obtain a target container image; creating a local persistent storage volume in the Kubernetes cluster to obtain PV (Persistent Volumes), and binding the PV to a working node in the Kubernetes cluster; creating a stateful set in the Kubernetes cluster according to the target container image and the local persistent storage volume to obtain PVC (Persistent Volume Claims) and a Pod instance, and binding the PVC to the Pod instance, and binding the PVC to the PV to store the message middleware in the local persistent storage volume, wherein the stateful set is used to deploy stateful applications that need to be started in an orderly manner.

[0007] Optionally, building a container image corresponding to the message middleware includes: adding the application package of the message middleware to the container image through a Dockerfile script command to obtain the target container image; creating state environment variables of the message middleware through the Dockerfile script command, the state environment variables including at least the naming of the instance in the message middleware, the master-slave relationship of the instance, and the cluster grouping; setting the storage path of the configuration file and message data of the message middleware in the target container image, the message data representing the data transmitted between the applications.

[0008] Optionally, creating a local persistent storage volume in a Kubernetes cluster includes: creating a local configuration file, wherein the local configuration file is the configuration file corresponding to the local persistent storage volume; determining the number of the PVs to be created, and creating the PVs according to the number of the PVs; and determining the local persistent storage volume according to the local configuration file and the PV.

[0009] Optionally, creating a local configuration file includes: creating a storage class used by the local persistent storage volume, and determining the local configuration file based on the storage class, and determining the number of PVs that need to be created, including: determining the number of PVs based on the number of instances to be deployed and the number of working nodes.

[0010] Optionally, a stateful set is created in the Kubernetes cluster based on the target container image and the local persistent storage volume, including: setting the container image used by the stateful set to the target container image; using the number of replicas in the configuration item of the stateful set to specify the number of instances to be deployed; dynamically assigning values ​​to the state environment variables; and mounting the storage path to the local persistent storage volume.

[0011] Optionally, dynamically assigning values ​​to the state environment variables includes: dynamically assigning values ​​to the state environment variables using an API (Application Programming Interface) object provided by the Kubernetes cluster.

[0012] Optionally, mounting the storage path to the local persistent storage volume includes: defining a persistent volume declaration template in the configuration item of the stateful set to automatically create the PVC when creating the Pod instance, and binding the Pod instance to the corresponding PVC, and automatically matching and binding the PVC to the corresponding PV.

[0013] According to another aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute any one of the message middleware storage methods.

[0014] According to another aspect of the present application, a computer program product is provided, comprising computer instructions, wherein when the computer instructions are executed by a processor, any one of the message middleware storage methods is implemented.

[0015] According to another aspect of the present application, an electronic device is provided, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include a storage method for executing any one of the message middlewares.

[0016] Applying the technical solution of this application, first build the container image corresponding to the message middleware, obtain the target container image, then create a local persistent storage volume in the Kubernetes cluster, obtain PV, and bind PV to the working node in the Kubernetes cluster, and finally create a stateful set in the Kubernetes cluster according to the target container image and the local persistent storage volume, obtain PVC and Pod instance, and bind PVC to Pod instance, and bind PVC to PV, so as to store the message middleware in the local persistent storage volume. Compared with the problem of data loss and confusion caused by the drift of message middleware nodes in the Kubernetes environment in the prior art, this application uses the local persistent storage volume of Kubernetes to store the data of the message middleware in the local persistent storage, designs the stateful set of the message middleware of Kubernetes, so as to automatically create Pod instances and PVC, and bind the Pod instance to PVC, that is, use the local persistent storage method, and use the characteristic that PVC will not be destroyed with the Pod node created accordingly, so as to ensure that even if the message middleware node drifts, it will not cause the data loss and confusion of the message middleware. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The drawings constituting part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0018] Figure 1 A hardware structure block diagram of a mobile terminal for executing a storage method of a message middleware provided in an embodiment of the present application is shown;

[0019] Figure 2 A schematic diagram of a storage method of a message middleware provided according to an embodiment of the present application is shown;

[0020] Figure 3 A diagram showing an example of a deployment of a storage method for a message middleware provided according to an embodiment of the present application is shown;

[0021] Figure 4 Shown with Figure 3 Schematic diagram of the resource status of the Kubernetes cluster after the pod node is scaled down in the corresponding deployment example.

[0022] The above drawings include the following reference numerals:

[0023] 102, processor; 104, memory; 106, transmission device; 108, input and output devices. DETAILED DESCRIPTION

[0024] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0025] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only 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 should fall within the scope of protection of the present application.

[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0027] As introduced in the background technology, in the prior art, the drift of message middleware nodes in the Kubernetes environment causes data loss and confusion. To solve the above problems, the embodiments of the present application provide a storage method, computer-readable storage medium, computer program product and electronic device for a message middleware.

[0028] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0029] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure diagram of a mobile terminal of a storage method of a message middleware according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.

[0030] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as computer programs corresponding to the storage method of the message middleware in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, the above method is implemented. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof. The transmission device 106 is used to receive or send data via a network. The above-mentioned specific network example may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0031] In this embodiment, a storage method for a message middleware running on a mobile terminal, a computer terminal or a similar computing device is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0032] Figure 2 1 is a flow chart of a storage method of a message middleware according to an embodiment of the present application. Figure 2 As shown, the method comprises the following steps:

[0033] Step S201, building a container image corresponding to the message middleware to obtain a target container image;

[0034] Step S202: Create a local persistent storage volume in the Kubernetes cluster, obtain PV, and bind the PV to the working node in the Kubernetes cluster.

[0035] Step S203: Create a stateful set in the Kubernetes cluster according to the target container image and the local persistent storage volume, obtain PVC and Pod instances, bind the PVC to the Pod instance, and bind the PVC to the PV to store the message middleware in the local persistent storage volume, wherein the stateful set is used to deploy stateful applications that need to be started in an orderly manner.

[0036] Through the above embodiment, first build the container image corresponding to the message middleware to obtain the target container image, then create a local persistent storage volume in the Kubernetes cluster to obtain PV, and bind PV to the working node in the Kubernetes cluster, and finally create a stateful set in the Kubernetes cluster according to the target container image and the local persistent storage volume, obtain PVC and Pod instance, and bind PVC to Pod instance, and bind PVC to PV, so as to store the message middleware in the local persistent storage volume. Compared with the problem of data loss and confusion caused by the drift of message middleware nodes in the Kubernetes environment in the prior art, this application uses the local persistent storage volume of Kubernetes to store the data of the message middleware in the local persistent storage, designs the stateful set of the message middleware of Kubernetes to automatically create Pod instances and PVC, and bind the Pod instance to PVC, that is, use the local persistent storage method, and use the characteristic that PVC will not be destroyed with the Pod node created accordingly, so as to ensure that even if the message middleware node drifts, it will not cause the data loss and confusion of the message middleware.

[0037] Specifically, message middleware: Message middleware is a supporting software system that provides synchronous or asynchronous, reliable message transmission for application systems in a network environment based on queue and messaging technology. Commonly used message middleware include RocketMQ, Kafka, RabbitMQ, etc. Kubernetes (k8s): A container orchestration engine that supports automated deployment, large-scale scalability, and application container management. PV: An abstraction of the underlying storage. It is not storage itself, but the storage address is specified in the resource inventory file for creating PV. It also specifies some storage parameters, such as some size, performance and other indicators. PVC: It is a declaration of storage requirements. PVC is a declaration of the use of PV. Pod: The smallest deployable computing unit of a group of one or more application containers. Container image: A packaging format used in containerization technology, which contains a complete application and all components and dependencies required for its operation.

[0038] In an optional solution, building a container image corresponding to the message middleware includes: adding the application package of the message middleware to the container image through the Dockerfile script command to obtain the target container image; creating the state environment variables of the message middleware through the Dockerfile script command, the state environment variables at least including the naming of the instance in the message middleware, the master-slave relationship of the instance, and the cluster grouping; setting the storage path of the configuration file and message data of the message middleware in the target container image, the message data represents the data transmitted between the application programs. In this embodiment, by using Dockerfile to build the container image, the consistency and portability of the message middleware in different environments can be ensured, and by setting the storage path of the message data and configuration files, it can be ensured that the message data and configuration files in the message middleware will not be lost when the container is restarted or migrated.

[0039] Specifically, Dockerfile: a script file used to build a Docker image.

[0040] Specifically, the conf or properties configuration file of the message middleware contains the configuration information of the message middleware, including the address of message persistence, instance naming, master-slave relationship, message expiration time, performance tuning configuration, etc. The configuration file is generally stored in the message middleware package, and the message data storage path is set to the data storage path.

[0041] According to some exemplary embodiments of the present application, creating a local persistent storage volume in a Kubernetes cluster includes: creating a local configuration file, the local configuration file being the configuration file corresponding to the local persistent storage volume; determining the number of the PVs to be created, and creating the PVs according to the number of the PVs; determining the local persistent storage volume according to the local configuration file and the PVs. In this embodiment, by creating a local configuration file, the local persistent storage volume can be flexibly configured and managed, so that the storage volume settings are more in line with the needs of the application, and by determining the number of PVs to be created, sufficient storage resources can be pre-allocated according to the scale and needs of the application, avoiding problems caused by insufficient storage resources during operation.

[0042] Specifically, LocalPV storage volume (i.e. local persistent storage volume): a Kubernetes persistent storage volume that represents a configured local storage device, such as a disk, partition, or directory. StorageClass (i.e. storage volume): an object in Kubernetes that is used to define the type and behavior of creating a persistent volume (PV) in a cluster. StorageClass can determine the provider of storage resources, the properties and behavior of storage volumes, and how to bind these storage volumes to dynamically allocated persistent volume requests.

[0043] Specifically, LocalPV can only be used as a statically created PV and does not support dynamic resource allocation. Compared with hostPath volumes, LocalPV is used in a persistent and portable manner without manually scheduling Pods to working nodes.

[0044] In other embodiments, creating a local configuration file includes: creating a storage class used by the above-mentioned local persistent storage volume, and determining the above-mentioned local configuration file based on the above-mentioned storage class, and determining the number of the above-mentioned PVs that need to be created, including: determining the number of the above-mentioned PVs based on the number of the above-mentioned instances to be deployed and the number of the above-mentioned working nodes. In this embodiment, by creating a storage class to determine the local configuration file, the most appropriate storage class can be selected for the local persistent storage volume according to the actual storage requirements and resource conditions. This can ensure the efficient use of storage resources and avoid waste or shortage of resources. The number of PVs is determined based on the number of message middleware instances to be deployed and the number of working nodes. This can ensure that each instance has corresponding storage resources, and can also flexibly adjust the allocation of storage resources according to the number of working nodes.

[0045] Specifically, to create a LocalPV storage volume, you first need to create the StorageClass (storage class) used, use kubernetes.io / no-provisioner (non-dynamic provisioner) as the Provisioner (resource provider), and set volumeBindingMode (volume binding mode) to WaitForFirstConsumer (wait for the first PVC); among them, the volume binding mode represents the binding method between PV and PVC, and waiting for the first PVC represents that the PV is not bound immediately after the PVC is created. It is necessary to wait for the first Pod instance to consume the PVC, and then dynamically create the PV according to the scheduling requirements of the Pod (such as node affinity), and bind the PV to the PVC.

[0046] Specifically, a node (i.e., a working node) is a host machine that provides a deployed Pod instance.

[0047] Specifically, the storage capacity, the node path to mount, and the node are set through the kubernetes yaml configuration file. After the PV is created, it will be bound to the node.

[0048] According to other exemplary embodiments of the present application, a stateful set is created in the above-mentioned Kubernetes cluster according to the above-mentioned target container image and the above-mentioned local persistent storage volume, including: setting the above-mentioned container image used by the above-mentioned stateful set to the above-mentioned target container image; using the number of replicas in the configuration item of the above-mentioned stateful set to specify the number of the above-mentioned instances to be deployed; dynamically assigning values ​​to the above-mentioned state environment variables; and mounting the above-mentioned storage path to the above-mentioned local persistent storage volume. In this embodiment, by combining the container image of the message middleware (i.e., the target container image) with the local persistent storage volume and setting the storage path in the stateful set, the data persistence of the message middleware can be ensured, and the data will not be lost even if the Pod is migrated or restarted, thereby further improving the reliability of the system.

[0049] Specifically, Kubernetes' Statefulset stateful controller (i.e., stateful set) is suitable for creating stateful applications such as message middleware that need to store message data. Use the yaml configuration file to configure the following points and other necessary configuration items. Creating a message middleware stateful controller can implement implementations that support application expansion and contraction, application redeployment, and restart.

[0050] According to an embodiment of the present disclosure, creating a Statefulset of a message middleware is divided into four key points: using a message middleware image (i.e., a target container image), setting the number of deployment instances, dynamically assigning values ​​to message middleware state environment variables, and mounting the storage in the message data and configuration file container to a LocalPV storage volume.

[0051] Specifically, in the stateful controller configuration item, spec.replicas (i.e., the number of copies) specifies the number of deployment instances, which is determined based on usage requirements.

[0052] Specifically, the message middleware is divided into a message middleware master node controller and a message middleware slave node controller according to the master and slave nodes of the message middleware.

[0053] In some other optional solutions of the present application, the state environment variables are dynamically assigned, including: using the API object provided by the Kubernetes cluster to dynamically assign the state environment variables. In this embodiment, the state environment variables are dynamically assigned through the API object provided by the Kubernetes cluster, which can realize the automatic management of the application configuration at runtime, which means that the configuration can be adjusted in real time according to the actual operation situation without manual intervention.

[0054] Specifically, the state environment variables to be assigned in the message middleware container are dynamically assigned: the naming (sharding) of the message middleware instance, the cluster grouping, etc. The dynamic assignment can use the API objects provided by Kubernetes, such as status.hostIP (the IP address of the host where the Pod is located), spec.nodeName (the node name of the Pod), metadata.name (the name of the Pod), etc., to dynamically set the state environment variables.

[0055] In some other optional schemes of the present application, the above storage path is mounted to the above local persistent storage volume, including: defining a persistent volume declaration template in the configuration item of the above stateful set, so as to automatically create the above PVC when creating the above Pod instance, and bind the above Pod instance to the corresponding above PVC, and automatically match and bind the above PVC to the corresponding above PV. In this embodiment, by defining a persistent volume declaration template in the configuration item of the stateful set, automatic management of storage resources is achieved, which means that when a Pod instance is created, the relevant PVC will also be automatically created, thereby simplifying the configuration and management of storage resources. The Pod instance is automatically bound to the corresponding PVC, ensuring that the Pod can access the expected storage resources. This automatic binding mechanism reduces the complexity of manual configuration and reduces the risk of data access problems caused by configuration errors.

[0056] Specifically, volumeClaimTemplates (i.e., persistent volume claim template): a field in StatefulSet that is used to define the persistent volume claim (PVC) template required for each Pod. This field allows us to automatically create and bind the corresponding PVC for each Pod in StatefulSet. In the volumeClaimTemplates field, multiple PVC templates can be defined, each of which contains the properties required to create a PVC, such as storage class, access mode, storage resource requirements, etc. When creating a Pod for StatefulSet, each Pod will use the PVC corresponding to it and mount it to the Pod's container, thereby realizing the use of persistent storage.

[0057] Specifically, by declaring volumeClaimTemplates in the configuration of StatefulSet, a corresponding PVC is automatically created when a message middleware stateful Pod instance is created. The message data storage path in the container is mounted on the PVC, thereby implementing this embodiment.

[0058] Figure 3 FIG. 1 shows an example diagram of a storage method for a message middleware according to an embodiment of the present application. Figure 3 As shown in the figure, there are 5 host machines available for deployment in the Kubernetes cluster: node1, node2, node3, node4, node5. PVs are created for these 5 host machines: pv1, pv2, pv3, pv4, pv5. In the initial state, the PV status is Available, which means that the PV has been created by the Kubernetes cluster administrator and has not been bound to any PVC. It can be used by any PVC request. The message middleware instance is created through the message middleware stateful deployment controller (i.e., stateful set). Figure 3 The example creates a message middleware cluster with two masters and two slaves. The two master nodes are MQ-m-pod1 and MQ-m-pod2, and the two slave nodes are MQ-s-pod1 and MQ-s-pod2. The stateful deployment controller creates the corresponding PVC while creating the pod (i.e. Pod) to mount the message data in the container to the PVC. The corresponding PVCs are pvc-m-1, pvc-m-2, pvc-s-1, and pvc-s-2 respectively. The PVC will automatically bind to the PV that meets the declaration conditions. Figure 3 In the example, the binding relationship between PVC and PV is: (pvc-m-1)->(pv1), (pvc-s-1)->(pv2), (pvc-m-2)->(pv3), (pvc-s-2)->(pv5). PV4 has no PVC bound to it. For the node bound to PVC and PV, the corresponding message middleware pod will be deployed to the host node (i.e., node) where the PV is located.

[0059] Figure 4 Hint Figure 3 The deployment example shows the resource status of the Kubernetes cluster after the pod node is scaled down. Figure 4As shown in the example, when the message middleware slave node is scaled down or destroyed, the instance of the slave pod node MQ-s-pod2 is destroyed, but the PVC used by the destroyed slave pod node: pvc-s-2 is not destroyed and remains bound to pv5, so the message data of the slave pod node MQ-s-pod2 is still stored on the node5 host storage. When the slave node is expanded and restored, the pod node MQ-s-pod2 is recreated, and the pvc-s-2 required by MQ-s-pod2 in the Kubernetes cluster will be remounted to the message data storage path of MQ-s-pod2, and the Kubernetes cluster deployment status is restored to Figure 3 shown.

[0060] Specifically, the LocalPV storage method is used, and the characteristic that PVC will not be destroyed along with the pod node created with it is utilized, so that the message middleware stateful service supports expansion and contraction, application redeployment, and restart, thus solving the problems of data loss and disorder.

[0061] Specifically, the local storage of the host machine is used as the storage of the message middleware using the LocalPV storage method of Kubernetes; the present invention does not need to configure network storage and has low requirements for storage devices; the host machine storage used by the storage device of the present invention does not consume network bandwidth when accessing data on the storage device, and the performance of the message middleware mainly depends on the local storage device IO (Input / Output), and the delay in accessing message data is low.

[0062] In order to enable those skilled in the art to more clearly understand the technical solution of the present application, the implementation process of the storage method of the message middleware of the present application will be described in detail below in combination with specific embodiments.

[0063] This embodiment relates to a specific storage method of message middleware, including the following steps:

[0064] Step S1: Build a container image corresponding to the message middleware to obtain a target container image: add the application package of the message middleware to the container image through the Dockerfile script command to obtain the target container image; create the state environment variables of the message middleware through the Dockerfile script command, the state environment variables at least include the naming of the instance in the message middleware, the master-slave relationship of the instance, and the cluster grouping; set the storage path of the configuration file of the message middleware and the message data in the target container image, the message data represents the data transmitted between the application programs;

[0065] Step S2: Create a local persistent storage volume in the Kubernetes cluster, obtain PV, and bind the PV to the working node in the Kubernetes cluster;

[0066] Step S3: Create a stateful set in the Kubernetes cluster according to the target container image and the local persistent storage volume, obtain PVC and Pod instances, bind the PVC to the Pod instance, and bind the PVC to the PV to store the message middleware in the local persistent storage volume. The stateful set is used to deploy stateful applications that need to be started in an orderly manner.

[0067] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0068] An embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the storage method of the message middleware.

[0069] Specifically, the storage method of the message middleware includes:

[0070] Step S201, building a container image corresponding to the message middleware to obtain a target container image;

[0071] Step S202: Create a local persistent storage volume in the Kubernetes cluster, obtain PV, and bind the PV to the working node in the Kubernetes cluster.

[0072] Step S203: Create a stateful set in the Kubernetes cluster according to the target container image and the local persistent storage volume, obtain PVC and Pod instances, bind the PVC to the Pod instance, and bind the PVC to the PV to store the message middleware in the local persistent storage volume, wherein the stateful set is used to deploy stateful applications that need to be started in an orderly manner.

[0073] Optionally, building a container image corresponding to the message middleware includes: adding the application package of the message middleware to the container image through the Dockerfile script command to obtain the target container image; creating the state environment variables of the message middleware through the Dockerfile script command, the state environment variables at least including the naming of the instance in the message middleware, the master-slave relationship of the instance and the cluster grouping; setting the storage path of the configuration file and message data of the message middleware in the target container image, the message data representing the data transmitted between the application programs.

[0074] Optionally, creating a local persistent storage volume in the Kubernetes cluster includes: creating a local configuration file, the local configuration file is the configuration file corresponding to the local persistent storage volume; determining the number of the above-mentioned PVs to be created, and creating the above-mentioned PVs according to the number of the above-mentioned PVs; determining the above-mentioned local persistent storage volume according to the above-mentioned local configuration file and the above-mentioned PV.

[0075] Optionally, creating a local configuration file includes: creating a storage class used by the above-mentioned local persistent storage volume, and determining the above-mentioned local configuration file based on the above-mentioned storage class, and determining the number of the above-mentioned PVs that need to be created, including: determining the number of the above-mentioned PVs based on the number of the above-mentioned instances to be deployed and the number of the above-mentioned working nodes.

[0076] Optionally, based on the target container image and the local persistent storage volume, a stateful set is created in the Kubernetes cluster, including: setting the container image used by the stateful set to the target container image; specifying the number of instances to be deployed using the number of replicas in the configuration item of the stateful set; dynamically assigning values ​​to the state environment variables; and mounting the storage path to the local persistent storage volume.

[0077] Optionally, dynamically assigning values ​​to the state environment variables includes: dynamically assigning values ​​to the state environment variables using an API object provided by the Kubernetes cluster.

[0078] Optionally, mounting the storage path to the local persistent storage volume includes: defining a persistent volume declaration template in the configuration item of the stateful set to automatically create the PVC when creating the Pod instance, and binding the Pod instance to the corresponding PVC, and automatically matching and binding the PVC to the corresponding PV.

[0079] The present application also provides a computer program product, including computer instructions, which, when executed by a processor, at least implement the following method steps:

[0080] Optionally, building a container image corresponding to the message middleware includes: adding the application package of the message middleware to the container image through the Dockerfile script command to obtain the target container image; creating the state environment variables of the message middleware through the Dockerfile script command, the state environment variables at least including the naming of the instance in the message middleware, the master-slave relationship of the instance and the cluster grouping; setting the storage path of the configuration file and message data of the message middleware in the target container image, the message data representing the data transmitted between the application programs.

[0081] Optionally, creating a local persistent storage volume in the Kubernetes cluster includes: creating a local configuration file, the local configuration file is the configuration file corresponding to the local persistent storage volume; determining the number of the above-mentioned PVs to be created, and creating the above-mentioned PVs according to the number of the above-mentioned PVs; determining the above-mentioned local persistent storage volume according to the above-mentioned local configuration file and the above-mentioned PV.

[0082] Optionally, creating a local configuration file includes: creating a storage class used by the above-mentioned local persistent storage volume, and determining the above-mentioned local configuration file based on the above-mentioned storage class, and determining the number of the above-mentioned PVs that need to be created, including: determining the number of the above-mentioned PVs based on the number of the above-mentioned instances to be deployed and the number of the above-mentioned working nodes.

[0083] Optionally, based on the target container image and the local persistent storage volume, a stateful set is created in the Kubernetes cluster, including: setting the container image used by the stateful set to the target container image; specifying the number of instances to be deployed using the number of replicas in the configuration item of the stateful set; dynamically assigning values ​​to the state environment variables; and mounting the storage path to the local persistent storage volume.

[0084] Optionally, dynamically assigning values ​​to the state environment variables includes: dynamically assigning values ​​to the state environment variables using an API object provided by the Kubernetes cluster.

[0085] Optionally, mounting the storage path to the local persistent storage volume includes: defining a persistent volume declaration template in the configuration item of the stateful set to automatically create the PVC when creating the Pod instance, and binding the Pod instance to the corresponding PVC, and automatically matching and binding the PVC to the corresponding PV.

[0086] An embodiment of the present application also provides an electronic device, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include a storage method for executing any one of the above-mentioned message middleware.

[0087] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.

[0088] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0089] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0090] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0091] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0092] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0093] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0094] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0095] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity 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, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0096] From the above description, it can be seen that the above embodiments of the present application achieve the following technical effects:

[0097] In the storage method of the message middleware of the present application, firstly, a container image corresponding to the message middleware is constructed to obtain the target container image, then a local persistent storage volume is created in the Kubernetes cluster to obtain the PV, and the PV is bound to the working node in the Kubernetes cluster, and finally, according to the target container image and the local persistent storage volume, a stateful set is created in the Kubernetes cluster to obtain the PVC and the Pod instance, and the PVC is bound to the Pod instance, and the PVC is bound to the PV, so as to store the message middleware in the local persistent storage volume. Compared with the problem of data loss and confusion caused by the drift of the message middleware node in the Kubernetes environment in the prior art, the present application uses the local persistent storage volume of Kubernetes to store the data of the message middleware in the local persistent storage, designs the stateful set of the message middleware of Kubernetes to automatically create the Pod instance and PVC, and binds the Pod instance to the PVC, that is, using the local persistent storage method, using the characteristic that the PVC will not be destroyed with the Pod node created accordingly, it is ensured that even if the message middleware node drifts, it will not cause the data loss and confusion of the message middleware.

[0098] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A storage method for message middleware, characterized in that: include: Build the container image corresponding to the message middleware and obtain the target container image; Create a local persistent storage volume in the Kubernetes cluster, obtain PV, and bind the PV to the working node in the Kubernetes cluster; According to the target container image and the local persistent storage volume, a stateful set is created in the Kubernetes cluster to obtain PVC and a Pod instance, and the PVC is bound to the Pod instance, and the PVC is bound to the PV to store the message middleware in the local persistent storage volume, wherein the stateful set is used to deploy stateful applications that need to be started in an orderly manner.

2. The storage method of message middleware according to claim 1, characterized in that: Build the container image corresponding to the message middleware, including: Add the application package of the message middleware to the container image through the Dockerfile script command to obtain the target container image; Creating state environment variables of the message middleware through the Dockerfile script command, wherein the state environment variables at least include the name of the instance in the message middleware, the master-slave relationship of the instance, and the cluster grouping; A configuration file of the message middleware and a storage path of message data in the target container image are set, wherein the message data represents data transmitted between the application programs.

3. The storage method of message middleware according to claim 2, characterized in that: Create a local persistent storage volume in the Kubernetes cluster, including: Creating a local configuration file, where the local configuration file is the configuration file corresponding to the local persistent storage volume; Determine the number of the PVs that need to be created, and create the PVs according to the number of the PVs; The local persistent storage volume is determined according to the local configuration file and the PV.

4. The storage method of message middleware according to claim 3, characterized in that: Creating a local configuration file includes: creating a storage class used by the local persistent storage volume, and determining the local configuration file according to the storage class, Determining the number of the PVs that need to be created includes: determining the number of the PVs according to the number of the instances that need to be deployed and the number of the working nodes.

5. The storage method of message middleware according to claim 4, characterized in that: Creating a stateful set in the Kubernetes cluster according to the target container image and the local persistent storage volume includes: Set the container image used by the stateful set to be the target container image; The number of instances to be deployed is specified using the number of replicas in the configuration item of the stateful set; Dynamically assigning values ​​to the state environment variables; Mount the storage path to the local persistent storage volume.

6. The storage method of message middleware according to claim 5, characterized in that: Dynamically assigning a value to the state environment variable includes: The state environment variables are dynamically assigned using the API object provided by the Kubernetes cluster.

7. The storage method of message middleware according to claim 6, characterized in that: Mounting the storage path to the local persistent storage volume includes: A persistent volume declaration template is defined in the configuration item of the stateful set to automatically create the PVC when the Pod instance is created, bind the Pod instance to the corresponding PVC, and automatically match and bind the PVC to the corresponding PV.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the message middleware storage method according to any one of claims 1 to 7.

9. A computer program product comprising computer instructions, characterized in that When the computer instructions are executed by a processor, the storage method of the message middleware described in any one of claims 1 to 7 is implemented.

10. An electronic device, characterized in that: include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include a storage method for executing the message middleware described in any one of claims 1 to 7.