Container injection methods, apparatus, electronic devices, systems and storage media

By intercepting and parsing container group creation requests from microservice clients, obtaining and adding companion container configuration information, the inflexibility of Istio injection methods is resolved, enabling personalized companion container injection and reducing resource waste.

CN116866165BActive Publication Date: 2026-11-17JD DIGITS HAIYI INFORMATION TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310622783.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-29
Publication Date
2026-11-17
Estimated Expiration
2043-05-29

AI Technical Summary

Technical Problem

The existing Istio method for injecting companion containers into container groups is not flexible enough and cannot meet the personalized needs of different microservices, resulting in wasted resources.

Method used

By intercepting the container group creation request of the microservice client, parsing the original container configuration information, obtaining the current configuration information of the companion container from the configuration server, adding the configuration information of the companion container to the original container configuration information, generating the container configuration target information, and sending it to the microservice server to inject the companion container.

Benefits of technology

It enables the injection of companion containers based on the personalized needs of microservices, reducing resource waste and improving the flexibility of the injection method.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116866165B_ABST
    Figure CN116866165B_ABST
Patent Text Reader

Abstract

This invention provides a container injection method, apparatus, electronic device, system, and storage medium. The container injection method includes: intercepting a container group creation request initiated by a microservice client; parsing the container group creation request to obtain the original container configuration information of the current microservice; obtaining the current configuration information of the companion container of the current microservice from a configuration server; adding the current configuration information of the companion container to the original container configuration information to obtain the container configuration target information of the current microservice; and sending the container configuration target information to the microservice server, so that the microservice server injects the companion container into the container group of the current microservice according to the container configuration target information. This invention uses service-level configuration for companion container injection. Different microservices can be configured with different companion containers or have different companion container configuration information, making the injection method more flexible, meeting the personalized needs of different microservices, and reducing resource waste.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of microservice management technology, and in particular to a container injection method, apparatus, electronic device, system and storage medium. Background Technology

[0002] Istio is an open-source service mesh that helps establish connections between microservices. Istio can be installed in container cluster management systems (Kubernetes, K8s) to assist in managing and monitoring microservices. Containers are the implementation carriers of microservices. In addition to their main business functions, microservices typically require a set of related peripheral functions, such as monitoring, logging, and permission management. The main business functions can be implemented through the main container, while peripheral functions can be implemented through companion containers. Istio allows the injection of companion containers into microservice pods.

[0003] In the process of implementing this invention, the inventors discovered that injecting companion containers into container groups using Istio is usually done by namespace. A namespace typically has multiple container groups, and these container groups in a namespace will inject companion containers with the same configuration. However, different microservices may have different requirements for companion containers and their configurations. Istio's injection method is not flexible enough and cannot meet the personalized needs of different microservices, resulting in a waste of resources. Summary of the Invention

[0004] This invention provides a container injection method, apparatus, electronic device, system, and storage medium that can meet the personalized needs of different microservices and reduce resource waste.

[0005] In a first aspect, the container injection method provided in the embodiments of the present invention includes:

[0006] Intercept container group creation requests initiated by microservice clients;

[0007] Parse the container group creation request to obtain the original container configuration information of the current microservice;

[0008] Obtain the current configuration information of the companion container of the current microservice from the configuration server;

[0009] Add the current configuration information of the companion container to the original container configuration information to obtain the container configuration target information of the current microservice;

[0010] The container configuration target information is sent to the microservice server so that the microservice server injects the companion container into the container group of the current microservice according to the container configuration target information.

[0011] Secondly, the container injection device provided in the embodiments of the present invention includes:

[0012] The interception module is used to intercept container group creation requests initiated by microservice clients;

[0013] The parsing module is used to parse the container group creation request to obtain the original container configuration information of the current microservice;

[0014] The acquisition module is used to obtain the current configuration information of the companion container of the current microservice from the configuration server;

[0015] An add module is used to add the current configuration information of the companion container to the original container configuration information to obtain the container configuration target information of the current microservice;

[0016] The sending module is used to send the container configuration target information to the microservice server, so that the microservice server injects the companion container into the container group of the current microservice according to the container configuration target information.

[0017] Thirdly, the electronic device provided in the embodiments of the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the container injection method as described in any embodiment of the present invention.

[0018] Fourthly, the container injection system provided in the embodiments of the present invention includes a microservice client, a microservice server, a configuration server, and an electronic device for executing the container injection method as described in any embodiment of the present invention.

[0019] Fifthly, the computer-readable storage medium provided in the embodiments of the present invention stores a computer program thereon, which, when executed by a processor, implements the container injection method as described in any embodiment of the present invention.

