A method for publishing application messages based on k8s
By creating a configMap configuration file with the same name for each business application in the k8s environment and setting up a group configuration operator, the security issues of data sharing and message publishing in the microservice environment are solved, data isolation and security enhancement are achieved, and multiple Language configuration reduces middleware dependencies.
Patent Information
- Application Number
- CN202111157530.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-29
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2041-09-29
AI Technical Summary
Existing technology In a microservice environment, the cost of data information sharing and message publishing/subscription between services is high, and data usage is not secure enough, especially the risk of sensitive information leakage due to multiple business applications sharing the same configMap.
Group business applications by creating a configMap configuration file with the same name. Each group sets a group configuration operator. After obtaining and verifying business parameters, monitor and modify the configMap configuration file to ensure that data is only updated within the specified group and increase the security of data use. flexibility and reduce dependence on middleware.
It achieves safe isolation of data between different business applications, enhances the security of data use, and supports reading of configuration information in various languages, reducing dependence on middleware and improving the lightweight and flexibility of deployment.
Smart Images

Figure CN113886015B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of message publishing, and more specifically, the present invention relates to a method for publishing application messages based on k8s. Background Art
[0002] Kubernetes, referred to as k8s, is an important tool for orchestrating containers developed by Google. Currently, more and more business applications have been microserviced, and almost all business applications are deployed in containers. The current technical solutions have the following defects:
[0003] First, the purpose of microservices is to minimize the coupling of services, but this makes the cost of data information sharing and message publishing / subscription between services increasingly high. It is worth considering how to reduce the dependency between applications and cross-language support.
[0004] Second, current existing technologies usually use configMap to share data. Multiple business applications are mounted on the same configMap. For example, business application A and business application B are mounted on the same configMap. Some sensitive information needs to be written into the configMap of business application A. Since business application C is also mounted on the same configMap, business application C obtains the sensitive information of business application A. This shows that the use of data is highly dangerous. Summary of the invention
[0005] The purpose of the present invention is to provide a version upgrade method and a computer-readable storage medium to solve the technical problem of insufficient security in data usage in the above-mentioned prior art.
[0006] In order to achieve the above technical objectives, the technical solution adopted by the present invention is as follows:
[0007] A method for publishing application messages based on k8s, characterized in that it includes the following steps:
[0008] Create a business application and a configMap configuration file with the same name as the business application, group the business application and the configMap configuration file, and set a group configuration operator for each group;
[0009] Obtaining a first service parameter transmitted by the console or the service application, and performing authentication according to the first service parameter;
[0010] If the authentication is successful, call the API interface to monitor whether the group configuration operator has changed. If it has changed, modify the configMap configuration file;
[0011] Update the modified configMap configuration file to the directory specified by the container;
[0012] The business application monitors whether the configMap configuration file is updated, and if updated, consumes the message.
[0013] Preferably, the business applications and the configMap configuration files are grouped, and each group is provided with a group configuration operator, which specifically includes the following steps:
[0014] Several business applications and several configMap configuration files with the same name as the business applications are in the same group;
[0015] Each group is provided with a group configuration operator.
[0016] Preferably, the first service parameter includes a group configuration name, first application information and a first configuration key-value pair.
[0017] Preferably, obtaining the first service parameter transmitted by the console or the service application and performing authentication according to the first service parameter specifically includes the following steps:
[0018] Acquire a second service parameter from a database, where the second service parameter includes second application information and a second configuration key-value pair;
[0019] Determining whether the first application information and the second application information are the same;
[0020] If they are the same, continue to determine whether the first configuration key-value pair and the second configuration key-value pair belong to the same group;
[0021] If they belong to the same group, the authentication is successful.
[0022] Preferably, the method further comprises the steps of:
[0023] If the authentication is successful, determine whether the group configuration operator of the group where the first service parameter is located exists;
[0024] If it does not exist, create a group configuration operator for the group where the first service parameter is located; if it exists, call the API interface to monitor whether the group configuration operator changes.
[0025] Preferably, the method further comprises the steps of:
[0026] Determine whether the configMap configuration file corresponding to each business application in the group to which the group configuration operator belongs exists;
[0027] If it does not exist, create a configMap configuration file with the same name as the business application.
[0028] Preferably, calling the API interface to monitor whether the group configuration operator has changed, and if so, modifying the configMap configuration file, specifically includes the following steps:
[0029] The group configuration operator includes a configuration list, and the configuration list includes configuration information of a configMap configuration file;
[0030] Determine whether the configuration information of the configMap configuration file in the group to which the group configuration operator belongs has changed;
[0031] If there is a change, modify the configuration information of the configMap configuration file.
[0032] Preferably, determining whether the configuration information of the configMap configuration file in the group to which the group configuration operator belongs has changed specifically includes the following steps:
[0033] The configuration information includes a configuration name and a configuration value, and it is determined whether the configuration name is the same as the first service parameter. If they are not the same, the configuration name is modified;
[0034] Determine whether the configuration value is the same as the first service parameter; if not, modify the configuration value.
[0035] Preferably, it further comprises a group configuration controller, wherein the group configuration controller obtains a first service parameter transmitted by the console or the service application, and the group configuration controller performs authentication according to the first service parameter.
[0036] A computer-readable storage medium, characterized in that computer instructions are stored on the computer-readable storage medium, and the steps of the above-mentioned method are implemented when the computer instructions are executed by a processor.
[0037] The beneficial effects provided by the present invention are:
[0038] 1. The present invention groups business applications and configMap configuration files by creating business applications and configMap configuration files with the same name as the business applications. Each group is provided with a group configuration operator. Different business applications are only mounted on configMap configuration files with the same business application name. Therefore, data in different business applications are invisible to each other. When data needs to be modified, only the business applications and configMap configuration files of the specified group are modified, thereby increasing the security of data use.
[0039] 2. The present invention includes obtaining a first business parameter transmitted by a console or a business application, performing authentication according to the first business parameter, and if the authentication is passed, calling an API interface to monitor whether the group configuration operator changes. If it changes, the configMap configuration file is modified, and authentication is used to determine whether the user has the authority to modify the business application and the configMap configuration file, thereby further increasing the security of data use. At the same time, the business application can control the configuration information of other business applications in the group and the authentication of permissions.
[0040] 3. The group configuration operator of the present invention includes a configuration list, which includes configuration information of a configMap configuration file. The configuration information reduces the dependence on middleware, making the deployment lighter, and supports reading configuration information in various languages. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0042] Figure 1 It is a flow chart of the method of publishing application messages;
[0043] Figure 2 It is a workflow diagram of the group configuration operator and the group configuration controller. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0045] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0046] Embodiment 1:
[0047] like Figure 1 As shown, this embodiment includes a k8s-based application message publishing method, which is characterized by comprising the following steps:
[0048] Create a business application and a configMap configuration file with the same name as the business application, group the business application and configMap configuration file, and set a group configuration operator for each group;
[0049] Obtain the first business parameter passed by the console or business application, and perform authentication according to the first business parameter; if the authentication is successful, call the API interface to monitor whether the group configuration operator has changed, and if so, modify the configMap configuration file;
[0050] Update the modified configMap configuration file to the directory specified by the container; the business application monitors whether the configMap configuration file is updated. If updated, the message is consumed.
[0051] Business applications and configMap configuration files are grouped, and each group is provided with a group configuration operator, specifically including the following steps: a number of business applications and a number of configMap configuration files with the same business application name are in the same group; and a group configuration operator is provided for each group.
[0052] The first service parameter includes a group configuration name, first application information, and a first configuration key-value pair. Specifically, the first application information includes a first application name and a first application owner, and the first configuration key-value pair includes a first configuration name and a first configuration value.
[0053] It also includes a group configuration controller, which obtains a first business parameter transmitted by a console or a business application, and performs authentication according to the first business parameter.
[0054] Obtaining a first business parameter transmitted by a console or a business application, and performing authentication according to the first business parameter, specifically comprising the following steps: obtaining a second business parameter from a database, the second business parameter including second application information and a second configuration key-value pair;
[0055] Determine whether the first application information and the second application information are the same. If they are the same, continue to determine whether the first configuration key-value pair and the second configuration key-value pair belong to the same group; if they belong to the same group, the authentication is passed.
[0056] Specifically, the console or business application calls the group configuration controller according to the first business parameter, and the group configuration controller is hereinafter referred to as the GCM controller. The GCM controller obtains the first business parameter transmitted by the console or business application, and the first business parameter includes the group configuration name, the first application name, the first application owner, the first configuration name and the first configuration value.
[0057] The GCM controller obtains the second business parameter from the database, the second business parameter includes the second application information and the second configuration key-value pair, wherein the second application information includes the second application name and the second application owner, and the second configuration key-value pair includes the second configuration name and the second configuration value.
[0058] Determine whether the first application name and the second application name are the same. If they are not the same, it means that the authentication has not passed and the message cannot be published. If they are the same, it means that the first application name and the second application name belong to the same group. Then determine whether the first application owner and the second application owner are the same. If they are not the same, it means that the authentication has not passed and the message cannot be published. If they are the same, continue to determine whether the first configuration key-value pair and the second configuration key-value pair belong to the same group. If the first configuration key-value pair and the second configuration key-value pair do not belong to the same group, it means that the authentication has not passed and the message cannot be published. If the first configuration key-value pair and the second configuration key-value pair belong to the same group, the authentication passes. Specifically, if the first configuration name and the second configuration name belong to the same group, and the first configuration value and the second configuration value also belong to the same group, the authentication passes.
[0059] like Figure 2 As shown, the steps are also included: if the authentication is passed, determine whether the group configuration operator of the group where the first business parameter is located exists; if not, create the group configuration operator of the group where the first business parameter is located; if it exists, call the API interface to monitor whether the group configuration operator changes.
[0060] Specifically, the group configuration operator is hereinafter referred to as the CRD operator. It determines whether the CRD operator of the group exists according to the group configuration name in the first business parameter. If not, it creates the CRD operator of the group where the first business parameter is located. If it exists, it calls the API interface to monitor whether the CRD operator changes.
[0061] The method also includes the steps of: determining whether a configMap configuration file corresponding to each business application in the group to which the group configuration operator belongs exists; if not, creating a configMap configuration file with the same name as the business application.
[0062] Specifically, the CRD operator includes an application name list, and determines whether a configMap configuration file corresponding to each business application in the application name list exists; if not, a configMap configuration file with the same name as the business application is created.
[0063] Call the API interface to monitor whether the group configuration operator has changed. If it has changed, modify the configMap configuration file, which specifically includes the following steps: the group configuration operator includes a configuration list, and the configuration list includes the configuration information of the configMap configuration file; determine whether the configuration information of the configMap configuration file in the group to which the group configuration operator belongs has changed; if it has changed, modify the configuration information of the configMap configuration file.
[0064] Determine whether the configuration information of the configMap configuration file in the group to which the group configuration operator belongs has changed, specifically including the following steps: the configuration information includes a configuration name and a configuration value, determine whether the configuration name is the same as the first business parameter, if not, modify the configuration name; determine whether the configuration value is the same as the first business parameter, if not, modify the configuration value.
[0065] Specifically, the CRD operator includes a configuration list, the configuration list includes configuration information of the configMap configuration file, the configuration information includes a third configuration name and a third configuration value, and determines whether the first configuration name and the third configuration name are the same. If they are not the same, the third configuration name is modified according to the first configuration name; and determines whether the first configuration value and the third configuration value are the same. If they are not the same, the third configuration value is modified according to the first configuration value.
[0066] Specifically, the GCM controller is called through the software development kit, the GCM controller modifies the third configuration name according to the first configuration name, and the GCM controller modifies the third configuration value according to the first configuration value. At the same time, the second configuration name is updated in the database according to the third configuration name, and the second configuration value is updated according to the third configuration value.
[0067] Specifically, the API interface is called to monitor whether the configuration information of the configMap configuration file is updated. If updated, the API interface updates the modified configMap configuration file to the directory specified by the container. The business application includes a software development kit, which is hereinafter referred to as SDK. The SDK monitors whether the configuration information of the configMap configuration file is updated. If updated, the message is consumed to realize the publishing of messages between applications.
[0068] Embodiment 2:
[0069] A computer-readable storage medium stores computer instructions, which implement the steps of the method in Example 1 when executed by a processor.
[0070] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0071] The present invention is described with reference to the flowcharts and / or block diagrams of the method, terminal device (system), and computer program product according to the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks 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 terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal 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.
[0072] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including 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.
[0073] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0074] It should be noted that:
[0075] The "one embodiment" or "embodiment" mentioned in the specification means that the specific features, structures or characteristics described in conjunction with the embodiment are included in at least one embodiment of the present invention. Therefore, the phrases "one embodiment" or "embodiment" appearing in various places throughout the specification do not necessarily refer to the same embodiment.
[0076] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0077] In addition, it should be noted that the shapes and names of the parts and components of the specific embodiments described in this specification may be different. Any equivalent or simple changes made based on the structure, features and principles described in the patent concept of the present invention are included in the protection scope of the patent of the present invention. The technicians in the technical field of the present invention can make various modifications or supplements to the specific embodiments described or replace them in a similar manner, as long as they do not deviate from the structure of the present invention or exceed the scope defined by the claims, they should all fall within the protection scope of the present invention.
Claims
1. A method for publishing application messages based on k8s. It is characterized in that The following steps are involved: Create a business application and a configMap configuration file with the same name as the business application, group the business application and the configMap configuration file, and set a group configuration operator for each group; Obtaining a first service parameter transmitted by the console or the service application, and performing authentication according to the first service parameter; If the authentication is successful, call the API interface to monitor whether the group configuration operator has changed. If it has changed, modify the configMap configuration file; Update the modified configMap configuration file to the directory specified by the container; The business application monitors whether the configMap configuration file is updated, and if updated, consumes the message; The business applications and the configMap configuration files are grouped, and each group is provided with a group configuration operator, which specifically includes the following steps: Several business applications and several configMap configuration files with the same name as the business applications are in the same group; Each group is provided with a group configuration operator; Call the API interface to monitor whether the group configuration operator has changed. If it has changed, modify the configMap configuration file, which specifically includes the following steps: The group configuration operator includes a configuration list, and the configuration list includes configuration information of a configMap configuration file; Determining whether the configuration information of the configMap configuration file in the group to which the group configuration operator belongs has changed includes: The configuration information includes a configuration name and a configuration value, and it is determined whether the configuration name is the same as the first service parameter. If they are not the same, the configuration name is modified; Determine whether the configuration value is the same as the first service parameter, and if not, modify the configuration value; If there is a change, modify the configuration information of the configMap configuration file; The method further comprises: Determine whether the configMap configuration file corresponding to each business application in the group to which the group configuration operator belongs exists; If it does not exist, create a configMap configuration file with the same name as the business application.
2. A method for publishing application messages based on k8s as claimed in claim 1, It is characterized in that The first service parameter includes a group configuration name, first application information, and a first configuration key-value pair.
3. A k8s-based application message publishing method as described in claim 2, It is characterized in that Get the console or The first service parameter transmitted by the service application is authenticated according to the first service parameter, specifically comprising the following steps: Acquire a second service parameter from a database, where the second service parameter includes second application information and a second configuration key-value pair; Determining whether the first application information and the second application information are the same; If they are the same, continue to determine whether the first configuration key-value pair and the second configuration key-value pair belong to the same group; If they belong to the same group, the authentication is successful.
4. A method for publishing application messages based on k8s as claimed in claim 1, It is characterized in that Also includes the steps: If the authentication is successful, determine whether the group configuration operator of the group where the first service parameter is located exists; If it does not exist, create a group configuration operator for the group where the first service parameter is located; if it exists, call the API interface to monitor whether the group configuration operator changes.
5. A k8s-based application message publishing method as claimed in claim 1, It is characterized in that It also includes a group configuration controller, which obtains a first service parameter transmitted by the console or the service application, and performs authentication according to the first service parameter.
6. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, which, when executed by a processor, implement the steps of the k8s-based application message publishing method as described in any one of claims 1 to 5.