[0020] The solution of this invention can intercept container group creation requests initiated by microservice clients, parse the container group creation requests to obtain the original container configuration information of the current microservice, obtain the current configuration information of the companion container of the current microservice from the configuration server, add the current configuration information of the companion container to the original container configuration information to obtain the container configuration target information of the current microservice, and send the container configuration target information to the microservice server so that the microservice server can inject the companion container into the container group of the current microservice according to the container configuration target information. This invention can obtain the current configuration information of the companion container of the current microservice from the configuration server, and then achieve the injection of the companion container by modifying the original container configuration information. That is, this invention uses service-level configuration for companion container injection. Different microservices can configure different companion containers or have different companion container configuration information. Compared with injecting companion containers according to namespaces, the injection method of this invention is more flexible, can meet the personalized needs of different microservices, and reduce resource waste. Attached Figure Description

[0021] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0022] Figure 1 This is a flowchart illustrating a container injection method provided in an embodiment of the present invention. Figure 1 ;

[0023] Figure 2 This is a flowchart illustrating a container injection method provided in an embodiment of the present invention. Figure 2 ;

[0024] Figure 3 This is a schematic diagram illustrating the effect of a specific configuration information provided in an embodiment of the present invention;

[0025] Figure 4 This is a schematic diagram illustrating the effect of default configuration information provided in an embodiment of the present invention;

[0026] Figure 5 This is a flowchart illustrating a container update method provided in an embodiment of the present invention;

[0027] Figure 6 This is a schematic diagram of the container injection device provided by the present invention;

[0028] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0029] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0030] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0031] In the embodiments of the present invention, the technical solution can be applied to various container cluster management systems, such as the Kubernetes (K8s) system. In the following description, the technical solution of the embodiments of the present invention will be described using the K8s system as an example; however, it should be noted that the technical solution of the embodiments of the present invention is not limited to the K8s system.

[0032] like Figure 1 As shown, Figure 1 This is a flowchart illustrating a container injection method provided in an embodiment of the present invention. Figure 1 The container injection method provided in this embodiment of the invention can be executed by the container injection device provided in this embodiment of the invention, which can be implemented in software and / or hardware. In a specific embodiment, the device can be integrated into an electronic device, such as a computer or server. The electronic device can be equipped with an admission controller (e.g., a webhook), which can include a mutating admission webhook and a validating admission webhook. This embodiment will be described in detail from the following steps.

[0033] S101. Intercept container group creation requests initiated by microservice clients.

[0034] Specifically, when a microservice client (which can be a Kubernetes client) needs to create a container group, it can send a container group creation request to the microservice server (which can be a Kubernetes server). Electronic devices can intercept the container group creation request sent by the microservice client.

[0035] In this embodiment, the application or system can be composed of multiple microservices, each of which can be deployed independently and is loosely coupled. Each microservice can focus on and complete a single task. For example, an e-commerce platform can be deployed as microservices, which may include user services, payment services, warehousing services, and information services. Each microservice can focus on only one specific business function to simplify the development and maintenance of the application or system.

[0036] A Pod is the smallest scheduling unit in Kubernetes. Each Pod is a running instance of a specific application. A Pod can contain multiple containers. The containers in a Pod can be divided into two categories: main containers and companion containers. The main containers are used to implement the main business functions of the microservice, while companion containers are used to implement the peripheral functions required by the microservice.

[0037] S102. Parse the container group creation request to obtain the original container configuration information of the current microservice.

[0038] In practice, electronic devices can use the change admission controller to parse container group creation requests and obtain the original container configuration information of the current microservice. This original container configuration information may include the current configuration information of the main container of the current microservice. Of course, it may also include other necessary information required to create the container group; this is not specifically limited here. For example, the original configuration information of the main container of the current microservice may include the container version, the memory required by the running instance of the container, and the Central Processing Unit (CPU).

[0039] S103. Obtain the current configuration information of the companion container of the current microservice from the configuration server.

[0040] In this embodiment, the electronic device can obtain the current configuration information of the companion container of the current microservice from the configuration server. The current configuration information of the companion container may include, but is not limited to, memory configuration information, CPU configuration information, or version configuration information.

[0041] Specifically, the current configuration information of the companion container can exist in the form of cr. cr is a built-in resource type in Kubernetes. This type of resource is mainly used to create user-defined resource types. That is, through cr resources, user-defined resource types can be converted into resource types on Kubernetes.

[0042] In this embodiment, an e-commerce platform consists of multiple microservices. Each microservice deploys services that implement basic business functions through a main container and peripheral functions through a companion container. For example, in the payment service of the e-commerce platform, the main container implements the payment function, and the companion container implements permission verification within the payment function.

[0043] In Kubernetes (K8s) systems, companion containers are a widely used architectural pattern in K8s applications. One or more companion containers can be deployed alongside each main container to address common cross-cutting concerns across different applications. For example, the Istio service mesh uses companion containers to intercept and forward application network traffic, and a monitoring agent uses companion containers to collect data from business applications, etc.

[0044] S104. Add the current configuration information of the companion container to the original container configuration information to obtain the target container configuration information of the current microservice.

[0045] In this embodiment, the current configuration information of the companion container is added to the original container configuration information. That is, the configuration of the companion container is added to the configuration including the main container to obtain the container configuration target information of the current microservice. Specifically, the current configuration information of the companion container can be added as an annotation to the original container configuration information. The current configuration information of the companion container and the current configuration information of the main container of the current microservice constitute the container configuration target information of the current microservice.

[0046] S105. Send container configuration target information to the microservice server so that the microservice server can inject the companion container into the container group of the current microservice according to the container configuration target information.

[0047] In an embodiment of the present invention, after modifying the configuration information in the container group creation request using the change admission controller, the container configuration target information of the current microservice can be sent to the microservice server, so that the microservice server injects the companion container into the container group of the current microservice according to the container configuration target message.

[0048] Specifically, before sending the container configuration target information to the microservice server, the verification admission controller can be used to verify the container configuration target information. If the verification passes, the container configuration target information can then be sent to the microservice server to improve the container injection success rate.

[0049] In an embodiment of the present invention, after receiving the container configuration target information, the microservice server can parse the container configuration target information to make the current configuration information of the companion container in the container configuration target information effective. Then, it can add template-related configuration information as needed, but will not overwrite or superimpose the current configuration information of the companion container, and configure to obtain the final container configuration information. Finally, the companion container and the main container are injected into the container group of the current microservice according to the final container configuration information.

[0050] In embodiments of the present invention, different companion containers can be injected into different microservices, or the same companion container can be injected into different microservices. However, the configuration of the companion container can be different, depending on the business functions or peripheral functions required by each microservice. The configuration of the companion container includes version configuration, memory configuration, and CPU configuration, etc.

[0051] Figure 2 A flowchart illustrating a container injection method provided by the present invention. Figure 2 .exist Figure 2 In the process, the microservice client initiates a container group creation request, triggering a change admission controller for admission control. It first determines whether a companion container needs to be injected into the container group (i.e., whether it matches; if so, it doesn't). If so, it accesses the mesh service's add interface (e.g., the `inject` interface of the `mesh-inject` service), parses the request, and converts the parsed data into a container group structure (i.e., the container configuration's raw information). This raw container configuration includes the main container's configuration information. Next, it determines whether the container group needs to inject companion container configuration information. If so, it retrieves the companion container's current configuration information from the configuration database (which can exist in CR form) and adds this information as an annotation to the container configuration's raw information, assembling it into a new container. The system first obtains the container group configuration information (i.e., container configuration target information) and constructs a new container group creation request. Then, it uses the new container group creation request to access the existing interface of the Istio server (e.g., the existing inject interface of the Istio server), triggering the registered message processing class to access the Istio server. The Istio server parses the request and converts the parsed data into a container group structure (i.e., container configuration target information). It then determines whether the container group needs to be admitted. If so, it obtains the container group patch template information, adds the required information to the container configuration target information, and generates new container group configuration information. The generated container group configuration information is then stored in the configuration information database (e.g., etcd). Finally, the Kubernetes server calls the container group configuration information in etcd to create the main container and companion container in the container group.

[0052] In the embodiments of this invention, the architecture utilizes the extension capabilities provided by the Kubernetes interface service. The admission controller includes two types: a change admission controller and a verification admission controller. Essentially, the admission controller is an admission call to the interface service. Furthermore, after the Kubernetes change admission controller detects a container group creation request, it intercepts the request information, adds annotations related to the companion container configuration, and then calls the companion container injection interface provided by Istio to complete the distribution of the customized configuration of the companion container.

[0053] It is understood that, in the embodiments of the present invention, the container group creation request initiated by the microservice client can be intercepted, the container group creation request can be parsed to obtain the original container configuration information of the current microservice, the current configuration information of the companion container of the current microservice can be obtained from the configuration server, the current configuration information of the companion container can be added to the original container configuration information to obtain the container configuration target information of the current microservice, and the container configuration target information can be sent to the microservice server so that the microservice server can inject the companion container into the container group of the current microservice according to the container configuration target information. This method can obtain the current configuration information of the companion container of the current microservice from the configuration server, and then realize the injection of the companion container by modifying the original container configuration information. That is, the present invention uses service-level configuration for companion container injection. Different microservices can configure different companion containers or have different companion container configuration information. Compared with the injection of companion containers according to namespace, the injection method of the present invention is more flexible, can meet the personalized needs of different microservices, and reduce resource waste.

[0054] In some embodiments of the present invention, the configuration server may be a distributed key-value storage system server (etcd server). The configuration server may include a companion container configuration library, which may store configuration information of each companion container according to a service or the mesh corresponding to the service. Therefore, based on the service identifier of the current microservice, the current configuration information of the companion containers of the current microservice can be obtained from the companion container configuration library of the configuration server. Figure 1 The specific implementation process of S103 can be described as follows:

[0055] (1) Determine whether the companion container configuration library contains the exclusive configuration information of the companion container of the current microservice based on the service identifier of the current microservice.

[0056] Specifically, the service identifier of the current microservice can be either the service identifier of the current microservice itself or the identifier of the application to which the current microservice constitutes. The service identifier of the current microservice can be used to search the companion container configuration library to see if the unique configuration information of the companion container for the current microservice exists. For example, if the current microservice is a payment service, and this microservice constitutes an e-commerce platform, the current configuration information of the companion container for the current microservice can be retrieved from the companion container configuration library of the configuration server based on the name of the payment service, or the current configuration information of the companion container for the current microservice can be retrieved from the companion container configuration library of the configuration server based on the name of the e-commerce platform.

[0057] Understandably, based on the service identifier of the current microservice, the current configuration information of the companion container of the current microservice is obtained from the companion container configuration library of the configuration server. This method utilizes the service identifier of the current microservice to obtain the current configuration information of the companion container of the current microservice, so that the obtained current configuration information of the companion container corresponds to the current microservice. This allows the microservice to implement peripheral functions through the companion container, avoiding the situation where the injected companion container is insufficient to support the functional requirements of the current microservice, thus preventing service errors and crashes deployed on the microservice.

[0058] (2) If it exists, obtain the exclusive configuration information of the companion container of the current microservice from the companion container configuration library, and determine the exclusive configuration information as the current configuration information of the companion container of the current microservice.

[0059] For example, such as Figure 3 As shown in Figure 3, this is a schematic diagram illustrating the effect of a specific configuration information provided in an embodiment of the present invention. Figure 3 The system includes two types of options: grid and service, and six resource options: CPU, memory, version, log level, termination delay interval, and number of concurrent threads. It allows for the pre-configuration of specific configuration information based on the services deployed on the microservice.

[0060] In embodiments of the present invention, the configuration of the dedicated configuration information in the companion container configuration library is related to the services deployed on the microserver. For services with high online access frequency, higher resource configuration can be used, while for services with low online access frequency, lower resource configuration can be used.

[0061] For example, if the current microservice focuses on the payment service, and there is dedicated configuration information for the companion container of the payment service in the companion container library, then that dedicated configuration information will be determined as the current configuration information of the companion container of the payment service.

[0062] (3) If it does not exist, the default configuration information of the companion container of the current microservice is obtained from the companion container configuration library, and the default configuration information is determined as the current configuration information of the companion container of the current microservice.

[0063] In some embodiments of the present invention, if the companion container configuration information for the current microservice does not exist in the companion container configuration library, the default configuration information in the companion container configuration library is used as the current configuration information for the companion container of the current microservice. The default configuration is at the grid level, meaning that all companion containers in the corresponding grid of the microservice have the same configuration.

[0064] For example, such as Figure 4 As shown, Figure 4 This is a schematic diagram illustrating the effect of default configuration information provided in an embodiment of the present invention. Figure 4 On the left are the main modules of the JSMF microservice platform, including: network management, cluster management, group management, gateway management, control plane management, data plane management, registry center management, service governance, configuration management, network management service, Skywalking, and unitization management. On the right are selection boxes for meshes and services. Select the target mesh and service in the selection boxes, and then click the query button to perform the search. The page displays the name, mesh, service, version, CPU, memory, and operations. "Default" in the name indicates the default configuration information; "Mesh-jdcloud001-istioi" is the selected mesh; and the service, version, CPU, and memory all correspond to their respective default resource values.

[0065] For example, in the user service, payment service, warehousing service, order service and information service of the e-commerce platform, the configurations of the user service, warehousing service, order service and information service are the same. For the payment service, when there is no exclusive configuration information for the companion container in the companion container configuration library, the current configuration information of the companion container corresponding to the payment service is the default configuration, that is, the same as the configuration information of the companion container in the user service, warehousing service, order service and information service.

[0066] It is understood that in some embodiments of the present invention, the method determines whether the companion container configuration library contains dedicated configuration information for the current microservice's companion container. If it exists, the dedicated configuration information is retrieved from the companion container configuration library and used as the current configuration information. If it does not exist, the default configuration information is retrieved from the companion container configuration library and used as the current configuration information. In this method, the dedicated configuration information for the current microservice's companion container is first searched in the companion container configuration library. Only after no dedicated configuration information is found is the default configuration information used as the dedicated configuration information for the current microservice's companion container. This method satisfies the personalized needs of different microservices, ensures the rational use of resources, and avoids resource waste.

[0067] In some embodiments, the configuration server may further include a container group configuration library, which stores container configuration information for microservices, such as the target container configuration information for the current microservice. By setting up a companion container configuration library and a container group configuration library in the configuration server, the companion container configuration information and the container group configuration information are isolated, facilitating the querying and use of configuration information.

[0068] In some embodiments of the present invention, the companion container configuration library can be created by the following method:

[0069] (1) Monitor the access traffic of each microservice.

[0070] In some embodiments of the present invention, access traffic to each microservice can be detected. For example, in an e-commerce platform, the number of times microservices such as user services, payment services, warehousing services, order services, and information services are accessed can be monitored.

[0071] (2) Configure companion containers for each microservice based on the access traffic of each microservice to obtain the companion container configuration library.

[0072] In some embodiments of the present invention, access traffic can help understand which services deployed on each microservice are accessed most frequently, which require more computing resources, and what shortcomings can be modified. Therefore, companion containers for each microservice can be configured based on their access traffic, resulting in a companion container configuration library. For example, when the access traffic to the user service and payment service in an e-commerce platform is high (i.e., accessed frequently), the companion container configuration, including CPU and memory, indicates that the companion containers implementing the user service and payment service need more CPU and memory resources. Therefore, more CPU and memory resources can be configured for the companion containers implementing the user service and payment service. In practical applications, the required configuration can be categorized according to access traffic, and resources can be configured accordingly. For example, the required configuration can be categorized into high, medium, and low. For high-level resource configuration, a CPU and memory configuration of 4 cores and 8 gigabytes is recommended; for medium-level resource configuration, a CPU and memory configuration of 2 cores and 4 gigabytes is recommended; and for low-level resource configuration, a CPU and memory configuration of 1 core and 2 gigabytes is recommended.

[0073] It is understood that in some embodiments of the present invention, the access traffic of each microservice is monitored; companion containers are configured for each microservice based on the access traffic of each microservice, resulting in a companion container configuration library. In this method, by analyzing the access traffic of services deployed on each microservice, the microservices with the most frequent access are identified, and companion containers are configured for them, ensuring reasonable resource utilization. Furthermore, the configuration information of the companion containers is stored in the companion container configuration library, so that when the current configuration information of the companion container of the current microservice needs to be obtained, it can be directly retrieved from the companion container configuration library, improving retrieval efficiency.

[0074] In some embodiments of the present invention, the injected companion container can also be updated, and the specific update method is as follows: Figure 5 As shown, it includes the following steps:

[0075] S401. Monitor whether the current configuration information of the companion container of the current microservice in the companion container configuration library has changed.

[0076] In some embodiments of the present invention, an electronic device may be configured with a coordinator service. This coordinator service can monitor the current configuration information of the companion containers of the current microservice in the companion container configuration library to identify whether the current configuration information of the companion containers of the current microservice has changed. For example, during peak periods of product purchases, when the access traffic to user services and payment services on an e-commerce platform increases and more computing resources are required, the current configuration information of the companion containers of user services and payment services in the companion container configuration library can be changed to support the operation of user services and payment services. Therefore, it is necessary to periodically or in real-time monitor the current configuration information of the companion containers of the current microservice in the companion container configuration library to see if any changes have occurred.

[0077] S402. If the current configuration information of the companion container of the current microservice in the companion container configuration library has changed, then obtain the updated configuration information of the companion container of the current microservice from the companion container configuration library.

[0078] In some embodiments of the present invention, if it is found that the current configuration information of the companion container of the current microservice in the companion container configuration library has changed, the coordinator service can be used to obtain the updated configuration information of the companion container of the current microservice from the companion container configuration library and cache the updated configuration information locally.

[0079] S403. Update the current configuration information of the companion container in the container configuration target information to the updated configuration information to obtain the container configuration update information of the current microservice.

[0080] In some embodiments of the present invention, the current configuration information of the companion container in the container configuration target information can be replaced by updated configuration information to obtain the container configuration update information of the current microservice. For example, when a configuration service of a configuration mesh starts or restarts, a change admission controller can be used to intercept it and inject the updated configuration information into the container configuration target information.

[0081] For example, during peak periods of item purchases, the increased access traffic to user services and payment services on the e-commerce platform may necessitate a reconfiguration of CPU and memory. In this case, the reconfigured CPU and memory are used to replace the previously configured CPU and memory in the companion container within the container configuration target information, thus obtaining the current microservice's container configuration update information.

[0082] S404. Send container configuration update information to the microservice server so that the microservice server can update the companion container injected into the container group of the current microservice according to the container configuration update information.

[0083] In some embodiments of the present invention, the interceptor sends container configuration update information to the microservice server. After the microservice server obtains the container configuration update information, it updates the companion container injected into the container group of the current microservice.

[0084] In embodiments of the present invention, on a Kubernetes system, a canary approach can be used for rolling upgrades of services. First, a portion of traffic is switched to the new microservice. Once the service is stable, traffic can be gradually switched back, eventually reaching the new version, minimizing the impact on actual online business operations. For example, if the current application's microservices are implemented using multiple container groups, such as container group 1 and container group 2, for instance, version V1 includes container group 1 and container group 2, when a microservice upgrade is needed, in the upgrade version V2, an upgraded version of container group 1 can be created first based on the latest configuration. Then, the old version of container group 1 in version V1 is killed. Next, an upgraded version of container group 2 is created in the upgrade version V2, and finally, the old version of container group 2 in version V1 is killed, thus achieving a rolling upgrade.

[0085] It is understood that, in some embodiments of the present invention, the method monitors whether the current configuration information of the companion container of the current microservice in the companion container configuration library has changed; if the current configuration information of the companion container of the current microservice in the companion container configuration library has changed, the updated configuration information of the companion container of the current microservice is obtained from the companion container configuration library; the current configuration information of the companion container in the container configuration target information is updated to the updated configuration information to obtain the container configuration update information of the current microservice; the container configuration update information is sent to the microservice server so that the microservice server updates the companion containers injected in the container group of the current microservice according to the container configuration update information. In this method, monitoring whether the current configuration information of the companion container of the current microservice has changed, and updating the current configuration information of the companion container in a timely manner when a change occurs, ensures that the services deployed on the microservice can run normally and avoids errors or crashes during critical moments or peak usage periods.

[0086] In an embodiment of the present invention, Figure 6 This is a schematic diagram of a container injection device provided by the present invention. This device is suitable for performing the container injection method provided by the present invention, such as... Figure 6 As shown, the device may specifically include:

[0087] Interception module 601 is used to intercept container group creation requests initiated by microservice clients;

[0088] Parsing module 602 is used to parse the container group creation request to obtain the original container configuration information of the current microservice;

[0089] The acquisition module 603 is used to obtain the current configuration information of the companion container of the current microservice from the configuration server;

[0090] Add module 604, used to add the current configuration information of the companion container to the original container configuration information to obtain the container configuration target information of the current microservice;

[0091] The sending module 605 is used to send the container configuration target information to the microservice server so that the microservice server injects the companion container into the container group of the current microservice according to the container configuration target information.

[0092] In one embodiment, the acquisition module 603 is specifically used for:

[0093] Based on the service identifier of the current microservice, obtain the current configuration information of the companion container of the current microservice from the companion container configuration library of the configuration server.

[0094] In one embodiment, the acquisition module 603 is specifically used for:

[0095] Determine whether the companion container configuration library contains the exclusive configuration information for the companion container of the current microservice;

[0096] If it exists, then obtain the exclusive configuration information of the companion container of the current microservice from the companion container configuration library, and determine the exclusive configuration information as the current configuration information;

[0097] If it does not exist, the default configuration information of the companion container of the current microservice is obtained from the companion container configuration library, and the default configuration information is determined as the current configuration information.

[0098] The container injection device of the present invention further includes a creation module, which is specifically used for:

[0099] Monitor the access traffic of each microservice; configure companion containers for each microservice based on the access traffic of each microservice, and obtain the companion container configuration library.

[0100] In one embodiment, the device further includes an update module, which is specifically used for:

[0101] Monitor whether the current configuration information of the companion container of the current microservice in the companion container configuration library has changed;

[0102] If the current configuration information of the companion container of the current microservice in the companion container configuration library changes, then the updated configuration information of the companion container of the current microservice is obtained from the companion container configuration library.

[0103] The current configuration information of the companion container in the container configuration target information is updated to the updated configuration information to obtain the container configuration update information of the current microservice;

[0104] Send the container configuration update information to the microservice server so that the microservice server updates the companion container injected into the container group of the current microservice according to the container configuration update information.

[0105] In one embodiment, module 604 is added, specifically for:

[0106] The original container configuration information includes the current configuration information of the main container of the current microservice. The current configuration information of the main container is used by the microservice server to inject the main container into the container group of the current microservice.

[0107] The configuration server also includes a container group configuration library, which is used to store the container configuration target information of the current microservice.

[0108] In one embodiment, module 604 is added, specifically for:

[0109] The current configuration information of the companion container is added as an annotation to the original container configuration information to obtain the container configuration target information of the current microservice.

[0110] The container injection device of the present invention further includes a verification module, which is specifically used for:

[0111] Before sending the container configuration target information to the microservice server, the container configuration target information is verified. If the verification passes, the sending module 605 is triggered to send the container configuration target information to the microservice server.

[0112] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional modules is merely an example. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The specific working process of the functional modules described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0113] The apparatus of this invention can intercept container group creation requests initiated by microservice clients, parse the container group creation requests to obtain the original container configuration information of the current microservice, obtain the current configuration information of the companion container of the current microservice from the configuration server, add the current configuration information of the companion container to the original container configuration information to obtain the container configuration target information of the current microservice, and send the container configuration target information to the microservice server so that the microservice server injects the companion container into the container group of the current microservice according to the container configuration target information. This invention can obtain the current configuration information of the companion container of the current microservice from the configuration server, and then achieve the injection of the companion container by modifying the original container configuration information. That is, this invention uses service-level configuration for companion container injection. Different microservices can configure different companion containers or have different companion container configuration information. Compared with injecting companion containers according to namespaces, the injection method of this invention is more flexible, can meet the personalized needs of different microservices, and reduce resource waste.

[0114] This invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the container injection method provided in any of the above embodiments.

[0115] This invention also provides a computer-readable medium storing a computer program thereon, which, when executed by a processor, implements the container injection method provided in any of the above embodiments.

[0116] The following is for reference. Figure 7 It shows a schematic diagram of the structure of a computer system 700 suitable for implementing an electronic device according to embodiments of the present invention. Figure 7 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the invention.

[0117] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 702 or programs loaded from storage section 708 into random access memory (RAM) 703. The RAM 703 also stores various programs and data required for the operation of the computer system 700. The CPU 701, ROM 702, and RAM 703 are interconnected via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0118] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, mouse, etc.; an output section 707 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 710 as needed so that computer programs read from it can be installed into the storage section 708 as needed.

[0119] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 709, and / or installed from removable medium 711. When the computer program is executed by central processing unit (CPU) 701, it performs the functions defined above in the system of this invention.

[0120] It should be noted that the computer-readable medium shown in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0121] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0122] The modules and / or units described in this invention can be implemented in software or hardware. The described modules and / or units can also be housed in a processor; for example, a processor can be described as including an interception module, a parsing module, an acquisition module, an addition module, and a sending module. The names of these modules do not necessarily limit the module itself.

[0123] In another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs, which, when executed by the device, cause the device to include:

[0124] The system intercepts container group creation requests initiated by microservice clients; parses the container group creation requests to obtain the original container configuration information of the current microservice; obtains the current configuration information of the companion container of the current microservice from the configuration server; adds the current configuration information of the companion container to the original container configuration information to obtain the container configuration target information of the current microservice; and sends the container configuration target information to the microservice server so that the microservice server injects the companion container into the container group of the current microservice according to the container configuration target information.

[0125] According to the technical solution of the present invention, service-level configuration is used for the injection of companion containers. Different microservices can be configured with different companion containers or have different companion container configuration information. The injection method is more flexible, can meet the personalized needs of different microservices, and reduce resource waste.

[0126] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0127] It should be noted that the collection, gathering, updating, analysis, processing, use, transmission, and storage of user personal information involved in this disclosed technical solution all comply with relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken to prevent unauthorized access to user personal information data and to safeguard user personal information security, network security, and national security.

[0128] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A method of container injection, characterized by, include: Intercept container group creation requests initiated by microservice clients; Parse the container group creation request to obtain the original container configuration information of the current microservice, which includes the current configuration information of the main container of the current microservice; Based on the service identifier of the current microservice, access the added interface of the mesh service to obtain the current configuration information of the companion container of the current microservice from the companion container configuration library of the configuration server; including: determining whether there is dedicated configuration information of the companion container of the current microservice in the companion container configuration library; if so, obtaining the dedicated configuration information of the companion container of the current microservice from the companion container configuration library, and determining the dedicated configuration information as the current configuration information; the configuration of the dedicated configuration information is related to the service deployed on the microserver. For services with high online access frequency, a higher resource configuration is used, and for services with low online access frequency, a lower resource configuration is used. The current configuration information of the companion container is added as an annotation to the original container configuration information to obtain the target container configuration information of the current microservice; Sending the container configuration target information to the microservice server so that the microservice server injects the companion container into the container group of the current microservice according to the container configuration target information; including: constructing a new container group creation request using the container configuration target information, calling the companion container injection interface of the Istio server so that the Istio server parses the new container group creation request and converts the parsed data into the container configuration target information, obtaining container group patch template information, and generating new container group configuration information by supplementing the required information into the container configuration target information, storing the new container group configuration information in the configuration information database, and the microservice server calling the container group configuration information in the configuration information database to inject the companion container and the main container into the container group of the current microservice.

2. The container injection method of claim 1, wherein, After determining whether the companion container configuration library contains the exclusive configuration information for the companion container of the current microservice, the method further includes: If it does not exist, the default configuration information of the companion container of the current microservice is obtained from the companion container configuration library, and the default configuration information is determined as the current configuration information.

3. The container injection method of claim 1, wherein, The companion container configuration library is created using the following method: Monitor the access traffic of each microservice; Based on the access traffic of each microservice, companion containers are configured for each microservice to obtain the companion container configuration library.

4. The container injection method of claim 1, wherein, The method further includes: Monitor whether the current configuration information of the companion container of the current microservice in the companion container configuration library has changed; If the current configuration information of the companion container of the current microservice in the companion container configuration library changes, then the updated configuration information of the companion container of the current microservice is obtained from the companion container configuration library. The current configuration information of the companion container in the container configuration target information is updated to the updated configuration information to obtain the container configuration update information of the current microservice; Send the container configuration update information to the microservice server so that the microservice server updates the companion container injected into the container group of the current microservice according to the container configuration update information.

5. The container injection method of claim 1, wherein, The original container configuration information includes the current configuration information of the main container of the current microservice. The current configuration information of the main container is used by the microservice server to inject the main container into the container group of the current microservice. The configuration server also includes a container group configuration library, which is used to store the container configuration target information of the current microservice.

6. The container injection method of claim 1, wherein, Before sending the container configuration target information to the microservice server, the following steps are also included: The container configuration target information is verified. If the verification passes, the step of sending the container configuration target information to the microservice server is triggered.

7. A container injection apparatus, characterized by, include: The interception module is used to intercept container group creation requests initiated by microservice clients; The parsing module is used to parse the container group creation request to obtain the original container configuration information of the current microservice. The original container configuration information includes the current configuration information of the main container of the current microservice. The acquisition module is used to access the addition interface of the mesh service based on the service identifier of the current microservice, and obtain the current configuration information of the companion container of the current microservice from the companion container configuration library of the configuration server; including: determining whether there is dedicated configuration information of the companion container of the current microservice in the companion container configuration library; if so, obtaining the dedicated configuration information of the companion container of the current microservice from the companion container configuration library, and determining the dedicated configuration information as the current configuration information; the configuration of the dedicated configuration information is related to the service deployed on the microserver. For services with high online access frequency, a higher resource configuration is used, and for services with low online access frequency, a lower resource configuration is used. The add module is used to add the current configuration information of the companion container as an annotation to the original container configuration information to obtain the container configuration target information of the current microservice; The sending module is used to send the container configuration target information to the microservice server, so that the microservice server injects the companion container into the container group of the current microservice according to the container configuration target information; including: constructing a new container group creation request using the container configuration target information, calling the companion container injection interface of the Istio server, so that the Istio server parses the new container group creation request, converts the parsed data into the container configuration target information, obtains container group patch template information, and generates new container group configuration information by supplementing the required information into the container configuration target information, and puts the new container group configuration information into the configuration information database, and the microservice server calls the container group configuration information in the configuration information database to inject the companion container and the main container into the container group of the current microservice.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the container injection method as described in any one of claims 1 to 6.

9. A vessel injection system characterized in that, It includes a microservice client, a microservice server, a configuration server, and an electronic device for performing the container injection method as described in any one of claims 1 to 6.

10. A computer-readable storage medium having stored thereon a computer program, characterized in that, When the program is executed by the processor, it implements the container injection method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method for automatically adding agent based on container cloud

    CN114221773A